Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17625

Basic Windows Message loop

$
0
0

Common wisdom is to construct a game's message pump as some flavor of this:

	MSG msg = { 0 };

	while(msg.message != WM_QUIT)
	{
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			Update();
		}
	}

Does this still make sense with modern multi-threaded engine design?  Might it not be better to use GetMessage instead of PeekMessage, which blocks until a message is received, and let a separate thread(s) handle all the game logic/rendering?  Then the actual window handling can't get hung up by the rendering, and the rendering doesn't get potentially hiccuped by windows events…


Viewing all articles
Browse latest Browse all 17625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>