I'm writing a 3D application for Windows, using OpenGL. For now it renders a simple test scene with one model of about 50000 polygons and it renders smoothly at 60FPS.
However, the framerate gets very uneven whenever the mouse is moved over the application window. It fluctuates from 400 FPS to 20 FPS randomly. Is there any reason for this? Is this caused by mouse events the app is forced to handle? Can I disable them and just poll the mouse state?
My app loop is very simple, something more or less like:
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
{
quit();
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
draw();
Sleep(1);
}
and the window procedure is basically
return DefWindowProc(hWnd,uMsg,wParam,lParam);