Integrating the Renderer class
There is obviously no point in even having the Renderer
class, if it is not going to be in its proper place or used at all. Since its only job is to draw things on screen with the correct effect being applied, a fitting place for it would be inside the Window
class:
class Window{ public: ... Renderer* GetRenderer(); ... private: ... Renderer m_renderer; };
Because outside classes rely on it as well, it is a good idea to provide a getter method for easy retrieval of this object.
Actually integrating it into the rest of the code is surprisingly easy. A good place to start is giving the Renderer
access to the Window
class like so:
Window::Window(...) : m_renderer(this, l_useShaders) { ... }
The renderer also has hooks for knowing when we begin and end the drawing process. Luckily, the Window
class already supports this idea, so it's really easy to tap into it:
void Window::BeginDraw() { ...