From 0077982fb78a8ed39a90da03c0898d12583fed64 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 18 Apr 2021 16:07:13 +0200 Subject: GLES fixes (#11205) * Consistently set float precision for GLES * Enable DPI scaling on Windows+GLES --- src/client/renderingengine.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/client/renderingengine.cpp') diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index 4f59bbae3..d2d136a61 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -335,6 +335,10 @@ static bool getWindowHandle(irr::video::IVideoDriver *driver, HWND &hWnd) case video::EDT_DIRECT3D9: hWnd = reinterpret_cast(exposedData.D3D9.HWnd); break; +#if ENABLE_GLES + case video::EDT_OGLES1: + case video::EDT_OGLES2: +#endif case video::EDT_OPENGL: hWnd = reinterpret_cast(exposedData.OpenGLWin32.HWnd); break; -- cgit v1.2.3 From e0716384d6c7abfa228b039056f1e872ca7bb8cf Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 28 Apr 2021 10:53:36 +0200 Subject: refacto: add RenderingEngine::cleanupMeshCache This permits to prevent client to own the mesh cache cleanup logic. It's better in RenderingEngine --- src/client/client.cpp | 7 +------ src/client/renderingengine.cpp | 9 +++++++++ src/client/renderingengine.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/client/renderingengine.cpp') diff --git a/src/client/client.cpp b/src/client/client.cpp index d7e69f349..48097be2e 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -300,12 +300,7 @@ Client::~Client() } // cleanup 3d model meshes on client shutdown - while (RenderingEngine::get_mesh_cache()->getMeshCount() != 0) { - scene::IAnimatedMesh *mesh = RenderingEngine::get_mesh_cache()->getMeshByIndex(0); - - if (mesh) - RenderingEngine::get_mesh_cache()->removeMesh(mesh); - } + m_rendering_engine->cleanupMeshCache(); delete m_minimap; m_minimap = nullptr; diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index d2d136a61..970bcf95b 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -225,6 +225,15 @@ bool RenderingEngine::print_video_modes() return videomode_list != NULL; } +void RenderingEngine::cleanupMeshCache() +{ + auto mesh_cache = m_device->getSceneManager()->getMeshCache(); + while (mesh_cache->getMeshCount() != 0) { + if (scene::IAnimatedMesh *mesh = mesh_cache->getMeshByIndex(0)) + m_rendering_engine->get_mesh_cache()->removeMesh(mesh); + } +} + bool RenderingEngine::setupTopLevelWindow(const std::string &name) { // FIXME: It would make more sense for there to be a switch of some diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index 5807421ef..fae431f1f 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -56,6 +56,7 @@ public: bool setWindowIcon(); bool setXorgWindowIconFromPath(const std::string &icon_file); static bool print_video_modes(); + void cleanupMeshCache(); static RenderingEngine *get_instance() { return s_singleton; } -- cgit v1.2.3 From 74125a74d34e9b1a003107d4ef6b95b8483d2464 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 28 Apr 2021 11:07:28 +0200 Subject: refacto: hide mesh_cache inside the rendering engine This permit cleaner access to meshCache and ensure we don't access to it from all the code --- src/client/client.cpp | 2 +- src/client/game.cpp | 25 +------------------------ src/client/renderingengine.cpp | 7 ++++++- src/client/renderingengine.h | 11 +++++------ 4 files changed, 13 insertions(+), 32 deletions(-) (limited to 'src/client/renderingengine.cpp') diff --git a/src/client/client.cpp b/src/client/client.cpp index 48097be2e..15979df02 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1983,7 +1983,7 @@ scene::IAnimatedMesh* Client::getMesh(const std::string &filename, bool cache) return nullptr; mesh->grab(); if (!cache) - m_rendering_engine->get_mesh_cache()->removeMesh(mesh); + m_rendering_engine->removeMesh(mesh); return mesh; } diff --git a/src/client/game.cpp b/src/client/game.cpp index 612072136..8400d7639 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -652,8 +652,6 @@ public: protected: - void extendedResourceCleanup(); - // Basic initialisation bool init(const std::string &map_dir, const std::string &address, u16 port, const SubgameSpec &gamespec); @@ -968,7 +966,7 @@ Game::~Game() delete itemdef_manager; delete draw_control; - extendedResourceCleanup(); + clearTextureNameCache(); g_settings->deregisterChangedCallback("doubletap_jump", &settingChangedCallback, this); @@ -4063,27 +4061,6 @@ void Game::readSettings() ****************************************************************************/ /****************************************************************************/ -void Game::extendedResourceCleanup() -{ - // Extended resource accounting - infostream << "Irrlicht resources after cleanup:" << std::endl; - infostream << "\tRemaining meshes : " - << RenderingEngine::get_mesh_cache()->getMeshCount() << std::endl; - infostream << "\tRemaining textures : " - << driver->getTextureCount() << std::endl; - - for (unsigned int i = 0; i < driver->getTextureCount(); i++) { - irr::video::ITexture *texture = driver->getTextureByIndex(i); - infostream << "\t\t" << i << ":" << texture->getName().getPath().c_str() - << std::endl; - } - - clearTextureNameCache(); - infostream << "\tRemaining materials: " - << driver-> getMaterialRendererCount() - << " (note: irrlicht doesn't support removing renderers)" << std::endl; -} - void Game::showDeathFormspec() { static std::string formspec_str = diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index 970bcf95b..da9022477 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -225,12 +225,17 @@ bool RenderingEngine::print_video_modes() return videomode_list != NULL; } +void RenderingEngine::removeMesh(const irr::scene::IMesh* mesh) +{ + m_device->getSceneManager()->getMeshCache()->removeMesh(mesh); +} + void RenderingEngine::cleanupMeshCache() { auto mesh_cache = m_device->getSceneManager()->getMeshCache(); while (mesh_cache->getMeshCount() != 0) { if (scene::IAnimatedMesh *mesh = mesh_cache->getMeshByIndex(0)) - m_rendering_engine->get_mesh_cache()->removeMesh(mesh); + mesh_cache->removeMesh(mesh); } } diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index fae431f1f..73b55229e 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -26,6 +26,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_extrabloated.h" #include "debug.h" +namespace irr { namespace scene { +class IMesh; +}} class ITextureSource; class Camera; class Client; @@ -58,6 +61,8 @@ public: static bool print_video_modes(); void cleanupMeshCache(); + void removeMesh(const irr::scene::IMesh* mesh); + static RenderingEngine *get_instance() { return s_singleton; } io::IFileSystem *get_filesystem() @@ -71,12 +76,6 @@ public: return s_singleton->m_device->getVideoDriver(); } - static scene::IMeshCache *get_mesh_cache() - { - sanity_check(s_singleton && s_singleton->m_device); - return s_singleton->m_device->getSceneManager()->getMeshCache(); - } - static scene::ISceneManager *get_scene_manager() { sanity_check(s_singleton && s_singleton->m_device); -- cgit v1.2.3 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/camera.cpp | 2 +- src/client/clientlauncher.cpp | 57 ++++++++++++++++++++------------------- src/client/clientlauncher.h | 1 + src/client/game.cpp | 54 ++++++++++++++++++++----------------- src/client/game.h | 4 ++- src/client/gameui.cpp | 6 ++--- src/client/hud.cpp | 6 ++--- src/client/minimap.cpp | 2 +- src/client/renderingengine.cpp | 12 ++++----- src/client/renderingengine.h | 51 +++++++++++------------------------ src/gui/guiEngine.cpp | 30 +++++++++++---------- src/gui/guiEngine.h | 3 +++ src/main.cpp | 3 +-- src/script/lua_api/l_mainmenu.cpp | 2 +- 14 files changed, 112 insertions(+), 121 deletions(-) (limited to 'src/client/renderingengine.cpp') diff --git a/src/client/camera.cpp b/src/client/camera.cpp index 5158d0dd1..f6892295b 100644 --- a/src/client/camera.cpp +++ b/src/client/camera.cpp @@ -541,7 +541,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r m_curr_fov_degrees = rangelim(m_curr_fov_degrees, 1.0f, 160.0f); // FOV and aspect ratio - const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + const v2u32 &window_size = RenderingEngine::getWindowSize(); m_aspect = (f32) window_size.X / (f32) window_size.Y; m_fov_y = m_curr_fov_degrees * M_PI / 180.0; // Increase vertical FOV on lower aspect ratios (<16:10) diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index b1b801947..6db5f2e70 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -80,7 +80,7 @@ ClientLauncher::~ClientLauncher() delete g_fontengine; delete g_gamecallback; - delete RenderingEngine::get_instance(); + delete m_rendering_engine; #if USE_SOUND g_sound_manager_singleton.reset(); @@ -101,7 +101,7 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) // List video modes if requested if (list_video_modes) - return RenderingEngine::print_video_modes(); + return m_rendering_engine->print_video_modes(); #if USE_SOUND if (g_settings->getBool("enable_sound")) @@ -120,12 +120,12 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) return true; } - if (RenderingEngine::get_video_driver() == NULL) { + if (m_rendering_engine->get_video_driver() == NULL) { errorstream << "Could not initialize video driver." << std::endl; return false; } - RenderingEngine::get_instance()->setupTopLevelWindow(PROJECT_NAME_C); + m_rendering_engine->setupTopLevelWindow(PROJECT_NAME_C); /* This changes the minimum allowed number of vertices in a VBO. @@ -136,15 +136,15 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) // Create game callback for menus g_gamecallback = new MainGameCallback(); - RenderingEngine::get_instance()->setResizable(true); + m_rendering_engine->setResizable(true); init_input(); - RenderingEngine::get_scene_manager()->getParameters()-> + m_rendering_engine->get_scene_manager()->getParameters()-> setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); - guienv = RenderingEngine::get_gui_env(); - skin = RenderingEngine::get_gui_env()->getSkin(); + guienv = m_rendering_engine->get_gui_env(); + skin = guienv->getSkin(); skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255)); skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0)); skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 30, 30, 30)); @@ -166,7 +166,7 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) sprite_path.append("checkbox_16.png"); // Texture dimensions should be a power of 2 gui::IGUISpriteBank *sprites = skin->getSpriteBank(); - video::IVideoDriver *driver = RenderingEngine::get_video_driver(); + video::IVideoDriver *driver = m_rendering_engine->get_video_driver(); video::ITexture *sprite_texture = driver->getTexture(sprite_path.c_str()); if (sprite_texture) { s32 sprite_id = sprites->addTextureAsSprite(sprite_texture); @@ -184,7 +184,7 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) // Create the menu clouds if (!g_menucloudsmgr) - g_menucloudsmgr = RenderingEngine::get_scene_manager()->createNewSceneManager(); + g_menucloudsmgr = m_rendering_engine->get_scene_manager()->createNewSceneManager(); if (!g_menuclouds) g_menuclouds = new Clouds(g_menucloudsmgr, -1, rand()); g_menuclouds->setHeight(100.0f); @@ -212,11 +212,11 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) bool retval = true; bool *kill = porting::signal_handler_killstatus(); - while (RenderingEngine::run() && !*kill && + while (m_rendering_engine->run() && !*kill && !g_gamecallback->shutdown_requested) { // Set the window caption const wchar_t *text = wgettext("Main Menu"); - RenderingEngine::get_raw_device()-> + m_rendering_engine->get_raw_device()-> setWindowCaption((utf8_to_wide(PROJECT_NAME_C) + L" " + utf8_to_wide(g_version_hash) + L" [" + text + L"]").c_str()); @@ -224,14 +224,14 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) try { // This is used for catching disconnects - RenderingEngine::get_gui_env()->clear(); + m_rendering_engine->get_gui_env()->clear(); /* We need some kind of a root node to be able to add custom gui elements directly on the screen. Otherwise they won't be automatically drawn. */ - guiroot = RenderingEngine::get_gui_env()->addStaticText(L"", + guiroot = m_rendering_engine->get_gui_env()->addStaticText(L"", core::rect(0, 0, 10000, 10000)); bool game_has_run = launch_game(error_message, reconnect_requested, @@ -254,29 +254,30 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args) } // Break out of menu-game loop to shut down cleanly - if (!RenderingEngine::get_raw_device()->run() || *kill) { + if (!m_rendering_engine->run() || *kill) { if (!g_settings_path.empty()) g_settings->updateConfigFile(g_settings_path.c_str()); break; } - RenderingEngine::get_video_driver()->setTextureCreationFlag( + m_rendering_engine->get_video_driver()->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map")); #ifdef HAVE_TOUCHSCREENGUI - receiver->m_touchscreengui = new TouchScreenGUI(RenderingEngine::get_raw_device(), receiver); + receiver->m_touchscreengui = new TouchScreenGUI(m_rendering_engine->get_raw_device(), receiver); g_touchscreengui = receiver->m_touchscreengui; #endif the_game( kill, input, + m_rendering_engine, start_data, error_message, chat_backend, &reconnect_requested ); - RenderingEngine::get_scene_manager()->clear(); + m_rendering_engine->get_scene_manager()->clear(); #ifdef HAVE_TOUCHSCREENGUI delete g_touchscreengui; @@ -344,8 +345,8 @@ void ClientLauncher::init_args(GameStartData &start_data, const Settings &cmd_ar bool ClientLauncher::init_engine() { receiver = new MyEventReceiver(); - new RenderingEngine(receiver); - return RenderingEngine::get_raw_device() != nullptr; + m_rendering_engine = new RenderingEngine(receiver); + return m_rendering_engine->get_raw_device() != nullptr; } void ClientLauncher::init_input() @@ -362,7 +363,7 @@ void ClientLauncher::init_input() // Make sure this is called maximum once per // irrlicht device, otherwise it will give you // multiple events for the same joystick. - if (RenderingEngine::get_raw_device()->activateJoysticks(infos)) { + if (m_rendering_engine->get_raw_device()->activateJoysticks(infos)) { infostream << "Joystick support enabled" << std::endl; joystick_infos.reserve(infos.size()); for (u32 i = 0; i < infos.size(); i++) { @@ -469,7 +470,7 @@ bool ClientLauncher::launch_game(std::string &error_message, start_data.address.empty() && !start_data.name.empty(); } - if (!RenderingEngine::run()) + if (!m_rendering_engine->run()) return false; if (!start_data.isSinglePlayer() && start_data.name.empty()) { @@ -541,14 +542,14 @@ bool ClientLauncher::launch_game(std::string &error_message, void ClientLauncher::main_menu(MainMenuData *menudata) { bool *kill = porting::signal_handler_killstatus(); - video::IVideoDriver *driver = RenderingEngine::get_video_driver(); + video::IVideoDriver *driver = m_rendering_engine->get_video_driver(); infostream << "Waiting for other menus" << std::endl; - while (RenderingEngine::get_raw_device()->run() && !*kill) { + while (m_rendering_engine->run() && !*kill) { if (!isMenuActive()) break; driver->beginScene(true, true, video::SColor(255, 128, 128, 128)); - RenderingEngine::get_gui_env()->drawAll(); + m_rendering_engine->get_gui_env()->drawAll(); driver->endScene(); // On some computers framerate doesn't seem to be automatically limited sleep_ms(25); @@ -557,14 +558,14 @@ void ClientLauncher::main_menu(MainMenuData *menudata) // Cursor can be non-visible when coming from the game #ifndef ANDROID - RenderingEngine::get_raw_device()->getCursorControl()->setVisible(true); + m_rendering_engine->get_raw_device()->getCursorControl()->setVisible(true); #endif /* show main menu */ - GUIEngine mymenu(&input->joystick, guiroot, &g_menumgr, menudata, *kill); + GUIEngine mymenu(&input->joystick, guiroot, m_rendering_engine, &g_menumgr, menudata, *kill); /* leave scene manager in a clean state */ - RenderingEngine::get_scene_manager()->clear(); + m_rendering_engine->get_scene_manager()->clear(); } void ClientLauncher::speed_tests() diff --git a/src/client/clientlauncher.h b/src/client/clientlauncher.h index b280d8e6b..79727e1fe 100644 --- a/src/client/clientlauncher.h +++ b/src/client/clientlauncher.h @@ -49,6 +49,7 @@ private: bool list_video_modes = false; bool skip_main_menu = false; bool random_input = false; + RenderingEngine *m_rendering_engine = nullptr; InputHandler *input = nullptr; MyEventReceiver *receiver = nullptr; gui::IGUISkin *skin = nullptr; diff --git a/src/client/game.cpp b/src/client/game.cpp index 8400d7639..33707df4a 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -642,6 +642,7 @@ public: bool startup(bool *kill, InputHandler *input, + RenderingEngine *rendering_engine, const GameStartData &game_params, std::string &error_message, bool *reconnect, @@ -853,6 +854,7 @@ private: these items (e.g. device) */ IrrlichtDevice *device; + RenderingEngine *m_rendering_engine; video::IVideoDriver *driver; scene::ISceneManager *smgr; bool *kill; @@ -994,6 +996,7 @@ Game::~Game() bool Game::startup(bool *kill, InputHandler *input, + RenderingEngine *rendering_engine, const GameStartData &start_data, std::string &error_message, bool *reconnect, @@ -1001,21 +1004,21 @@ bool Game::startup(bool *kill, { // "cache" - this->device = RenderingEngine::get_raw_device(); + m_rendering_engine = rendering_engine; + device = m_rendering_engine->get_raw_device(); this->kill = kill; this->error_message = &error_message; - this->reconnect_requested = reconnect; + reconnect_requested = reconnect; this->input = input; this->chat_backend = chat_backend; - this->simple_singleplayer_mode = start_data.isSinglePlayer(); + simple_singleplayer_mode = start_data.isSinglePlayer(); input->keycache.populate(); driver = device->getVideoDriver(); - smgr = RenderingEngine::get_scene_manager(); + smgr = m_rendering_engine->get_scene_manager(); - RenderingEngine::get_scene_manager()->getParameters()-> - setAttribute(scene::OBJ_LOADER_IGNORE_MATERIAL_FILES, true); + smgr->getParameters()->setAttribute(scene::OBJ_LOADER_IGNORE_MATERIAL_FILES, true); // Reinit runData runData = GameRunData(); @@ -1036,7 +1039,7 @@ bool Game::startup(bool *kill, if (!createClient(start_data)) return false; - RenderingEngine::initialize(client, hud); + m_rendering_engine->initialize(client, hud); return true; } @@ -1055,7 +1058,7 @@ void Game::run() Profiler::GraphValues dummyvalues; g_profiler->graphGet(dummyvalues); - draw_times.last_time = RenderingEngine::get_timer_time(); + draw_times.last_time = m_rendering_engine->get_timer_time(); set_light_table(g_settings->getFloat("display_gamma")); @@ -1067,12 +1070,12 @@ void Game::run() irr::core::dimension2d previous_screen_size(g_settings->getU16("screen_w"), g_settings->getU16("screen_h")); - while (RenderingEngine::run() + while (m_rendering_engine->run() && !(*kill || g_gamecallback->shutdown_requested || (server && server->isShutdownRequested()))) { const irr::core::dimension2d ¤t_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 @@ -1085,7 +1088,7 @@ void Game::run() } // Calculate dtime = - // RenderingEngine::run() from this iteration + // m_rendering_engine->run() from this iteration // + Sleep time until the wanted FPS are reached limitFps(&draw_times, &dtime); @@ -1134,7 +1137,7 @@ void Game::run() void Game::shutdown() { - RenderingEngine::finalize(); + m_rendering_engine->finalize(); #if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8 if (g_settings->get("3d_mode") == "pageflip") { driver->setRenderTarget(irr::video::ERT_STEREO_BOTH_BUFFERS); @@ -1463,7 +1466,7 @@ bool Game::connectToServer(const GameStartData &start_data, start_data.password, start_data.address, *draw_control, texture_src, shader_src, itemdef_manager, nodedef_manager, sound, eventmgr, - RenderingEngine::get_instance(), connect_address.isIPv6(), m_game_ui.get()); + m_rendering_engine, connect_address.isIPv6(), m_game_ui.get()); client->m_simple_singleplayer_mode = simple_singleplayer_mode; @@ -1485,9 +1488,9 @@ bool Game::connectToServer(const GameStartData &start_data, f32 dtime; f32 wait_time = 0; // in seconds - fps_control.last_time = RenderingEngine::get_timer_time(); + fps_control.last_time = m_rendering_engine->get_timer_time(); - while (RenderingEngine::run()) { + while (m_rendering_engine->run()) { limitFps(&fps_control, &dtime); @@ -1524,7 +1527,7 @@ bool Game::connectToServer(const GameStartData &start_data, if (client->m_is_registration_confirmation_state) { if (registration_confirmation_shown) { // Keep drawing the GUI - RenderingEngine::draw_menu_scene(guienv, dtime, true); + m_rendering_engine->draw_menu_scene(guienv, dtime, true); } else { registration_confirmation_shown = true; (new GUIConfirmRegistration(guienv, guienv->getRootGUIElement(), -1, @@ -1560,9 +1563,9 @@ bool Game::getServerContent(bool *aborted) FpsControl fps_control = { 0 }; f32 dtime; // in seconds - fps_control.last_time = RenderingEngine::get_timer_time(); + fps_control.last_time = m_rendering_engine->get_timer_time(); - while (RenderingEngine::run()) { + while (m_rendering_engine->run()) { limitFps(&fps_control, &dtime); @@ -1600,13 +1603,13 @@ bool Game::getServerContent(bool *aborted) if (!client->itemdefReceived()) { const wchar_t *text = wgettext("Item definitions..."); progress = 25; - RenderingEngine::draw_load_screen(text, guienv, texture_src, + m_rendering_engine->draw_load_screen(text, guienv, texture_src, dtime, progress); delete[] text; } else if (!client->nodedefReceived()) { const wchar_t *text = wgettext("Node definitions..."); progress = 30; - RenderingEngine::draw_load_screen(text, guienv, texture_src, + m_rendering_engine->draw_load_screen(text, guienv, texture_src, dtime, progress); delete[] text; } else { @@ -1633,7 +1636,7 @@ bool Game::getServerContent(bool *aborted) } progress = 30 + client->mediaReceiveProgress() * 35 + 0.5; - RenderingEngine::draw_load_screen(utf8_to_wide(message.str()), guienv, + m_rendering_engine->draw_load_screen(utf8_to_wide(message.str()), guienv, texture_src, dtime, progress); } } @@ -3886,7 +3889,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, } catch (SettingNotFoundException) { } #endif - RenderingEngine::draw_scene(skycolor, m_game_ui->m_flags.show_hud, + m_rendering_engine->draw_scene(skycolor, m_game_ui->m_flags.show_hud, m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair); /* @@ -4016,7 +4019,7 @@ inline void Game::limitFps(FpsControl *fps_timings, f32 *dtime) void Game::showOverlayMessage(const char *msg, float dtime, int percent, bool draw_clouds) { const wchar_t *wmsg = wgettext(msg); - RenderingEngine::draw_load_screen(wmsg, guienv, texture_src, dtime, percent, + m_rendering_engine->draw_load_screen(wmsg, guienv, texture_src, dtime, percent, draw_clouds); delete[] wmsg; } @@ -4229,6 +4232,7 @@ void Game::showPauseMenu() void the_game(bool *kill, InputHandler *input, + RenderingEngine *rendering_engine, const GameStartData &start_data, std::string &error_message, ChatBackend &chat_backend, @@ -4243,8 +4247,8 @@ void the_game(bool *kill, try { - if (game.startup(kill, input, start_data, error_message, - reconnect_requested, &chat_backend)) { + if (game.startup(kill, input, rendering_engine, start_data, + error_message, reconnect_requested, &chat_backend)) { game.run(); } diff --git a/src/client/game.h b/src/client/game.h index d04153271..fbbf106db 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -23,7 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include class InputHandler; -class ChatBackend; /* to avoid having to include chat.h */ +class ChatBackend; +class RenderingEngine; struct SubgameSpec; struct GameStartData; @@ -45,6 +46,7 @@ struct CameraOrientation { void the_game(bool *kill, InputHandler *input, + RenderingEngine *rendering_engine, const GameStartData &start_data, std::string &error_message, ChatBackend &chat_backend, diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp index 0c08efeb5..ebc6b108c 100644 --- a/src/client/gameui.cpp +++ b/src/client/gameui.cpp @@ -97,7 +97,7 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ const CameraOrientation &cam, const PointedThing &pointed_old, const GUIChatConsole *chat_console, float dtime) { - v2u32 screensize = RenderingEngine::get_instance()->getWindowSize(); + v2u32 screensize = RenderingEngine::getWindowSize(); if (m_flags.show_debug) { static float drawtime_avg = 0; @@ -228,7 +228,7 @@ void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count) if (m_flags.show_debug) chat_y += 2 * g_fontengine->getLineHeight(); - const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + const v2u32 &window_size = RenderingEngine::getWindowSize(); core::rect chat_size(10, chat_y, window_size.X - 20, 0); @@ -260,7 +260,7 @@ void GameUI::updateProfiler() core::position2di upper_left(6, 50); core::position2di lower_right = upper_left; lower_right.X += size.Width + 10; - lower_right.Y += size.Height; + lower_right.Y += size.Height; m_guitext_profiler->setRelativePosition(core::rect(upper_left, lower_right)); } diff --git a/src/client/hud.cpp b/src/client/hud.cpp index c58c7e822..ceea96832 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -747,7 +747,7 @@ void Hud::drawHotbar(u16 playeritem) { s32 width = hotbar_itemcount * (m_hotbar_imagesize + m_padding * 2); v2s32 pos = centerlowerpos - v2s32(width / 2, m_hotbar_imagesize + m_padding * 3); - const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + const v2u32 &window_size = RenderingEngine::getWindowSize(); if ((float) width / (float) window_size.X <= g_settings->getFloat("hud_hotbar_max_width")) { if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) { @@ -874,7 +874,7 @@ void Hud::toggleBlockBounds() void Hud::drawBlockBounds() { if (m_block_bounds_mode == BLOCK_BOUNDS_OFF) { - return; + return; } video::SMaterial old_material = driver->getMaterial2D(); @@ -956,7 +956,7 @@ void Hud::updateSelectionMesh(const v3s16 &camera_offset) } void Hud::resizeHotbar() { - const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + const v2u32 &window_size = RenderingEngine::getWindowSize(); if (m_screensize != window_size) { m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 97977c366..f26aa1c70 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -577,7 +577,7 @@ scene::SMeshBuffer *Minimap::getMinimapMeshBuffer() void Minimap::drawMinimap() { // Non hud managed minimap drawing (legacy minimap) - v2u32 screensize = RenderingEngine::get_instance()->getWindowSize(); + v2u32 screensize = RenderingEngine::getWindowSize(); const u32 size = 0.25 * screensize.Y; drawMinimap(core::rect( diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index da9022477..ec8f47576 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -159,7 +159,7 @@ RenderingEngine::~RenderingEngine() s_singleton = nullptr; } -v2u32 RenderingEngine::getWindowSize() const +v2u32 RenderingEngine::_getWindowSize() const { if (core) return core->getVirtualSize(); @@ -497,7 +497,7 @@ void RenderingEngine::_draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime, int percent, bool clouds) { - v2u32 screensize = RenderingEngine::get_instance()->getWindowSize(); + v2u32 screensize = getWindowSize(); v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight()); v2s32 center(screensize.X / 2, screensize.Y / 2); @@ -565,7 +565,7 @@ void RenderingEngine::_draw_load_screen(const std::wstring &text, /* Draws the menu scene including (optional) cloud background. */ -void RenderingEngine::_draw_menu_scene(gui::IGUIEnvironment *guienv, +void RenderingEngine::draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds) { bool cloud_menu_background = clouds && g_settings->getBool("menu_clouds"); @@ -613,19 +613,19 @@ std::vector RenderingEngine::getSupportedVideoDrivers return drivers; } -void RenderingEngine::_initialize(Client *client, Hud *hud) +void RenderingEngine::initialize(Client *client, Hud *hud) { const std::string &draw_mode = g_settings->get("3d_mode"); core.reset(createRenderingCore(draw_mode, m_device, client, hud)); core->initialize(); } -void RenderingEngine::_finalize() +void RenderingEngine::finalize() { core.reset(); } -void RenderingEngine::_draw_scene(video::SColor skycolor, bool show_hud, +void RenderingEngine::draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap, bool draw_wield_tool, bool draw_crosshair) { core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair); 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; 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 ¤t_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); } diff --git a/src/gui/guiEngine.h b/src/gui/guiEngine.h index eef1ad8aa..70abce181 100644 --- a/src/gui/guiEngine.h +++ b/src/gui/guiEngine.h @@ -50,6 +50,7 @@ struct image_definition { /* forward declarations */ /******************************************************************************/ class GUIEngine; +class RenderingEngine; class MainMenuScripting; class Clouds; struct MainMenuData; @@ -150,6 +151,7 @@ public: */ GUIEngine(JoystickController *joystick, gui::IGUIElement *parent, + RenderingEngine *rendering_engine, IMenuManager *menumgr, MainMenuData *data, bool &kill); @@ -188,6 +190,7 @@ private: /** update size of topleftext element */ void updateTopLeftTextSize(); + RenderingEngine *m_rendering_engine = nullptr; /** parent gui element */ gui::IGUIElement *m_parent = nullptr; /** manager to add menus to */ diff --git a/src/main.cpp b/src/main.cpp index 39b441d2c..7f96836b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -225,8 +225,7 @@ int main(int argc, char *argv[]) return run_dedicated_server(game_params, cmd_args) ? 0 : 1; #ifndef SERVER - ClientLauncher launcher; - retval = launcher.run(game_params, cmd_args) ? 0 : 1; + retval = ClientLauncher().run(game_params, cmd_args) ? 0 : 1; #else retval = 0; #endif diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 1e8dea909..a5bb5f261 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -790,7 +790,7 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L) lua_pushnumber(L,RenderingEngine::getDisplayDensity()); lua_settable(L, top); - const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + const v2u32 &window_size = RenderingEngine::getWindowSize(); lua_pushstring(L,"window_width"); lua_pushnumber(L, window_size.X); lua_settable(L, top); -- cgit v1.2.3 From 48d5abd5bee7a3f956cb2b92745bed6313cf5d8a Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Thu, 29 Apr 2021 20:38:35 +0200 Subject: refacto: remove get_gui_env & draw_load_screen from RenderingEngine singleton --- src/client/client.cpp | 6 +++--- src/client/client.h | 1 + src/client/game.cpp | 24 ++++++++++++------------ src/client/renderingengine.cpp | 2 +- src/client/renderingengine.h | 17 ++++------------- src/gui/guiEngine.cpp | 1 + src/gui/guiFormSpecMenu.cpp | 12 ++++++------ src/gui/guiFormSpecMenu.h | 6 ++++-- src/nodedef.cpp | 6 ++---- src/nodedef.h | 4 +--- src/script/lua_api/l_mainmenu.cpp | 5 +++-- 11 files changed, 38 insertions(+), 46 deletions(-) (limited to 'src/client/renderingengine.cpp') diff --git a/src/client/client.cpp b/src/client/client.cpp index 1a3a81378..c7aae1644 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1731,7 +1731,7 @@ typedef struct TextureUpdateArgs { ITextureSource *tsrc; } TextureUpdateArgs; -void texture_update_progress(void *args, u32 progress, u32 max_progress) +void Client::showUpdateProgressTexture(void *args, u32 progress, u32 max_progress) { TextureUpdateArgs* targs = (TextureUpdateArgs*) args; u16 cur_percent = ceil(progress / (double) max_progress * 100.); @@ -1750,7 +1750,7 @@ void texture_update_progress(void *args, u32 progress, u32 max_progress) targs->last_time_ms = time_ms; std::basic_stringstream strm; strm << targs->text_base << " " << targs->last_percent << "%..."; - RenderingEngine::draw_load_screen(strm.str(), targs->guienv, targs->tsrc, 0, + m_rendering_engine->draw_load_screen(strm.str(), targs->guienv, targs->tsrc, 0, 72 + (u16) ((18. / 100.) * (double) targs->last_percent), true); } } @@ -1804,7 +1804,7 @@ void Client::afterContentReceived() tu_args.last_percent = 0; tu_args.text_base = wgettext("Initializing nodes"); tu_args.tsrc = m_tsrc; - m_nodedef->updateTextures(this, texture_update_progress, &tu_args); + m_nodedef->updateTextures(this, &tu_args); delete[] tu_args.text_base; // Start mesh update thread after setting up content definitions diff --git a/src/client/client.h b/src/client/client.h index be5970160..b819d4301 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -347,6 +347,7 @@ public: float mediaReceiveProgress(); void afterContentReceived(); + void showUpdateProgressTexture(void *args, u32 progress, u32 max_progress); float getRTT(); float getCurRate(); diff --git a/src/client/game.cpp b/src/client/game.cpp index 81508f5f4..2f0f50505 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2047,8 +2047,8 @@ void Game::openInventory() || !client->getScript()->on_inventory_open(fs_src->m_client->getInventory(inventoryloc))) { TextDest *txt_dst = new TextDestPlayerInventory(client); auto *&formspec = m_game_ui->updateFormspec(""); - GUIFormSpecMenu::create(formspec, client, &input->joystick, fs_src, - txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFormSpec(fs_src->getForm(), inventoryloc); } @@ -2626,8 +2626,8 @@ void Game::handleClientEvent_ShowFormSpec(ClientEvent *event, CameraOrientation new TextDestPlayerInventory(client, *(event->show_formspec.formname)); auto *&formspec = m_game_ui->updateFormspec(*(event->show_formspec.formname)); - GUIFormSpecMenu::create(formspec, client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); } delete event->show_formspec.formspec; @@ -2639,8 +2639,8 @@ void Game::handleClientEvent_ShowLocalFormSpec(ClientEvent *event, CameraOrienta FormspecFormSource *fs_src = new FormspecFormSource(*event->show_formspec.formspec); LocalFormspecHandler *txt_dst = new LocalFormspecHandler(*event->show_formspec.formname, client); - GUIFormSpecMenu::create(m_game_ui->getFormspecGUI(), client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(m_game_ui->getFormspecGUI(), client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); delete event->show_formspec.formspec; delete event->show_formspec.formname; @@ -3332,8 +3332,8 @@ bool Game::nodePlacement(const ItemDefinition &selected_def, TextDest *txt_dst = new TextDestNodeMetadata(nodepos, client); auto *&formspec = m_game_ui->updateFormspec(""); - GUIFormSpecMenu::create(formspec, client, &input->joystick, fs_src, - txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFormSpec(meta->getString("formspec"), inventoryloc); return false; @@ -4082,8 +4082,8 @@ void Game::showDeathFormspec() LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", client); auto *&formspec = m_game_ui->getFormspecGUI(); - GUIFormSpecMenu::create(formspec, client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFocus("btn_respawn"); } @@ -4216,8 +4216,8 @@ void Game::showPauseMenu() LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_PAUSE_MENU"); auto *&formspec = m_game_ui->getFormspecGUI(); - GUIFormSpecMenu::create(formspec, client, &input->joystick, - fs_src, txt_dst, client->getFormspecPrepend(), sound); + GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(), + &input->joystick, fs_src, txt_dst, client->getFormspecPrepend(), sound); formspec->setFocus("btn_continue"); formspec->doPause = true; diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index ec8f47576..e74446aeb 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -493,7 +493,7 @@ bool RenderingEngine::setXorgWindowIconFromPath(const std::string &icon_file) Text will be removed when the screen is drawn the next time. Additionally, a progressbar can be drawn when percent is set between 0 and 100. */ -void RenderingEngine::_draw_load_screen(const std::wstring &text, +void RenderingEngine::draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime, int percent, bool clouds) { diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index 4d06baa23..1fd85f5ef 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -95,19 +95,14 @@ public: return m_device->getTimer()->getTime(); } - static gui::IGUIEnvironment *get_gui_env() + gui::IGUIEnvironment *get_gui_env() { - sanity_check(s_singleton && s_singleton->m_device); - return s_singleton->m_device->getGUIEnvironment(); + return m_device->getGUIEnvironment(); } - inline static void draw_load_screen(const std::wstring &text, + void draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, - float dtime = 0, int percent = 0, bool clouds = true) - { - s_singleton->_draw_load_screen( - text, guienv, tsrc, dtime, percent, clouds); - } + float dtime = 0, int percent = 0, bool clouds = true); void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds); void draw_scene(video::SColor skycolor, bool show_hud, @@ -125,10 +120,6 @@ public: static std::vector getSupportedVideoDrivers(); private: - void _draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, - ITextureSource *tsrc, float dtime = 0, int percent = 0, - bool clouds = true); - v2u32 _getWindowSize() const; std::unique_ptr core; diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp index 0c7b96492..694baf482 100644 --- a/src/gui/guiEngine.cpp +++ b/src/gui/guiEngine.cpp @@ -170,6 +170,7 @@ GUIEngine::GUIEngine(JoystickController *joystick, -1, m_menumanager, NULL /* &client */, + m_rendering_engine->get_gui_env(), m_texture_source, m_sound_manager, m_formspecgui, diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index fdcf27a0a..c6435804f 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -96,10 +96,10 @@ inline u32 clamp_u8(s32 value) GUIFormSpecMenu::GUIFormSpecMenu(JoystickController *joystick, gui::IGUIElement *parent, s32 id, IMenuManager *menumgr, - Client *client, ISimpleTextureSource *tsrc, ISoundManager *sound_manager, - IFormSource *fsrc, TextDest *tdst, + Client *client, gui::IGUIEnvironment *guienv, ISimpleTextureSource *tsrc, + ISoundManager *sound_manager, IFormSource *fsrc, TextDest *tdst, const std::string &formspecPrepend, bool remap_dbl_click): - GUIModalMenu(RenderingEngine::get_gui_env(), parent, id, menumgr, remap_dbl_click), + GUIModalMenu(guienv, parent, id, menumgr, remap_dbl_click), m_invmgr(client), m_tsrc(tsrc), m_sound_manager(sound_manager), @@ -145,12 +145,12 @@ GUIFormSpecMenu::~GUIFormSpecMenu() } void GUIFormSpecMenu::create(GUIFormSpecMenu *&cur_formspec, Client *client, - JoystickController *joystick, IFormSource *fs_src, TextDest *txt_dest, - const std::string &formspecPrepend, ISoundManager *sound_manager) + gui::IGUIEnvironment *guienv, JoystickController *joystick, IFormSource *fs_src, + TextDest *txt_dest, const std::string &formspecPrepend, ISoundManager *sound_manager) { if (cur_formspec == nullptr) { cur_formspec = new GUIFormSpecMenu(joystick, guiroot, -1, &g_menumgr, - client, client->getTextureSource(), sound_manager, fs_src, + client, guienv, client->getTextureSource(), sound_manager, fs_src, txt_dest, formspecPrepend); cur_formspec->doPause = false; diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index d658aba7b..926de66d5 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -152,6 +152,7 @@ public: gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, Client *client, + gui::IGUIEnvironment *guienv, ISimpleTextureSource *tsrc, ISoundManager *sound_manager, IFormSource* fs_src, @@ -162,8 +163,9 @@ public: ~GUIFormSpecMenu(); static void create(GUIFormSpecMenu *&cur_formspec, Client *client, - JoystickController *joystick, IFormSource *fs_src, TextDest *txt_dest, - const std::string &formspecPrepend, ISoundManager *sound_manager); + gui::IGUIEnvironment *guienv, JoystickController *joystick, IFormSource *fs_src, + TextDest *txt_dest, const std::string &formspecPrepend, + ISoundManager *sound_manager); void setFormSpec(const std::string &formspec_string, const InventoryLocation ¤t_inventory_location) diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 65a76bcec..db4043aa1 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -1435,9 +1435,7 @@ void NodeDefManager::applyTextureOverrides(const std::vector &o } } -void NodeDefManager::updateTextures(IGameDef *gamedef, - void (*progress_callback)(void *progress_args, u32 progress, u32 max_progress), - void *progress_callback_args) +void NodeDefManager::updateTextures(IGameDef *gamedef, void *progress_callback_args) { #ifndef SERVER infostream << "NodeDefManager::updateTextures(): Updating " @@ -1456,7 +1454,7 @@ void NodeDefManager::updateTextures(IGameDef *gamedef, for (u32 i = 0; i < size; i++) { ContentFeatures *f = &(m_content_features[i]); f->updateTextures(tsrc, shdsrc, meshmanip, client, tsettings); - progress_callback(progress_callback_args, i, size); + client->showUpdateProgressTexture(progress_callback_args, i, size); } #endif } diff --git a/src/nodedef.h b/src/nodedef.h index 0de4dbc21..8a6d88071 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -660,9 +660,7 @@ public: * total ContentFeatures. * @param progress_cbk_args passed to the callback function */ - void updateTextures(IGameDef *gamedef, - void (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress), - void *progress_cbk_args); + void updateTextures(IGameDef *gamedef, void *progress_cbk_args); /*! * Writes the content of this manager to the given output stream. diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index a5bb5f261..b13398539 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -397,7 +397,8 @@ int ModApiMainMenu::l_show_keys_menu(lua_State *L) GUIEngine* engine = getGuiEngine(L); sanity_check(engine != NULL); - GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(RenderingEngine::get_gui_env(), + GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu( + engine->m_rendering_engine->get_gui_env(), engine->m_parent, -1, engine->m_menumanager, @@ -694,7 +695,7 @@ int ModApiMainMenu::l_show_path_select_dialog(lua_State *L) bool is_file_select = readParam(L, 3); GUIFileSelectMenu* fileOpenMenu = - new GUIFileSelectMenu(RenderingEngine::get_gui_env(), + new GUIFileSelectMenu(engine->m_rendering_engine->get_gui_env(), engine->m_parent, -1, engine->m_menumanager, -- cgit v1.2.3 From de85bc9227ef0db01854fa0eef89256646b4d578 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Mon, 3 May 2021 10:27:00 +0200 Subject: fix: some code tidy about includes & irr namespaces --- src/client/client.cpp | 2 +- src/client/client.h | 2 +- src/client/clientobject.h | 6 +-- src/client/clouds.cpp | 2 +- src/client/clouds.h | 3 +- src/client/content_cao.cpp | 14 +++--- src/client/content_cao.h | 2 +- src/client/content_mapblock.cpp | 2 +- src/client/content_mapblock.h | 2 +- src/client/game.cpp | 78 ++++++++++++++--------------- src/client/renderingengine.cpp | 2 +- src/client/renderingengine.h | 5 +- src/script/common/c_content.h | 2 + src/unittest/test_clientactiveobjectmgr.cpp | 2 +- 14 files changed, 59 insertions(+), 65 deletions(-) (limited to 'src/client/renderingengine.cpp') diff --git a/src/client/client.cpp b/src/client/client.cpp index c7aae1644..c0da27e44 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1475,7 +1475,7 @@ bool Client::updateWieldedItem() return true; } -irr::scene::ISceneManager* Client::getSceneManager() +scene::ISceneManager* Client::getSceneManager() { return m_rendering_engine->get_scene_manager(); } diff --git a/src/client/client.h b/src/client/client.h index b819d4301..c9a72b1b3 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -356,7 +356,7 @@ public: void setCamera(Camera* camera) { m_camera = camera; } Camera* getCamera () { return m_camera; } - irr::scene::ISceneManager *getSceneManager(); + scene::ISceneManager *getSceneManager(); bool shouldShowMinimap() const; diff --git a/src/client/clientobject.h b/src/client/clientobject.h index dbc2f22cf..b192f0dcd 100644 --- a/src/client/clientobject.h +++ b/src/client/clientobject.h @@ -33,17 +33,13 @@ class LocalPlayer; struct ItemStack; class WieldMeshSceneNode; -namespace irr { namespace scene { - class ISceneManager; -}} - class ClientActiveObject : public ActiveObject { public: ClientActiveObject(u16 id, Client *client, ClientEnvironment *env); virtual ~ClientActiveObject(); - virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) = 0; + virtual void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) = 0; virtual void removeFromScene(bool permanent) {} virtual void updateLight(u32 day_night_ratio) {} diff --git a/src/client/clouds.cpp b/src/client/clouds.cpp index 5a075aaf0..5008047af 100644 --- a/src/client/clouds.cpp +++ b/src/client/clouds.cpp @@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., // Menu clouds are created later class Clouds; Clouds *g_menuclouds = NULL; -irr::scene::ISceneManager *g_menucloudsmgr = NULL; +scene::ISceneManager *g_menucloudsmgr = NULL; // Constant for now static constexpr const float cloud_size = BS * 64.0f; diff --git a/src/client/clouds.h b/src/client/clouds.h index a4d810faa..c009a05b7 100644 --- a/src/client/clouds.h +++ b/src/client/clouds.h @@ -29,8 +29,7 @@ class Clouds; extern Clouds *g_menuclouds; // Scene manager used for menu clouds -namespace irr{namespace scene{class ISceneManager;}} -extern irr::scene::ISceneManager *g_menucloudsmgr; +extern scene::ISceneManager *g_menucloudsmgr; class Clouds : public scene::ISceneNode { diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index a2fbbf001..6c7559364 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -188,7 +188,7 @@ public: static ClientActiveObject* create(Client *client, ClientEnvironment *env); - void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr); + void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr); void removeFromScene(bool permanent); void updateLight(u32 day_night_ratio); void updateNodePos(); @@ -219,7 +219,7 @@ ClientActiveObject* TestCAO::create(Client *client, ClientEnvironment *env) return new TestCAO(client, env); } -void TestCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) +void TestCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) { if(m_node != NULL) return; @@ -590,7 +590,7 @@ void GenericCAO::removeFromScene(bool permanent) m_client->getMinimap()->removeMarker(&m_marker); } -void GenericCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) +void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) { m_smgr = smgr; @@ -1484,10 +1484,10 @@ void GenericCAO::updateBonePosition() if (m_bone_position.empty() || !m_animated_meshnode) return; - m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render + m_animated_meshnode->setJointMode(scene::EJUOR_CONTROL); // To write positions to the mesh on render for (auto &it : m_bone_position) { std::string bone_name = it.first; - irr::scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str()); + scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str()); if (bone) { bone->setPosition(it.second.X); bone->setRotation(it.second.Y); @@ -1496,7 +1496,7 @@ void GenericCAO::updateBonePosition() // search through bones to find mistakenly rotated bones due to bug in Irrlicht for (u32 i = 0; i < m_animated_meshnode->getJointCount(); ++i) { - irr::scene::IBoneSceneNode *bone = m_animated_meshnode->getJointNode(i); + scene::IBoneSceneNode *bone = m_animated_meshnode->getJointNode(i); if (!bone) continue; @@ -1924,7 +1924,7 @@ void GenericCAO::updateMeshCulling() return; } - irr::scene::ISceneNode *node = getSceneNode(); + scene::ISceneNode *node = getSceneNode(); if (!node) return; diff --git a/src/client/content_cao.h b/src/client/content_cao.h index 32ec9c1c3..4bbba9134 100644 --- a/src/client/content_cao.h +++ b/src/client/content_cao.h @@ -236,7 +236,7 @@ public: void removeFromScene(bool permanent); - void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr); + void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr); inline void expireVisuals() { diff --git a/src/client/content_mapblock.cpp b/src/client/content_mapblock.cpp index e530f3d7f..810c57138 100644 --- a/src/client/content_mapblock.cpp +++ b/src/client/content_mapblock.cpp @@ -61,7 +61,7 @@ static constexpr u16 quad_indices[] = {0, 1, 2, 2, 3, 0}; const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike"; MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output, - irr::scene::IMeshManipulator *mm): + scene::IMeshManipulator *mm): data(input), collector(output), nodedef(data->m_client->ndef()), diff --git a/src/client/content_mapblock.h b/src/client/content_mapblock.h index cbee49021..237cc7847 100644 --- a/src/client/content_mapblock.h +++ b/src/client/content_mapblock.h @@ -173,7 +173,7 @@ public: public: MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output, - irr::scene::IMeshManipulator *mm); + scene::IMeshManipulator *mm); void generate(); void renderSingle(content_t node, u8 param2 = 0x00); }; diff --git a/src/client/game.cpp b/src/client/game.cpp index 2f0f50505..eb1dbb5a3 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -839,7 +839,7 @@ private: MapDrawControl *draw_control = nullptr; Camera *camera = nullptr; Clouds *clouds = nullptr; // Free using ->Drop() - Sky *m_sky = nullptr; // Free using ->Drop() + Sky *sky = nullptr; // Free using ->Drop() Hud *hud = nullptr; Minimap *mapper = nullptr; @@ -1159,8 +1159,8 @@ void Game::shutdown() if (gui_chat_console) gui_chat_console->drop(); - if (m_sky) - m_sky->drop(); + if (sky) + sky->drop(); /* cleanup menus */ while (g_menumgr.menuCount() > 0) { @@ -1346,8 +1346,8 @@ bool Game::createClient(const GameStartData &start_data) /* Skybox */ - m_sky = new Sky(-1, m_rendering_engine, texture_src, shader_src); - scsf->setSky(m_sky); + sky = new Sky(-1, m_rendering_engine, texture_src, shader_src); + scsf->setSky(sky); skybox = NULL; // This is used/set later on in the main run loop /* Pre-calculated values @@ -2754,23 +2754,23 @@ void Game::handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *ca void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) { - m_sky->setVisible(false); + sky->setVisible(false); // Whether clouds are visible in front of a custom skybox. - m_sky->setCloudsEnabled(event->set_sky->clouds); + sky->setCloudsEnabled(event->set_sky->clouds); if (skybox) { skybox->remove(); skybox = NULL; } // Clear the old textures out in case we switch rendering type. - m_sky->clearSkyboxTextures(); + sky->clearSkyboxTextures(); // Handle according to type if (event->set_sky->type == "regular") { // Shows the mesh skybox - m_sky->setVisible(true); + sky->setVisible(true); // Update mesh based skybox colours if applicable. - m_sky->setSkyColors(event->set_sky->sky_color); - m_sky->setHorizonTint( + sky->setSkyColors(event->set_sky->sky_color); + sky->setHorizonTint( event->set_sky->fog_sun_tint, event->set_sky->fog_moon_tint, event->set_sky->fog_tint_type @@ -2778,27 +2778,27 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) } else if (event->set_sky->type == "skybox" && event->set_sky->textures.size() == 6) { // Disable the dyanmic mesh skybox: - m_sky->setVisible(false); + sky->setVisible(false); // Set fog colors: - m_sky->setFallbackBgColor(event->set_sky->bgcolor); + sky->setFallbackBgColor(event->set_sky->bgcolor); // Set sunrise and sunset fog tinting: - m_sky->setHorizonTint( + sky->setHorizonTint( event->set_sky->fog_sun_tint, event->set_sky->fog_moon_tint, event->set_sky->fog_tint_type ); // Add textures to skybox. for (int i = 0; i < 6; i++) - m_sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src); + sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src); } else { // Handle everything else as plain color. if (event->set_sky->type != "plain") infostream << "Unknown sky type: " << (event->set_sky->type) << std::endl; - m_sky->setVisible(false); - m_sky->setFallbackBgColor(event->set_sky->bgcolor); + sky->setVisible(false); + sky->setFallbackBgColor(event->set_sky->bgcolor); // Disable directional sun/moon tinting on plain or invalid skyboxes. - m_sky->setHorizonTint( + sky->setHorizonTint( event->set_sky->bgcolor, event->set_sky->bgcolor, "custom" @@ -2810,30 +2810,30 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) void Game::handleClientEvent_SetSun(ClientEvent *event, CameraOrientation *cam) { - m_sky->setSunVisible(event->sun_params->visible); - m_sky->setSunTexture(event->sun_params->texture, + sky->setSunVisible(event->sun_params->visible); + sky->setSunTexture(event->sun_params->texture, event->sun_params->tonemap, texture_src); - m_sky->setSunScale(event->sun_params->scale); - m_sky->setSunriseVisible(event->sun_params->sunrise_visible); - m_sky->setSunriseTexture(event->sun_params->sunrise, texture_src); + sky->setSunScale(event->sun_params->scale); + sky->setSunriseVisible(event->sun_params->sunrise_visible); + sky->setSunriseTexture(event->sun_params->sunrise, texture_src); delete event->sun_params; } void Game::handleClientEvent_SetMoon(ClientEvent *event, CameraOrientation *cam) { - m_sky->setMoonVisible(event->moon_params->visible); - m_sky->setMoonTexture(event->moon_params->texture, + sky->setMoonVisible(event->moon_params->visible); + sky->setMoonTexture(event->moon_params->texture, event->moon_params->tonemap, texture_src); - m_sky->setMoonScale(event->moon_params->scale); + sky->setMoonScale(event->moon_params->scale); delete event->moon_params; } void Game::handleClientEvent_SetStars(ClientEvent *event, CameraOrientation *cam) { - m_sky->setStarsVisible(event->star_params->visible); - m_sky->setStarCount(event->star_params->count, false); - m_sky->setStarColor(event->star_params->starcolor); - m_sky->setStarScale(event->star_params->scale); + sky->setStarsVisible(event->star_params->visible); + sky->setStarCount(event->star_params->count, false); + sky->setStarColor(event->star_params->starcolor); + sky->setStarScale(event->star_params->scale); delete event->star_params; } @@ -3710,7 +3710,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, direct_brightness = time_brightness; sunlight_seen = true; } else { - float old_brightness = m_sky->getBrightness(); + float old_brightness = sky->getBrightness(); direct_brightness = client->getEnv().getClientMap() .getBackgroundBrightness(MYMIN(runData.fog_range * 1.2, 60 * BS), daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen) @@ -3737,7 +3737,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, runData.time_of_day_smooth = time_of_day_smooth; - m_sky->update(time_of_day_smooth, time_brightness, direct_brightness, + sky->update(time_of_day_smooth, time_brightness, direct_brightness, sunlight_seen, camera->getCameraMode(), player->getYaw(), player->getPitch()); @@ -3745,7 +3745,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, Update clouds */ if (clouds) { - if (m_sky->getCloudsVisible()) { + if (sky->getCloudsVisible()) { clouds->setVisible(true); clouds->step(dtime); // camera->getPosition is not enough for 3rd person views @@ -3755,14 +3755,14 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, camera_node_position.Y = camera_node_position.Y + camera_offset.Y * BS; camera_node_position.Z = camera_node_position.Z + camera_offset.Z * BS; clouds->update(camera_node_position, - m_sky->getCloudColor()); + sky->getCloudColor()); if (clouds->isCameraInsideCloud() && m_cache_enable_fog) { // if inside clouds, and fog enabled, use that as sky // color(s) video::SColor clouds_dark = clouds->getColor() .getInterpolated(video::SColor(255, 0, 0, 0), 0.9); - m_sky->overrideColors(clouds_dark, clouds->getColor()); - m_sky->setInClouds(true); + sky->overrideColors(clouds_dark, clouds->getColor()); + sky->setInClouds(true); runData.fog_range = std::fmin(runData.fog_range * 0.5f, 32.0f * BS); // do not draw clouds after all clouds->setVisible(false); @@ -3783,7 +3783,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, if (m_cache_enable_fog) { driver->setFog( - m_sky->getBgColor(), + sky->getBgColor(), video::EFT_FOG_LINEAR, runData.fog_range * m_cache_fog_start, runData.fog_range * 1.0, @@ -3793,7 +3793,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, ); } else { driver->setFog( - m_sky->getBgColor(), + sky->getBgColor(), video::EFT_FOG_LINEAR, 100000 * BS, 110000 * BS, @@ -3873,7 +3873,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, /* Drawing begins */ - const video::SColor &skycolor = m_sky->getSkyColor(); + const video::SColor &skycolor = sky->getSkyColor(); TimeTaker tt_draw("Draw scene"); driver->beginScene(true, true, skycolor); diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index e74446aeb..4f96a6e37 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -225,7 +225,7 @@ bool RenderingEngine::print_video_modes() return videomode_list != NULL; } -void RenderingEngine::removeMesh(const irr::scene::IMesh* mesh) +void RenderingEngine::removeMesh(const scene::IMesh* mesh) { m_device->getSceneManager()->getMeshCache()->removeMesh(mesh); } diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index 1fd85f5ef..28ddc8652 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -26,9 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_extrabloated.h" #include "debug.h" -namespace irr { namespace scene { -class IMesh; -}} class ITextureSource; class Camera; class Client; @@ -60,7 +57,7 @@ public: static bool print_video_modes(); void cleanupMeshCache(); - void removeMesh(const irr::scene::IMesh* mesh); + void removeMesh(const scene::IMesh* mesh); static v2u32 getWindowSize() { diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h index f54490e3a..4dc614706 100644 --- a/src/script/common/c_content.h +++ b/src/script/common/c_content.h @@ -39,6 +39,8 @@ extern "C" { #include "itemgroup.h" #include "itemdef.h" #include "c_types.h" +// We do a explicit path include because by default c_content.h include src/client/hud.h +// prior to the src/hud.h, which is not good on server only build #include "../../hud.h" namespace Json { class Value; } diff --git a/src/unittest/test_clientactiveobjectmgr.cpp b/src/unittest/test_clientactiveobjectmgr.cpp index a43855c19..2d508cf32 100644 --- a/src/unittest/test_clientactiveobjectmgr.cpp +++ b/src/unittest/test_clientactiveobjectmgr.cpp @@ -29,7 +29,7 @@ public: TestClientActiveObject() : ClientActiveObject(0, nullptr, nullptr) {} ~TestClientActiveObject() = default; ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_TEST; } - virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) {} + virtual void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) {} }; class TestClientActiveObjectMgr : public TestBase -- cgit v1.2.3