Integrating the GUI system

In order to use the GUI system, it needs to first exist. Just like in previous chapters, we need to instantiate and update the GUI classes we built. Let's start by adding the GUI manager and the font manager to the SharedContext.h file:

struct SharedContext{
  SharedContext():
    ...
    m_fontManager(nullptr),
    ...
    m_guiManager(nullptr){}
     ...
     FontManager* m_fontManager;
  GUI_Manager* m_guiManager;
};

We need to keep a pointer to the GUI manager and the font manager in the Game class, as with all of the other classes that are shared through the SharedContext structure, starting with the header:

class Game{
public:
    ...
private:
    ...
    FontManager m_fontManager;
    ...
    GUI_Manager m_guiManager;
};

These pointers are, of course meaningless, ...

Get SFML Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.