RE: [GD-Windows] message pump problem
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2003-11-24 17:04:35
|
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(); } 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. 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? :-) Cheers, / h+ -----Original Message----- From: gam...@li... [mailto:gam...@li...]On Behalf Of Marin Kovacic Sent: Monday, November 24, 2003 1:17 AM To: gam...@li... Subject: [GD-Windows] message pump problem [sorry, this may be posted twice, I posted it from the wrong account and it got stuck for moderator approval] Hi, I was wondering exactly what code you guys use for your message pumps? The thing is that after recent bug hunting I changed the pump to something like while(1) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { GetMessage(&msg, NULL, 0, 0); TranslateMessage(&msg); DispatchMessage(&msg); } else { //do game frame here } } , and I've had a support mail from a guy to whom the game stops at the loading screen. After inspecting his logs, it turns out that he's getting an endless stream of WM_PAINT messages, and the game loop stuff never gets executed. I've reread the GetMessage/PeekMessage stuff in MSDN and there's some mumbo-jumbo about WM_PAINT messages not being removed from the queue by GetMessage(), and system issueing WM_PAINT messages when the queue is empty but, frankly, I didn't manage to understand any of it. So, what exactly if the correct way to handle this? I've created a workaround and while it works, it's ugly as hell and I'd rather it's not there at all. Thanks, Marin Kovacic Lemonade Productions http://www.lemonade-p.com ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=555 |