| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 814 人关注过本帖
标题:[求助]OpenGL与windows结合问题!(窗口)
只看楼主 加入收藏
ldcsoftware
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-8-6
收藏
 问题点数:0 回复次数:2 
[求助]OpenGL与windows结合问题!(窗口)

#include <windows.h>
#include <stdio.h>
#include <gl/glut.h>

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
//BOOL CreateWindow(int width,int height);

HINSTANCE hInstance;

void init(void)
{
glClearColor(0.0f,0.0f,0.0f,0.0f);
glShadeModel(GL_FLAT);
}

void display(void)
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

glColor3f(1.0f,1.0f,1.0f);
glPushMatrix();
glutSolidSphere(1.0f,40,16);
glPopMatrix();
}

void reshape(int w,int h)
{
glViewport(0.0f,0.0f,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f,(GLsizei)w / (GLsizei)h,1.0f,20.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

BOOL CreateWindowGL(int width,int height)
{
// hInstance = GetModuleHandle(NULL);
hInstance = GetModuleHandle(NULL);
int right,bottom;
right = width;
bottom = height;
HWND hwnd;
WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(NULL,IDC_CROSS);
wc.hIcon = LoadIcon(NULL,IDI_WINLOGO);
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "lidecheng";
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;

if(!RegisterClass(&wc))
{
MessageBox(NULL,"调试","错误",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

hwnd = CreateWindow("lidecheng","wocaonima",WS_OVERLAPPEDWINDOW,100,100,right,bottom,NULL,NULL,hInstance,NULL);
if(!hwnd)
{
return FALSE;
}

ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
reshape(bottom,width);

return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{

MSG nMsg;
BOOL done = FALSE;

if(!CreateWindowGL(500,500))
{
return 0;
}

while(!done)
{
if(PeekMessage(&nMsg,NULL,0,0,PM_REMOVE))
{
if(nMsg.message = WM_QUIT)
{
done = TRUE;

}
else
{
TranslateMessage(&nMsg);
DispatchMessage(&nMsg);
}
}
else
{
display();
}
}

return (nMsg.wParam);
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
return 0;
/* case 'WM_KEYDOWN':
return 0;
case 'WM_KEYUP':
return 0;
case 'SIZE':
LOWORD(lParam),HIWORD(lParam);
LOWORD(lParam),HIWORD(lParam);
return 0;*/
default :
return 0;
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}

为什么我显示不出来窗口,并且和这个物体!
请哥哥姐姐帮帮我解决这个问题下下!
thank you !


搜索更多相关主题的帖子: windows OpenGL 窗口 结合 
2007-11-20 11:54
Whnight
Rank: 1
等 级:新手上路
帖 子:120
专家分:0
注 册:2007-9-14
收藏
得分:0 
你有新建工程吗?
2007-11-20 12:00
ldcsoftware
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2007-8-6
收藏
得分:0 
回复:(Whnight)你有新建工程吗?

我有啊 就是在写windows那里面写的啊

2007-11-20 17:53
快速回复:[求助]OpenGL与windows结合问题!(窗口)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015938 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved