Game Development Reference
In-Depth Information
return;
}
if (g_pApp->m_bQuitting)
{
PostMessage(g_pApp->GetHwnd(), WM_CLOSE, 0, 0);
}
if (g_pApp->m_pGame)
{
// allow event queue to process for up to 20 ms
IEventManager::Get()->VTick(20);
if (g_pApp->m_pBaseSocketManager)
g_pApp->m_pBaseSocketManager->DoSelect(0); // pause 0 microseconds
g_pApp->m_pGame->VOnUpdate(float(fTime), fElapsedTime);
}
}
This method updates your game logic, but only if there isn
'
t a modal dialog box up
and if the application isn
t quitting.
This code implies that you shouldn
'
'
t perform any quit mechanism while you are
pumping messages. Quitting takes a good amount of time, and a player worried
about getting caught playing your game while he is supposed to be doing something
else can press Alt-F4 to close your game about 20 times in a single second. If you
send all those quit messages into the message pump, you
'
ve got to filter them out,
which is why you check to see if you
re actually quitting so you can post a WM_CLOSE
message. The user interface control that receives the quit button click event or the
hot key event should simply set a Boolean variable to true , which will be checked
after the last message in the queue has been handled.
This function is a member of GameCodeApp , but since this method is a callback, it
must be declared static, which means that you have to use the global g_pApp
pointer to get to the instance of the GameCodeApp class. The same is true for the
GameCodeApp::OnRender call:
'
void CALLBACK GameCodeApp::OnD3D11FrameRender(ID3D11Device* pd3dDevice,
ID3D11DeviceContext* pd3dImmediateContext, double fTime,
float fElapsedTime, void* pUserContext )
{
BaseGameLogic *pGame = g_pApp->m_pGame;
for(GameViewList::iterator i=pGame->m_gameViews.begin(),
end=pGame->m_gameViews.end(); i!=end; ++i)
{
(*i)->VOnRender(fTime, fElapsedTime);
Search WWH ::




Custom Search