Skip to main content
This appears to be a technical question unrelated to the design of your game.
Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345
Source Link

Game loop c++ implementation

I'm starting to develop some simple 3D game. The basic topic for a start is the game loop.

There is a solution:

while (true) 
{
    while (PeekMessage(&msg,0,0,0,PM_REMOVE)
    {
        // Translate and dispatch message
    }

    if (msg.message == WM_QUIT)
    {
        break;
    }

   // Do update, rendering and all the real game loop stuff

}

proposed by Syntac_ in this thread.

The above answer revived positive feedback WHILE the solution seems to NOT be valid! When I click on the close ('X') button (or just press ALt+F4) to close the main app window nothing happens - the app is still running! Fast investigation - the problem is that the app receives some extra WM_TIMER message after the WM_QUIT message so the if (msg.message == WM_QUIT) is NEVER reached!