In the window procedure message processing function, I have come across a couple of things where I just have no idea what to do apart from declare a class globally so that my window procedure can see it.
Imagine I have a Game
class that is created in the window loop function and has a handle to the window passed through into it:
class Game
{
game( HWND hWnd );
void Go();
void ReCalculateViewportOffsets();
}
...// windows stuff and handle to window created
Game theGame( hWnd );
...// windows loop starts
theGame.Go();
Half-way through my game, someone changes the resolution so I need to fire a redraw with new offsets to center my viewport... I would like to call that from my WM_RESIZE
handler, but theGame
has been declared as a local in my main function rather than a global. Probably a good thing? but how on earth can I get hold of theGame
in my windows procedure function without declaring it globally:
case "WM_RESIZE":
//...
theGame.ReCalculateViewportOffsets( newWidth, newHeight );