LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HGLRC hRC; // rendering context
static HDC hDC; // device context
int width, height; // window width and height
int oldMouseX, oldMouseY; switch(message)
{
case WM_CREATE: // window is being created hDC = GetDC(hwnd); // get current window's device context
g_HDC = hDC;
SetupPixelFormat(hDC); // call our pixel format setup function // create rendering context and make it current
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC); return 0;
break; case WM_DESTROY:
PostQuitMessage(0); break;
case WM_CLOSE:
wglMakeCurrent(hDC, NULL);
wglDeleteContext(hRC);
DestroyWindow(hwnd); break;
case WM_SIZE:
height = HIWORD(lParam); // retrieve width and height
width = LOWORD(lParam); if (height==0) // don't want a divide by zero
{
height=1;
} glViewport(0, 0, width, height); // reset the viewport to new dimensions
glMatrixMode(GL_PROJECTION); // set projection matrix current matrix
glLoadIdentity(); // reset projection matrix // calculate aspect ratio of window
gluPerspective(54.0f,(GLfloat)width/(GLfloat)height,1.0f,1000.0f); glMatrixMode(GL_MODELVIEW); // set modelview matrix
glLoadIdentity(); // reset modelview matrix return 0;
break; case WM_KEYDOWN: // is a key pressed?
keyPressed[wParam] = true;
return 0;
break; case WM_KEYUP:
keyPressed[wParam] = false;
return 0;
break; case WM_MOUSEMOVE:
// save old mouse coordinates
oldMouseX = mouseX;
oldMouseY = mouseY; // get mouse coordinates from Windows
mouseX = LOWORD(lParam);
mouseY = HIWORD(lParam); // these lines limit the camera's range
if (mouseY < 200)
mouseY = 200;
if (mouseY > 450)
mouseY = 450; if ((mouseX - oldMouseX) > 0) // mouse moved to the right
angle += 3.0f;
else if ((mouseX - oldMouseX) < 0) // mouse moved to the left
angle -= 3.0f; return 0;
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
break;
}
return 0; } 这是我的消息处理函数
为什么我关闭程序时进程为什么没有自动关闭
搞的每次运行时都要在任务管理器中结束进程了
大家帮我看看那里有问题
谢谢!!!
{
static HGLRC hRC; // rendering context
static HDC hDC; // device context
int width, height; // window width and height
int oldMouseX, oldMouseY; switch(message)
{
case WM_CREATE: // window is being created hDC = GetDC(hwnd); // get current window's device context
g_HDC = hDC;
SetupPixelFormat(hDC); // call our pixel format setup function // create rendering context and make it current
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC); return 0;
break; case WM_DESTROY:
PostQuitMessage(0); break;
case WM_CLOSE:
wglMakeCurrent(hDC, NULL);
wglDeleteContext(hRC);
DestroyWindow(hwnd); break;
case WM_SIZE:
height = HIWORD(lParam); // retrieve width and height
width = LOWORD(lParam); if (height==0) // don't want a divide by zero
{
height=1;
} glViewport(0, 0, width, height); // reset the viewport to new dimensions
glMatrixMode(GL_PROJECTION); // set projection matrix current matrix
glLoadIdentity(); // reset projection matrix // calculate aspect ratio of window
gluPerspective(54.0f,(GLfloat)width/(GLfloat)height,1.0f,1000.0f); glMatrixMode(GL_MODELVIEW); // set modelview matrix
glLoadIdentity(); // reset modelview matrix return 0;
break; case WM_KEYDOWN: // is a key pressed?
keyPressed[wParam] = true;
return 0;
break; case WM_KEYUP:
keyPressed[wParam] = false;
return 0;
break; case WM_MOUSEMOVE:
// save old mouse coordinates
oldMouseX = mouseX;
oldMouseY = mouseY; // get mouse coordinates from Windows
mouseX = LOWORD(lParam);
mouseY = HIWORD(lParam); // these lines limit the camera's range
if (mouseY < 200)
mouseY = 200;
if (mouseY > 450)
mouseY = 450; if ((mouseX - oldMouseX) > 0) // mouse moved to the right
angle += 3.0f;
else if ((mouseX - oldMouseX) < 0) // mouse moved to the left
angle -= 3.0f; return 0;
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
break;
}
return 0; } 这是我的消息处理函数
为什么我关闭程序时进程为什么没有自动关闭
搞的每次运行时都要在任务管理器中结束进程了
大家帮我看看那里有问题
谢谢!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货