window update problem in windows

I have an OpenGL application that I made using a win32 console application in Visual Stuido 6.0 . Everything works, except that the frame loop does not get executed unless I move the mouse over the window. What I mean is that the program seems to pause unless the mouse is moving over the window. Any ideas why this might happen?


So the problem seems to have something to do with PeekMessage(…) vs. GetMessage(…). I removed my GetMessage(…) calls, and the program updates properly, but it no longer takes keyboard input. Any suggestions?


As part of your rendering loop, you should check PeekMessage to see if there are any windows messages to process.
If there is, only then should you call GetMessage. Since these windows messages are being queued, it is best to process all outstanding messages during that time.

Example code is:

while (PeekMessage(&msg,NULL,NULL,NULL,NULL)) {
if (GetMessage(&msg,NULL,NULL,NULL)) {
} else {
// Shut down your application

Rember that this needs to be called repeatedly to ensure proper processing. ie: You can execute this code once per frame.