Original Post
I have a question. I was looking though how a few people/authors create a game loop and I look at it an I thought that one is actually slower than another.
The first:
while(true) //infinite loop
{
if(PeekMessage(....) )
{
//Handle windows messages
}
else
{
//Do game suff
}
} //Do over
The second:
while(true)
{
if( PeekMessage(....))
{
//Handle messges
}
//Do game stuff
}
As you can see there is barely a difference, but the second one seems to me as if it woud run faster. I know the difference would be minimal(proably neglible) but I think there would be one. Also, in the first version of the game loop, if somehow your program kept handling windows messages it would forget about doing the game code until the next iteration of the loop. The second version does the game loop after a windows message without having to go through the loop again.
I personally like the second one better. But I want other opinions.
"Ogun''s Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.