aboutsummaryrefslogtreecommitdiff
path: root/src/gui/guiEngine.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2021-04-28 12:48:13 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2021-05-03 19:49:19 +0200
commit258101a91031f3ff9ee01a974030b02529ffdac0 (patch)
treef57e2b95910b26a40d15c6b623084b8d93a528a9 /src/gui/guiEngine.cpp
parent74125a74d34e9b1a003107d4ef6b95b8483d2464 (diff)
downloadminetest-258101a91031f3ff9ee01a974030b02529ffdac0.tar.gz
minetest-258101a91031f3ff9ee01a974030b02529ffdac0.tar.bz2
minetest-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/gui/guiEngine.cpp')
-rw-r--r--src/gui/guiEngine.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp
index 93463ad70..0c7b96492 100644
--- a/src/gui/guiEngine.cpp
+++ b/src/gui/guiEngine.cpp
@@ -121,12 +121,14 @@ void MenuMusicFetcher::fetchSounds(const std::string &name,
/******************************************************************************/
GUIEngine::GUIEngine(JoystickController *joystick,
gui::IGUIElement *parent,
+ RenderingEngine *rendering_engine,
IMenuManager *menumgr,
MainMenuData *data,
bool &kill) :
+ m_rendering_engine(rendering_engine),
m_parent(parent),
m_menumanager(menumgr),
- m_smgr(RenderingEngine::get_scene_manager()),
+ m_smgr(rendering_engine->get_scene_manager()),
m_data(data),
m_kill(kill)
{
@@ -138,7 +140,7 @@ GUIEngine::GUIEngine(JoystickController *joystick,
m_buttonhandler = new TextDestGuiEngine(this);
//create texture source
- m_texture_source = new MenuTextureSource(RenderingEngine::get_video_driver());
+ m_texture_source = new MenuTextureSource(rendering_engine->get_video_driver());
//create soundmanager
MenuMusicFetcher soundfetcher;
@@ -156,7 +158,7 @@ GUIEngine::GUIEngine(JoystickController *joystick,
g_fontengine->getTextHeight());
rect += v2s32(4, 0);
- m_irr_toplefttext = gui::StaticText::add(RenderingEngine::get_gui_env(),
+ m_irr_toplefttext = gui::StaticText::add(rendering_engine->get_gui_env(),
m_toplefttext, rect, false, true, 0, -1);
//create formspecsource
@@ -232,7 +234,7 @@ void GUIEngine::run()
{
// Always create clouds because they may or may not be
// needed based on the game selected
- video::IVideoDriver *driver = RenderingEngine::get_video_driver();
+ video::IVideoDriver *driver = m_rendering_engine->get_video_driver();
cloudInit();
@@ -259,10 +261,10 @@ void GUIEngine::run()
fog_pixelfog, fog_rangefog);
}
- while (RenderingEngine::run() && (!m_startgame) && (!m_kill)) {
+ while (m_rendering_engine->run() && (!m_startgame) && (!m_kill)) {
const irr::core::dimension2d<u32> &current_screen_size =
- RenderingEngine::get_video_driver()->getScreenSize();
+ m_rendering_engine->get_video_driver()->getScreenSize();
// Verify if window size has changed and save it if it's the case
// Ensure evaluating settings->getBool after verifying screensize
// First condition is cheaper
@@ -293,11 +295,11 @@ void GUIEngine::run()
drawHeader(driver);
drawFooter(driver);
- RenderingEngine::get_gui_env()->drawAll();
+ m_rendering_engine->get_gui_env()->drawAll();
driver->endScene();
- IrrlichtDevice *device = RenderingEngine::get_raw_device();
+ IrrlichtDevice *device = m_rendering_engine->get_raw_device();
u32 frametime_min = 1000 / (device->isWindowFocused()
? g_settings->getFloat("fps_max")
: g_settings->getFloat("fps_max_unfocused"));
@@ -330,7 +332,7 @@ GUIEngine::~GUIEngine()
//clean up texture pointers
for (image_definition &texture : m_textures) {
if (texture.texture)
- RenderingEngine::get_video_driver()->removeTexture(texture.texture);
+ m_rendering_engine->get_video_driver()->removeTexture(texture.texture);
}
delete m_texture_source;
@@ -350,13 +352,13 @@ void GUIEngine::cloudInit()
v3f(0,0,0), v3f(0, 60, 100));
m_cloud.camera->setFarValue(10000);
- m_cloud.lasttime = RenderingEngine::get_timer_time();
+ m_cloud.lasttime = m_rendering_engine->get_timer_time();
}
/******************************************************************************/
void GUIEngine::cloudPreProcess()
{
- u32 time = RenderingEngine::get_timer_time();
+ u32 time = m_rendering_engine->get_timer_time();
if(time > m_cloud.lasttime)
m_cloud.dtime = (time - m_cloud.lasttime) / 1000.0;
@@ -377,7 +379,7 @@ void GUIEngine::cloudPostProcess(u32 frametime_min, IrrlichtDevice *device)
u32 busytime_u32;
// not using getRealTime is necessary for wine
- u32 time = RenderingEngine::get_timer_time();
+ u32 time = m_rendering_engine->get_timer_time();
if(time > m_cloud.lasttime)
busytime_u32 = time - m_cloud.lasttime;
else
@@ -528,7 +530,7 @@ void GUIEngine::drawFooter(video::IVideoDriver *driver)
bool GUIEngine::setTexture(texture_layer layer, const std::string &texturepath,
bool tile_image, unsigned int minsize)
{
- video::IVideoDriver *driver = RenderingEngine::get_video_driver();
+ video::IVideoDriver *driver = m_rendering_engine->get_video_driver();
if (m_textures[layer].texture) {
driver->removeTexture(m_textures[layer].texture);
@@ -595,7 +597,7 @@ void GUIEngine::updateTopLeftTextSize()
rect += v2s32(4, 0);
m_irr_toplefttext->remove();
- m_irr_toplefttext = gui::StaticText::add(RenderingEngine::get_gui_env(),
+ m_irr_toplefttext = gui::StaticText::add(m_rendering_engine->get_gui_env(),
m_toplefttext, rect, false, true, 0, -1);
}