Re: [GD-Windows] message pump problem
Brought to you by:
vexxed72
From: Slava K. <sla...@gs...> - 2003-11-24 09:27:27
|
Hello Marin. INT CD3DApplication::Run ( ){ // Now we're ready to recieve and process Windows messages. BOOL bGotMsg; MSG msg; PeekMessage ( &msg, NULL, 0U, 0U, PM_NOREMOVE ); BOOL bIsIconic =3D FALSE; while( msg.message!=3DWM_QUIT && !m_bStop ){ // Use PeekMessage() if the app is active, so we can use idle time to // render the scene. Else, use GetMessage() to avoid eating CPU time. if( m_bActive ) bGotMsg =3D PeekMessage ( &msg, NULL, 0U, 0U, PM_REMOVE ); else bGotMsg =3D GetMessage ( &msg, NULL, 0U, 0U ); // =E5=F1=EB=E8 =F1=EE=EE=E1=F9=E5=ED=E8=E5 =EF=EE=EB=F3=F7=E5=ED=EE, = =EE=E1=F0=E0=E1=E0=F2=FB=E2=E0=E5=EC =E5=E3=EE if( bGotMsg ){ TranslateMessage ( &msg ); DispatchMessage ( &msg ); }else if( m_bActive && m_bReady ){ // =E8=ED=E0=F7=E5 =F0=E5=ED= =E4=E5=F0=E8=EC =EA=E0=E4=F0 (=E5=F1=EB=E8 =EF=F0=E8=EB=EE=E6=E5=ED=E8=E5 =E0=EA=F2=E8=E2=ED=EE) if( bIsIconic ){ bIsIconic =3D IsIconic(g_hwndMain); Sleep ( 100 ); continue; } bIsIconic =3D IsIconic(g_hwndMain); if( !g_bRenderInactive ){ HWND hActiveWnd =3D GetActiveWindow(); if( hActiveWnd!=3Dg_hwndMain ){ Sleep ( 100 ); continue; } } UpdateEnvironment ( ); if( FAILED(Render3DEnvironment()) ){ SendMessage ( m_hWnd, WM_CLOSE, 0, 0 ); } } } // =E3=EE=F2=EE=E2=EE return (INT) msg.wParam; } ----- Original Message ----- From: "Marin Kovacic" <m.k...@in...> To: <gam...@li...> Sent: Monday, November 24, 2003 11:17 AM 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=3D555 |