Windows system
There's a lot that goes on behind the scenes when it comes to dealing with open windows. Everything from window dimensions and titles to keeping track of and dealing with special events is centralized within a designated window class:
class Window{ public: Â Window(const std::string& l_title = "Window", Â Â Â const sf::Vector2u& l_size = {640,480}, Â Â Â bool l_useShaders = true); Â ~Window(); Â void BeginDraw(); Â void EndDraw(); Â void Update(); Â bool IsDone() const; Â bool IsFullscreen() const; Â bool IsFocused() const; Â void ToggleFullscreen(EventDetails* l_details); Â void Close(EventDetails* l_details = nullptr); Â sf::RenderWindow* GetRenderWindow(); Â Renderer* GetRenderer(); Â EventManager* GetEventManager(); Â sf::Vector2u GetWindowSize(); Â sf::FloatRect GetViewSpace(); private: Â ... };
Note the two highlighted methods. They will be used as call-backs in the event manager we'll discuss in the near future. Also note the return method for an object type Renderer
. It’s a utility class that simply invokes the .draw
call on a RenderWindow
, thus localizing it and making it much easier to use shaders. More information on that will be revealed in Chapter 6, Adding Some Finishing Touches – Using Shaders.