Re: [GD-Windows] message pump problem
Brought to you by:
vexxed72
From: Marin K. <m.k...@in...> - 2003-11-25 06:32:16
|
> The problem with this is that Windows expects your message proc to deal with > a number of messages in a burst and gets finicky when intervening "other > thing" happen. I would re-structure that loop as: > while( 1 ) { > while( PeekMessage( PM_REMOVE ) ) { > if( !IsDialogMessage() ) { > TranslateMessage(); > DispatchMessage(); > } > } > Draw(); > } But it's essentially the same thing. I'm not executing any of the game stuff while there's still messages in the queue (if I did I wouln't get the stall). Note the if-else: while(1) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { GetMessage(&msg, NULL, 0, 0); TranslateMessage(&msg); DispatchMessage(&msg); } else { //do game frame here } } > Further, I'd set up the window proc to also call Draw() from WM_TIMER > messages, and possibly from WM_PAINT. That's necessary if you want to keep > updating while the user is moving the window. I'm refreshing the frontbuffer from the WM_PAINT (not executing the game logic). I'll give WM_TIMER a bit of thought. > When you get WM_PAINT, you have to BeginUpdate() and EndUpdate() even if you > don't do anything else. If you don't begin/end updates, then Windows will > not realize that the window has been updated, the dirty region will be > non-empty, and you'll get an endless stream of WM_PAINT messages. (Sound > familiar? :-) Duh. Found a bug. It must have slipped in during the previous bug-hunting session. :) Check it out, it's ridiculous: case (WM_PAINT): { BeginPaint(g_focusWindow, NULL); if (g_pBlitko) { g_pBlitko->PresentFrame(); return (0); } EndPaint(g_focusWindow, NULL); return (0); }break; Thanks for the help, Marin Kovacic Lemonade Productions http://www.lemonade-p.com |