I’m working on a small game engine and I’ve encountered a problem.
So far, I have a window class that is a wrapper for a Win32 window. I also have a Window Manager class (it’s a singleton class) that manages the creation of windows and the handling of windows messages. I then have an engine class, which is so far the most important class, as it is the interface for the engine. This engine class contains the main loop, and the direct3d device, as well as the code to create and destroy it. This engine class also contains a Window class object, which acts as the main/host window for the direct3d device.
My problem is that the engine needs to react to some of the windows messages (such as WM_SIZE or WM_ACTIVATEAPP), but the message handler is part of the Widnow class, which is a “level” below the Engine class. I also think that I should create another class to encapsulate the rendering/graphics of the engine, and then add that class to the main engine class.
So I’m not sure whether I should have a Graphics class inside a Window class, or a Window class inside a Graphics class, or have them side by side in a main Engine class.
You’re living in an event-driven world, so use events. Have your window wrapper provide events that the game engine can hook and react to.