This is driving me nutty.
I''ve seen everything from:
(Microsoft
BOOL bGotMsg;
MSG msg;
PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE );
while( WM_QUIT != msg.message )
{
// 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 = PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE );
else
bGotMsg = GetMessage( &msg, NULL, 0U, 0U );
if( bGotMsg )
{
// Translate and dispatch the message
if( 0 == TranslateAccelerator( m_hWnd, hAccel, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
{
// Render a frame during idle time (no messages are waiting)
if( m_bActive && m_bReady )
{
if( FAILED( Render3DEnvironment() ) )
SendMessage( m_hWnd, WM_CLOSE, 0, 0 );
}
}
}
to...
(LaMothe... both are fairly similar)
BOOL bGotMsg = FALSE;
PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE );
while(WM_QUIT != msg.message ){
// 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( g_bIsActive )
bGotMsg = PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE );
else
bGotMsg = GetMessage( &msg, NULL, 0U, 0U );
if( bGotMsg )
{
// Translate and dispatch the message
TranslateMessage( &msg );
DispatchMessage( &msg );
} else {
// main game processing goes here
if(g_bDisplayReady){
Game_Frame();
}
}
} // end while
to...
(Parberry)
while(TRUE)
if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)){
if(!GetMessage(&msg,NULL,0,0))return msg.wParam;
TranslateMessage(&msg); DispatchMessage(&msg);
}
else if(ActiveApp)ProcessFrame(); else WaitMessage();
Basically, you don''t need to read any of that code, but I''m just wondering what bActive/bReady are, or when to change them..
I''m basically just wondering what is a simple way to do a message loop that could handle the app losing focus (minimized, whatever), and what WM_ message goes with that, and game pausing...
What do you guys use?
-----------------
The Goblin
-----------------
"Oh, God..."
"Yes?" <- My Response