From 258101a91031f3ff9ee01a974030b02529ffdac0 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 28 Apr 2021 12:48:13 +0200 Subject: refacto: RenderingEngine is now better hidden * No more access to the singleton instance from everywhere (RenderingEngine::get_instance dropped) * RenderingEngine::get_timer_time is now non static * RenderingEngine::draw_menu_scene is now non static * RenderingEngine::draw_scene is now non static * RenderingEngine::{initialize,finalize} are now non static * RenderingEngine::run is now non static * RenderingEngine::getWindowSize now have a static helper. It was mandatory to hide the global get_instance access --- src/client/renderingengine.h | 51 +++++++++++++------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) (limited to 'src/client/renderingengine.h') diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index 73b55229e..5462aa667 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -44,7 +44,6 @@ public: RenderingEngine(IEventReceiver *eventReceiver); ~RenderingEngine(); - v2u32 getWindowSize() const; void setResizable(bool resize); video::IVideoDriver *getVideoDriver() { return driver; } @@ -63,7 +62,11 @@ public: void removeMesh(const irr::scene::IMesh* mesh); - static RenderingEngine *get_instance() { return s_singleton; } + static v2u32 getWindowSize() + { + sanity_check(s_singleton); + return s_singleton->_getWindowSize(); + } io::IFileSystem *get_filesystem() { @@ -88,11 +91,9 @@ public: return s_singleton->m_device; } - static u32 get_timer_time() + u32 get_timer_time() { - sanity_check(s_singleton && s_singleton->m_device && - s_singleton->m_device->getTimer()); - return s_singleton->m_device->getTimer()->getTime(); + return m_device->getTimer()->getTime(); } static gui::IGUIEnvironment *get_gui_env() @@ -109,30 +110,16 @@ public: text, guienv, tsrc, dtime, percent, clouds); } - inline static void draw_menu_scene( - gui::IGUIEnvironment *guienv, float dtime, bool clouds) - { - s_singleton->_draw_menu_scene(guienv, dtime, clouds); - } + void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds); + void draw_scene(video::SColor skycolor, bool show_hud, + bool show_minimap, bool draw_wield_tool, bool draw_crosshair); - inline static void draw_scene(video::SColor skycolor, bool show_hud, - bool show_minimap, bool draw_wield_tool, bool draw_crosshair) - { - s_singleton->_draw_scene(skycolor, show_hud, show_minimap, - draw_wield_tool, draw_crosshair); - } + void initialize(Client *client, Hud *hud); + void finalize(); - inline static void initialize(Client *client, Hud *hud) + bool run() { - s_singleton->_initialize(client, hud); - } - - inline static void finalize() { s_singleton->_finalize(); } - - static bool run() - { - sanity_check(s_singleton && s_singleton->m_device); - return s_singleton->m_device->run(); + return m_device->run(); } static std::vector> getSupportedVideoModes(); @@ -143,15 +130,7 @@ private: ITextureSource *tsrc, float dtime = 0, int percent = 0, bool clouds = true); - void _draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime = 0, - bool clouds = true); - - void _draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap, - bool draw_wield_tool, bool draw_crosshair); - - void _initialize(Client *client, Hud *hud); - - void _finalize(); + v2u32 _getWindowSize() const; std::unique_ptr core; irr::IrrlichtDevice *m_device = nullptr; -- cgit v1.2.3