diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2021-04-28 12:48:13 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2021-05-03 19:49:19 +0200 |
commit | 258101a91031f3ff9ee01a974030b02529ffdac0 (patch) | |
tree | f57e2b95910b26a40d15c6b623084b8d93a528a9 /src/client/renderingengine.h | |
parent | 74125a74d34e9b1a003107d4ef6b95b8483d2464 (diff) | |
download | hax-minetest-server-258101a91031f3ff9ee01a974030b02529ffdac0.tar.gz hax-minetest-server-258101a91031f3ff9ee01a974030b02529ffdac0.zip |
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
Diffstat (limited to 'src/client/renderingengine.h')
-rw-r--r-- | src/client/renderingengine.h | 51 |
1 files changed, 15 insertions, 36 deletions
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<core::vector3d<u32>> 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<RenderingCore> core; irr::IrrlichtDevice *m_device = nullptr; |