The idea for this file is to put all of the Windows-dependent code in it.
That way if you want to port your game to Linux or Mac OS then you don't
have to go all through your code to make changes.
I only made minor changes to the book's code for main.cpp.
Here they are:
- Definitions of global variables were moved to engine.cpp.
I probably took this too far, and should have only moved the DirectX
variables there and not the Windows ones like g_hWndMain.
- I made objects of the Display and Controller class called display and
controller as local variables in WinMain.
The controller is initialized in a constructor, but the display has a
member function called initialize().
- GameInit, GameLoop, and GameShutdown were replaced by display.initialize(),
controller.tick(), and display.shutdown(), respectively.
- After the display is initialized, a pointer to the display is passed to the
The same controller function that sets the display also gives the display a
pointer to the Game object.
- I added a global variable for a debugging output stream to this file.
This is an example of a variable that could be used literally anywhere in the
file, and needs to be global.
A better implementation of the debugging stream would use #ifdef to not
include the debugging code in the release version, but we can look at that
possibility later in the term.