Freaky problem
I''ve been working my way through a book on DirectX. I only have the following problem when I implement D3D. It''s a basic implementation to just draw some pixels to the screen. I''m just at a point where something pretty wierd seems to be happening in my message loop...
PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE);
// run till completed
while (msg.message!=WM_QUIT) {
if (PeekMessage( &msg, NULL, 0, 0, PM_REMOVE)) {
// dispatch the message
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
GameLoop();
}
}
The problem is GameLoop() Never gets called! I modified my code a bit to output the first 100 window messages to the debug window and they''re all f..er 15.. Looked it up in
Winuser.h:
#define WM_PAINT 0x000F
Looks like I''m being flooded with paint messages!
Also, if I put the call to gameloop somewhere else, like in a loop that executes 100 times everything draws fine, program exits fine with no error messages etc..
I was wondering if anyone knows what would send non-stop paint messages to my window to the point where my loop is never idle?
Or if you think my problem is somewhere else I''d love to hear it?
Thanks!
Sean
Have you captured the WM_PAINT event in your window procedure? If you have then you need to call BeginPaint and EndPaint to let Windows know you handled it. Otherwise it just sends it over and over and over...
put the gameloop() outside the if...else , since under normal operation it won't make a difference.
[edited by - deathtrap on November 12, 2003 9:46:25 PM]
[edited by - deathtrap on November 12, 2003 9:46:25 PM]
<<>>
Ha! Thank you so much..
well.. im not using gdi(yet) so I needed:
ValidateRect(g_hWndMain,NULL);
but it took a whole 2 seconds after reading your post to realize it.. works fine! Thanks man, your a lifesaver
Ha! Thank you so much..
well.. im not using gdi(yet) so I needed:
ValidateRect(g_hWndMain,NULL);
but it took a whole 2 seconds after reading your post to realize it.. works fine! Thanks man, your a lifesaver
<>
makes a big difference.. anything outside the loop only gets called once a quit message has been posted.. ie only executes once.. inside the loop the loop either handles the message or runs the gameloop, which contains my render code
makes a big difference.. anything outside the loop only gets called once a quit message has been posted.. ie only executes once.. inside the loop the loop either handles the message or runs the gameloop, which contains my render code
Actually what you really need to change is
PM_REMOVE to PM_NOREMOVE.
And inside the if use a GetMessage.
This way when there''s no message in the queue your GameLoop will be called and if there''s a message it will be translated.
PM_REMOVE to PM_NOREMOVE.
And inside the if use a GetMessage.
This way when there''s no message in the queue your GameLoop will be called and if there''s a message it will be translated.
GetMessage puts your program to sleep if there isn''t a message I thought? anyway it works fine now, thanks for all the help everyone
Well, when calling PeekMessage in the if before you only reach getmessage when there''s a message ready to be gotten.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement