Hi all,
Can someone freshen up my memory on this one?
In my d3d9 engine I've Always had a main/ game loop like this:
bool run = true;
while(run)
{
_mainApp.mInput.UpdateKeys();
while(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if(msg.message == WM_QUIT) run = false;
}
_mainApp.mTimer.Update();
Currently I'm starting from scratch with my new d3d11 engine, and during learning d3d11, I've found this other way:
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) // WHILE ???
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
//mTimer.Tick();
if(!mAppPaused )
{
CalculateFrameStats();
UpdateScene(16.67f); //mTimer.DeltaTime());
DrawScene();
}
Is there a performance penalty/ advantage on either one of them compared to the other?
Using 'if' from a 'simple viewpoint' sounds best, because you then only do something if there's a message. With 'while' it sounds like waiting till a message occurs.
Any input/ pointers are appreciated.