mirror of
https://github.com/minetest/minetest.git
synced 2024-11-24 00:23:46 +01:00
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
This commit is contained in:
parent
74125a74d3
commit
258101a910
@ -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);
|
m_curr_fov_degrees = rangelim(m_curr_fov_degrees, 1.0f, 160.0f);
|
||||||
|
|
||||||
// FOV and aspect ratio
|
// 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_aspect = (f32) window_size.X / (f32) window_size.Y;
|
||||||
m_fov_y = m_curr_fov_degrees * M_PI / 180.0;
|
m_fov_y = m_curr_fov_degrees * M_PI / 180.0;
|
||||||
// Increase vertical FOV on lower aspect ratios (<16:10)
|
// Increase vertical FOV on lower aspect ratios (<16:10)
|
||||||
|
@ -80,7 +80,7 @@ ClientLauncher::~ClientLauncher()
|
|||||||
delete g_fontengine;
|
delete g_fontengine;
|
||||||
delete g_gamecallback;
|
delete g_gamecallback;
|
||||||
|
|
||||||
delete RenderingEngine::get_instance();
|
delete m_rendering_engine;
|
||||||
|
|
||||||
#if USE_SOUND
|
#if USE_SOUND
|
||||||
g_sound_manager_singleton.reset();
|
g_sound_manager_singleton.reset();
|
||||||
@ -101,7 +101,7 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
|||||||
|
|
||||||
// List video modes if requested
|
// List video modes if requested
|
||||||
if (list_video_modes)
|
if (list_video_modes)
|
||||||
return RenderingEngine::print_video_modes();
|
return m_rendering_engine->print_video_modes();
|
||||||
|
|
||||||
#if USE_SOUND
|
#if USE_SOUND
|
||||||
if (g_settings->getBool("enable_sound"))
|
if (g_settings->getBool("enable_sound"))
|
||||||
@ -120,12 +120,12 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RenderingEngine::get_video_driver() == NULL) {
|
if (m_rendering_engine->get_video_driver() == NULL) {
|
||||||
errorstream << "Could not initialize video driver." << std::endl;
|
errorstream << "Could not initialize video driver." << std::endl;
|
||||||
return false;
|
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.
|
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
|
// Create game callback for menus
|
||||||
g_gamecallback = new MainGameCallback();
|
g_gamecallback = new MainGameCallback();
|
||||||
|
|
||||||
RenderingEngine::get_instance()->setResizable(true);
|
m_rendering_engine->setResizable(true);
|
||||||
|
|
||||||
init_input();
|
init_input();
|
||||||
|
|
||||||
RenderingEngine::get_scene_manager()->getParameters()->
|
m_rendering_engine->get_scene_manager()->getParameters()->
|
||||||
setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
|
setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
|
||||||
|
|
||||||
guienv = RenderingEngine::get_gui_env();
|
guienv = m_rendering_engine->get_gui_env();
|
||||||
skin = RenderingEngine::get_gui_env()->getSkin();
|
skin = guienv->getSkin();
|
||||||
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
|
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_LIGHT, video::SColor(0, 0, 0, 0));
|
||||||
skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 30, 30, 30));
|
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");
|
sprite_path.append("checkbox_16.png");
|
||||||
// Texture dimensions should be a power of 2
|
// Texture dimensions should be a power of 2
|
||||||
gui::IGUISpriteBank *sprites = skin->getSpriteBank();
|
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());
|
video::ITexture *sprite_texture = driver->getTexture(sprite_path.c_str());
|
||||||
if (sprite_texture) {
|
if (sprite_texture) {
|
||||||
s32 sprite_id = sprites->addTextureAsSprite(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
|
// Create the menu clouds
|
||||||
if (!g_menucloudsmgr)
|
if (!g_menucloudsmgr)
|
||||||
g_menucloudsmgr = RenderingEngine::get_scene_manager()->createNewSceneManager();
|
g_menucloudsmgr = m_rendering_engine->get_scene_manager()->createNewSceneManager();
|
||||||
if (!g_menuclouds)
|
if (!g_menuclouds)
|
||||||
g_menuclouds = new Clouds(g_menucloudsmgr, -1, rand());
|
g_menuclouds = new Clouds(g_menucloudsmgr, -1, rand());
|
||||||
g_menuclouds->setHeight(100.0f);
|
g_menuclouds->setHeight(100.0f);
|
||||||
@ -212,11 +212,11 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
|||||||
bool retval = true;
|
bool retval = true;
|
||||||
bool *kill = porting::signal_handler_killstatus();
|
bool *kill = porting::signal_handler_killstatus();
|
||||||
|
|
||||||
while (RenderingEngine::run() && !*kill &&
|
while (m_rendering_engine->run() && !*kill &&
|
||||||
!g_gamecallback->shutdown_requested) {
|
!g_gamecallback->shutdown_requested) {
|
||||||
// Set the window caption
|
// Set the window caption
|
||||||
const wchar_t *text = wgettext("Main Menu");
|
const wchar_t *text = wgettext("Main Menu");
|
||||||
RenderingEngine::get_raw_device()->
|
m_rendering_engine->get_raw_device()->
|
||||||
setWindowCaption((utf8_to_wide(PROJECT_NAME_C) +
|
setWindowCaption((utf8_to_wide(PROJECT_NAME_C) +
|
||||||
L" " + utf8_to_wide(g_version_hash) +
|
L" " + utf8_to_wide(g_version_hash) +
|
||||||
L" [" + text + L"]").c_str());
|
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
|
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
|
We need some kind of a root node to be able to add
|
||||||
custom gui elements directly on the screen.
|
custom gui elements directly on the screen.
|
||||||
Otherwise they won't be automatically drawn.
|
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<s32>(0, 0, 10000, 10000));
|
core::rect<s32>(0, 0, 10000, 10000));
|
||||||
|
|
||||||
bool game_has_run = launch_game(error_message, reconnect_requested,
|
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
|
// 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())
|
if (!g_settings_path.empty())
|
||||||
g_settings->updateConfigFile(g_settings_path.c_str());
|
g_settings->updateConfigFile(g_settings_path.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderingEngine::get_video_driver()->setTextureCreationFlag(
|
m_rendering_engine->get_video_driver()->setTextureCreationFlag(
|
||||||
video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));
|
video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));
|
||||||
|
|
||||||
#ifdef HAVE_TOUCHSCREENGUI
|
#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;
|
g_touchscreengui = receiver->m_touchscreengui;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
the_game(
|
the_game(
|
||||||
kill,
|
kill,
|
||||||
input,
|
input,
|
||||||
|
m_rendering_engine,
|
||||||
start_data,
|
start_data,
|
||||||
error_message,
|
error_message,
|
||||||
chat_backend,
|
chat_backend,
|
||||||
&reconnect_requested
|
&reconnect_requested
|
||||||
);
|
);
|
||||||
RenderingEngine::get_scene_manager()->clear();
|
m_rendering_engine->get_scene_manager()->clear();
|
||||||
|
|
||||||
#ifdef HAVE_TOUCHSCREENGUI
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
delete g_touchscreengui;
|
delete g_touchscreengui;
|
||||||
@ -344,8 +345,8 @@ void ClientLauncher::init_args(GameStartData &start_data, const Settings &cmd_ar
|
|||||||
bool ClientLauncher::init_engine()
|
bool ClientLauncher::init_engine()
|
||||||
{
|
{
|
||||||
receiver = new MyEventReceiver();
|
receiver = new MyEventReceiver();
|
||||||
new RenderingEngine(receiver);
|
m_rendering_engine = new RenderingEngine(receiver);
|
||||||
return RenderingEngine::get_raw_device() != nullptr;
|
return m_rendering_engine->get_raw_device() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientLauncher::init_input()
|
void ClientLauncher::init_input()
|
||||||
@ -362,7 +363,7 @@ void ClientLauncher::init_input()
|
|||||||
// Make sure this is called maximum once per
|
// Make sure this is called maximum once per
|
||||||
// irrlicht device, otherwise it will give you
|
// irrlicht device, otherwise it will give you
|
||||||
// multiple events for the same joystick.
|
// 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;
|
infostream << "Joystick support enabled" << std::endl;
|
||||||
joystick_infos.reserve(infos.size());
|
joystick_infos.reserve(infos.size());
|
||||||
for (u32 i = 0; i < infos.size(); i++) {
|
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();
|
start_data.address.empty() && !start_data.name.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RenderingEngine::run())
|
if (!m_rendering_engine->run())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!start_data.isSinglePlayer() && start_data.name.empty()) {
|
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)
|
void ClientLauncher::main_menu(MainMenuData *menudata)
|
||||||
{
|
{
|
||||||
bool *kill = porting::signal_handler_killstatus();
|
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;
|
infostream << "Waiting for other menus" << std::endl;
|
||||||
while (RenderingEngine::get_raw_device()->run() && !*kill) {
|
while (m_rendering_engine->run() && !*kill) {
|
||||||
if (!isMenuActive())
|
if (!isMenuActive())
|
||||||
break;
|
break;
|
||||||
driver->beginScene(true, true, video::SColor(255, 128, 128, 128));
|
driver->beginScene(true, true, video::SColor(255, 128, 128, 128));
|
||||||
RenderingEngine::get_gui_env()->drawAll();
|
m_rendering_engine->get_gui_env()->drawAll();
|
||||||
driver->endScene();
|
driver->endScene();
|
||||||
// On some computers framerate doesn't seem to be automatically limited
|
// On some computers framerate doesn't seem to be automatically limited
|
||||||
sleep_ms(25);
|
sleep_ms(25);
|
||||||
@ -557,14 +558,14 @@ void ClientLauncher::main_menu(MainMenuData *menudata)
|
|||||||
|
|
||||||
// Cursor can be non-visible when coming from the game
|
// Cursor can be non-visible when coming from the game
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
RenderingEngine::get_raw_device()->getCursorControl()->setVisible(true);
|
m_rendering_engine->get_raw_device()->getCursorControl()->setVisible(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* show main menu */
|
/* 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 */
|
/* leave scene manager in a clean state */
|
||||||
RenderingEngine::get_scene_manager()->clear();
|
m_rendering_engine->get_scene_manager()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientLauncher::speed_tests()
|
void ClientLauncher::speed_tests()
|
||||||
|
@ -49,6 +49,7 @@ private:
|
|||||||
bool list_video_modes = false;
|
bool list_video_modes = false;
|
||||||
bool skip_main_menu = false;
|
bool skip_main_menu = false;
|
||||||
bool random_input = false;
|
bool random_input = false;
|
||||||
|
RenderingEngine *m_rendering_engine = nullptr;
|
||||||
InputHandler *input = nullptr;
|
InputHandler *input = nullptr;
|
||||||
MyEventReceiver *receiver = nullptr;
|
MyEventReceiver *receiver = nullptr;
|
||||||
gui::IGUISkin *skin = nullptr;
|
gui::IGUISkin *skin = nullptr;
|
||||||
|
@ -642,6 +642,7 @@ public:
|
|||||||
|
|
||||||
bool startup(bool *kill,
|
bool startup(bool *kill,
|
||||||
InputHandler *input,
|
InputHandler *input,
|
||||||
|
RenderingEngine *rendering_engine,
|
||||||
const GameStartData &game_params,
|
const GameStartData &game_params,
|
||||||
std::string &error_message,
|
std::string &error_message,
|
||||||
bool *reconnect,
|
bool *reconnect,
|
||||||
@ -853,6 +854,7 @@ private:
|
|||||||
these items (e.g. device)
|
these items (e.g. device)
|
||||||
*/
|
*/
|
||||||
IrrlichtDevice *device;
|
IrrlichtDevice *device;
|
||||||
|
RenderingEngine *m_rendering_engine;
|
||||||
video::IVideoDriver *driver;
|
video::IVideoDriver *driver;
|
||||||
scene::ISceneManager *smgr;
|
scene::ISceneManager *smgr;
|
||||||
bool *kill;
|
bool *kill;
|
||||||
@ -994,6 +996,7 @@ Game::~Game()
|
|||||||
|
|
||||||
bool Game::startup(bool *kill,
|
bool Game::startup(bool *kill,
|
||||||
InputHandler *input,
|
InputHandler *input,
|
||||||
|
RenderingEngine *rendering_engine,
|
||||||
const GameStartData &start_data,
|
const GameStartData &start_data,
|
||||||
std::string &error_message,
|
std::string &error_message,
|
||||||
bool *reconnect,
|
bool *reconnect,
|
||||||
@ -1001,21 +1004,21 @@ bool Game::startup(bool *kill,
|
|||||||
{
|
{
|
||||||
|
|
||||||
// "cache"
|
// "cache"
|
||||||
this->device = RenderingEngine::get_raw_device();
|
m_rendering_engine = rendering_engine;
|
||||||
|
device = m_rendering_engine->get_raw_device();
|
||||||
this->kill = kill;
|
this->kill = kill;
|
||||||
this->error_message = &error_message;
|
this->error_message = &error_message;
|
||||||
this->reconnect_requested = reconnect;
|
reconnect_requested = reconnect;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->chat_backend = chat_backend;
|
this->chat_backend = chat_backend;
|
||||||
this->simple_singleplayer_mode = start_data.isSinglePlayer();
|
simple_singleplayer_mode = start_data.isSinglePlayer();
|
||||||
|
|
||||||
input->keycache.populate();
|
input->keycache.populate();
|
||||||
|
|
||||||
driver = device->getVideoDriver();
|
driver = device->getVideoDriver();
|
||||||
smgr = RenderingEngine::get_scene_manager();
|
smgr = m_rendering_engine->get_scene_manager();
|
||||||
|
|
||||||
RenderingEngine::get_scene_manager()->getParameters()->
|
smgr->getParameters()->setAttribute(scene::OBJ_LOADER_IGNORE_MATERIAL_FILES, true);
|
||||||
setAttribute(scene::OBJ_LOADER_IGNORE_MATERIAL_FILES, true);
|
|
||||||
|
|
||||||
// Reinit runData
|
// Reinit runData
|
||||||
runData = GameRunData();
|
runData = GameRunData();
|
||||||
@ -1036,7 +1039,7 @@ bool Game::startup(bool *kill,
|
|||||||
if (!createClient(start_data))
|
if (!createClient(start_data))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
RenderingEngine::initialize(client, hud);
|
m_rendering_engine->initialize(client, hud);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1055,7 +1058,7 @@ void Game::run()
|
|||||||
Profiler::GraphValues dummyvalues;
|
Profiler::GraphValues dummyvalues;
|
||||||
g_profiler->graphGet(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"));
|
set_light_table(g_settings->getFloat("display_gamma"));
|
||||||
|
|
||||||
@ -1067,12 +1070,12 @@ void Game::run()
|
|||||||
irr::core::dimension2d<u32> previous_screen_size(g_settings->getU16("screen_w"),
|
irr::core::dimension2d<u32> previous_screen_size(g_settings->getU16("screen_w"),
|
||||||
g_settings->getU16("screen_h"));
|
g_settings->getU16("screen_h"));
|
||||||
|
|
||||||
while (RenderingEngine::run()
|
while (m_rendering_engine->run()
|
||||||
&& !(*kill || g_gamecallback->shutdown_requested
|
&& !(*kill || g_gamecallback->shutdown_requested
|
||||||
|| (server && server->isShutdownRequested()))) {
|
|| (server && server->isShutdownRequested()))) {
|
||||||
|
|
||||||
const irr::core::dimension2d<u32> ¤t_screen_size =
|
const irr::core::dimension2d<u32> ¤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
|
// Verify if window size has changed and save it if it's the case
|
||||||
// Ensure evaluating settings->getBool after verifying screensize
|
// Ensure evaluating settings->getBool after verifying screensize
|
||||||
// First condition is cheaper
|
// First condition is cheaper
|
||||||
@ -1085,7 +1088,7 @@ void Game::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate dtime =
|
// Calculate dtime =
|
||||||
// RenderingEngine::run() from this iteration
|
// m_rendering_engine->run() from this iteration
|
||||||
// + Sleep time until the wanted FPS are reached
|
// + Sleep time until the wanted FPS are reached
|
||||||
limitFps(&draw_times, &dtime);
|
limitFps(&draw_times, &dtime);
|
||||||
|
|
||||||
@ -1134,7 +1137,7 @@ void Game::run()
|
|||||||
|
|
||||||
void Game::shutdown()
|
void Game::shutdown()
|
||||||
{
|
{
|
||||||
RenderingEngine::finalize();
|
m_rendering_engine->finalize();
|
||||||
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8
|
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8
|
||||||
if (g_settings->get("3d_mode") == "pageflip") {
|
if (g_settings->get("3d_mode") == "pageflip") {
|
||||||
driver->setRenderTarget(irr::video::ERT_STEREO_BOTH_BUFFERS);
|
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,
|
start_data.password, start_data.address,
|
||||||
*draw_control, texture_src, shader_src,
|
*draw_control, texture_src, shader_src,
|
||||||
itemdef_manager, nodedef_manager, sound, eventmgr,
|
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;
|
client->m_simple_singleplayer_mode = simple_singleplayer_mode;
|
||||||
|
|
||||||
@ -1485,9 +1488,9 @@ bool Game::connectToServer(const GameStartData &start_data,
|
|||||||
f32 dtime;
|
f32 dtime;
|
||||||
f32 wait_time = 0; // in seconds
|
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);
|
limitFps(&fps_control, &dtime);
|
||||||
|
|
||||||
@ -1524,7 +1527,7 @@ bool Game::connectToServer(const GameStartData &start_data,
|
|||||||
if (client->m_is_registration_confirmation_state) {
|
if (client->m_is_registration_confirmation_state) {
|
||||||
if (registration_confirmation_shown) {
|
if (registration_confirmation_shown) {
|
||||||
// Keep drawing the GUI
|
// Keep drawing the GUI
|
||||||
RenderingEngine::draw_menu_scene(guienv, dtime, true);
|
m_rendering_engine->draw_menu_scene(guienv, dtime, true);
|
||||||
} else {
|
} else {
|
||||||
registration_confirmation_shown = true;
|
registration_confirmation_shown = true;
|
||||||
(new GUIConfirmRegistration(guienv, guienv->getRootGUIElement(), -1,
|
(new GUIConfirmRegistration(guienv, guienv->getRootGUIElement(), -1,
|
||||||
@ -1560,9 +1563,9 @@ bool Game::getServerContent(bool *aborted)
|
|||||||
FpsControl fps_control = { 0 };
|
FpsControl fps_control = { 0 };
|
||||||
f32 dtime; // in seconds
|
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);
|
limitFps(&fps_control, &dtime);
|
||||||
|
|
||||||
@ -1600,13 +1603,13 @@ bool Game::getServerContent(bool *aborted)
|
|||||||
if (!client->itemdefReceived()) {
|
if (!client->itemdefReceived()) {
|
||||||
const wchar_t *text = wgettext("Item definitions...");
|
const wchar_t *text = wgettext("Item definitions...");
|
||||||
progress = 25;
|
progress = 25;
|
||||||
RenderingEngine::draw_load_screen(text, guienv, texture_src,
|
m_rendering_engine->draw_load_screen(text, guienv, texture_src,
|
||||||
dtime, progress);
|
dtime, progress);
|
||||||
delete[] text;
|
delete[] text;
|
||||||
} else if (!client->nodedefReceived()) {
|
} else if (!client->nodedefReceived()) {
|
||||||
const wchar_t *text = wgettext("Node definitions...");
|
const wchar_t *text = wgettext("Node definitions...");
|
||||||
progress = 30;
|
progress = 30;
|
||||||
RenderingEngine::draw_load_screen(text, guienv, texture_src,
|
m_rendering_engine->draw_load_screen(text, guienv, texture_src,
|
||||||
dtime, progress);
|
dtime, progress);
|
||||||
delete[] text;
|
delete[] text;
|
||||||
} else {
|
} else {
|
||||||
@ -1633,7 +1636,7 @@ bool Game::getServerContent(bool *aborted)
|
|||||||
}
|
}
|
||||||
|
|
||||||
progress = 30 + client->mediaReceiveProgress() * 35 + 0.5;
|
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);
|
texture_src, dtime, progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3886,7 +3889,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
|
|||||||
} catch (SettingNotFoundException) {
|
} catch (SettingNotFoundException) {
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
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)
|
void Game::showOverlayMessage(const char *msg, float dtime, int percent, bool draw_clouds)
|
||||||
{
|
{
|
||||||
const wchar_t *wmsg = wgettext(msg);
|
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);
|
draw_clouds);
|
||||||
delete[] wmsg;
|
delete[] wmsg;
|
||||||
}
|
}
|
||||||
@ -4229,6 +4232,7 @@ void Game::showPauseMenu()
|
|||||||
|
|
||||||
void the_game(bool *kill,
|
void the_game(bool *kill,
|
||||||
InputHandler *input,
|
InputHandler *input,
|
||||||
|
RenderingEngine *rendering_engine,
|
||||||
const GameStartData &start_data,
|
const GameStartData &start_data,
|
||||||
std::string &error_message,
|
std::string &error_message,
|
||||||
ChatBackend &chat_backend,
|
ChatBackend &chat_backend,
|
||||||
@ -4243,8 +4247,8 @@ void the_game(bool *kill,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (game.startup(kill, input, start_data, error_message,
|
if (game.startup(kill, input, rendering_engine, start_data,
|
||||||
reconnect_requested, &chat_backend)) {
|
error_message, reconnect_requested, &chat_backend)) {
|
||||||
game.run();
|
game.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class InputHandler;
|
class InputHandler;
|
||||||
class ChatBackend; /* to avoid having to include chat.h */
|
class ChatBackend;
|
||||||
|
class RenderingEngine;
|
||||||
struct SubgameSpec;
|
struct SubgameSpec;
|
||||||
struct GameStartData;
|
struct GameStartData;
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ struct CameraOrientation {
|
|||||||
|
|
||||||
void the_game(bool *kill,
|
void the_game(bool *kill,
|
||||||
InputHandler *input,
|
InputHandler *input,
|
||||||
|
RenderingEngine *rendering_engine,
|
||||||
const GameStartData &start_data,
|
const GameStartData &start_data,
|
||||||
std::string &error_message,
|
std::string &error_message,
|
||||||
ChatBackend &chat_backend,
|
ChatBackend &chat_backend,
|
||||||
|
@ -97,7 +97,7 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
|
|||||||
const CameraOrientation &cam, const PointedThing &pointed_old,
|
const CameraOrientation &cam, const PointedThing &pointed_old,
|
||||||
const GUIChatConsole *chat_console, float dtime)
|
const GUIChatConsole *chat_console, float dtime)
|
||||||
{
|
{
|
||||||
v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
|
v2u32 screensize = RenderingEngine::getWindowSize();
|
||||||
|
|
||||||
if (m_flags.show_debug) {
|
if (m_flags.show_debug) {
|
||||||
static float drawtime_avg = 0;
|
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)
|
if (m_flags.show_debug)
|
||||||
chat_y += 2 * g_fontengine->getLineHeight();
|
chat_y += 2 * g_fontengine->getLineHeight();
|
||||||
|
|
||||||
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
|
const v2u32 &window_size = RenderingEngine::getWindowSize();
|
||||||
|
|
||||||
core::rect<s32> chat_size(10, chat_y,
|
core::rect<s32> chat_size(10, chat_y,
|
||||||
window_size.X - 20, 0);
|
window_size.X - 20, 0);
|
||||||
|
@ -747,7 +747,7 @@ void Hud::drawHotbar(u16 playeritem) {
|
|||||||
s32 width = hotbar_itemcount * (m_hotbar_imagesize + m_padding * 2);
|
s32 width = hotbar_itemcount * (m_hotbar_imagesize + m_padding * 2);
|
||||||
v2s32 pos = centerlowerpos - v2s32(width / 2, m_hotbar_imagesize + m_padding * 3);
|
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 <=
|
if ((float) width / (float) window_size.X <=
|
||||||
g_settings->getFloat("hud_hotbar_max_width")) {
|
g_settings->getFloat("hud_hotbar_max_width")) {
|
||||||
if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) {
|
if (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) {
|
||||||
@ -956,7 +956,7 @@ void Hud::updateSelectionMesh(const v3s16 &camera_offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Hud::resizeHotbar() {
|
void Hud::resizeHotbar() {
|
||||||
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
|
const v2u32 &window_size = RenderingEngine::getWindowSize();
|
||||||
|
|
||||||
if (m_screensize != window_size) {
|
if (m_screensize != window_size) {
|
||||||
m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE *
|
m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE *
|
||||||
|
@ -577,7 +577,7 @@ scene::SMeshBuffer *Minimap::getMinimapMeshBuffer()
|
|||||||
void Minimap::drawMinimap()
|
void Minimap::drawMinimap()
|
||||||
{
|
{
|
||||||
// Non hud managed minimap drawing (legacy minimap)
|
// Non hud managed minimap drawing (legacy minimap)
|
||||||
v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
|
v2u32 screensize = RenderingEngine::getWindowSize();
|
||||||
const u32 size = 0.25 * screensize.Y;
|
const u32 size = 0.25 * screensize.Y;
|
||||||
|
|
||||||
drawMinimap(core::rect<s32>(
|
drawMinimap(core::rect<s32>(
|
||||||
|
@ -159,7 +159,7 @@ RenderingEngine::~RenderingEngine()
|
|||||||
s_singleton = nullptr;
|
s_singleton = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
v2u32 RenderingEngine::getWindowSize() const
|
v2u32 RenderingEngine::_getWindowSize() const
|
||||||
{
|
{
|
||||||
if (core)
|
if (core)
|
||||||
return core->getVirtualSize();
|
return core->getVirtualSize();
|
||||||
@ -497,7 +497,7 @@ void RenderingEngine::_draw_load_screen(const std::wstring &text,
|
|||||||
gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime,
|
gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime,
|
||||||
int percent, bool clouds)
|
int percent, bool clouds)
|
||||||
{
|
{
|
||||||
v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
|
v2u32 screensize = getWindowSize();
|
||||||
|
|
||||||
v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight());
|
v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight());
|
||||||
v2s32 center(screensize.X / 2, screensize.Y / 2);
|
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.
|
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)
|
float dtime, bool clouds)
|
||||||
{
|
{
|
||||||
bool cloud_menu_background = clouds && g_settings->getBool("menu_clouds");
|
bool cloud_menu_background = clouds && g_settings->getBool("menu_clouds");
|
||||||
@ -613,19 +613,19 @@ std::vector<irr::video::E_DRIVER_TYPE> RenderingEngine::getSupportedVideoDrivers
|
|||||||
return drivers;
|
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");
|
const std::string &draw_mode = g_settings->get("3d_mode");
|
||||||
core.reset(createRenderingCore(draw_mode, m_device, client, hud));
|
core.reset(createRenderingCore(draw_mode, m_device, client, hud));
|
||||||
core->initialize();
|
core->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingEngine::_finalize()
|
void RenderingEngine::finalize()
|
||||||
{
|
{
|
||||||
core.reset();
|
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)
|
bool show_minimap, bool draw_wield_tool, bool draw_crosshair)
|
||||||
{
|
{
|
||||||
core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair);
|
core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair);
|
||||||
|
@ -44,7 +44,6 @@ public:
|
|||||||
RenderingEngine(IEventReceiver *eventReceiver);
|
RenderingEngine(IEventReceiver *eventReceiver);
|
||||||
~RenderingEngine();
|
~RenderingEngine();
|
||||||
|
|
||||||
v2u32 getWindowSize() const;
|
|
||||||
void setResizable(bool resize);
|
void setResizable(bool resize);
|
||||||
|
|
||||||
video::IVideoDriver *getVideoDriver() { return driver; }
|
video::IVideoDriver *getVideoDriver() { return driver; }
|
||||||
@ -63,7 +62,11 @@ public:
|
|||||||
|
|
||||||
void removeMesh(const irr::scene::IMesh* mesh);
|
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()
|
io::IFileSystem *get_filesystem()
|
||||||
{
|
{
|
||||||
@ -88,11 +91,9 @@ public:
|
|||||||
return s_singleton->m_device;
|
return s_singleton->m_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 get_timer_time()
|
u32 get_timer_time()
|
||||||
{
|
{
|
||||||
sanity_check(s_singleton && s_singleton->m_device &&
|
return m_device->getTimer()->getTime();
|
||||||
s_singleton->m_device->getTimer());
|
|
||||||
return s_singleton->m_device->getTimer()->getTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gui::IGUIEnvironment *get_gui_env()
|
static gui::IGUIEnvironment *get_gui_env()
|
||||||
@ -109,30 +110,16 @@ public:
|
|||||||
text, guienv, tsrc, dtime, percent, clouds);
|
text, guienv, tsrc, dtime, percent, clouds);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void draw_menu_scene(
|
void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds);
|
||||||
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);
|
||||||
s_singleton->_draw_menu_scene(guienv, dtime, clouds);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static void draw_scene(video::SColor skycolor, bool show_hud,
|
void initialize(Client *client, Hud *hud);
|
||||||
bool show_minimap, bool draw_wield_tool, bool draw_crosshair)
|
void finalize();
|
||||||
{
|
|
||||||
s_singleton->_draw_scene(skycolor, show_hud, show_minimap,
|
|
||||||
draw_wield_tool, draw_crosshair);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static void initialize(Client *client, Hud *hud)
|
bool run()
|
||||||
{
|
{
|
||||||
s_singleton->_initialize(client, hud);
|
return m_device->run();
|
||||||
}
|
|
||||||
|
|
||||||
inline static void finalize() { s_singleton->_finalize(); }
|
|
||||||
|
|
||||||
static bool run()
|
|
||||||
{
|
|
||||||
sanity_check(s_singleton && s_singleton->m_device);
|
|
||||||
return s_singleton->m_device->run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<core::vector3d<u32>> getSupportedVideoModes();
|
static std::vector<core::vector3d<u32>> getSupportedVideoModes();
|
||||||
@ -143,15 +130,7 @@ private:
|
|||||||
ITextureSource *tsrc, float dtime = 0, int percent = 0,
|
ITextureSource *tsrc, float dtime = 0, int percent = 0,
|
||||||
bool clouds = true);
|
bool clouds = true);
|
||||||
|
|
||||||
void _draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime = 0,
|
v2u32 _getWindowSize() const;
|
||||||
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();
|
|
||||||
|
|
||||||
std::unique_ptr<RenderingCore> core;
|
std::unique_ptr<RenderingCore> core;
|
||||||
irr::IrrlichtDevice *m_device = nullptr;
|
irr::IrrlichtDevice *m_device = nullptr;
|
||||||
|
@ -121,12 +121,14 @@ void MenuMusicFetcher::fetchSounds(const std::string &name,
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
GUIEngine::GUIEngine(JoystickController *joystick,
|
GUIEngine::GUIEngine(JoystickController *joystick,
|
||||||
gui::IGUIElement *parent,
|
gui::IGUIElement *parent,
|
||||||
|
RenderingEngine *rendering_engine,
|
||||||
IMenuManager *menumgr,
|
IMenuManager *menumgr,
|
||||||
MainMenuData *data,
|
MainMenuData *data,
|
||||||
bool &kill) :
|
bool &kill) :
|
||||||
|
m_rendering_engine(rendering_engine),
|
||||||
m_parent(parent),
|
m_parent(parent),
|
||||||
m_menumanager(menumgr),
|
m_menumanager(menumgr),
|
||||||
m_smgr(RenderingEngine::get_scene_manager()),
|
m_smgr(rendering_engine->get_scene_manager()),
|
||||||
m_data(data),
|
m_data(data),
|
||||||
m_kill(kill)
|
m_kill(kill)
|
||||||
{
|
{
|
||||||
@ -138,7 +140,7 @@ GUIEngine::GUIEngine(JoystickController *joystick,
|
|||||||
m_buttonhandler = new TextDestGuiEngine(this);
|
m_buttonhandler = new TextDestGuiEngine(this);
|
||||||
|
|
||||||
//create texture source
|
//create texture source
|
||||||
m_texture_source = new MenuTextureSource(RenderingEngine::get_video_driver());
|
m_texture_source = new MenuTextureSource(rendering_engine->get_video_driver());
|
||||||
|
|
||||||
//create soundmanager
|
//create soundmanager
|
||||||
MenuMusicFetcher soundfetcher;
|
MenuMusicFetcher soundfetcher;
|
||||||
@ -156,7 +158,7 @@ GUIEngine::GUIEngine(JoystickController *joystick,
|
|||||||
g_fontengine->getTextHeight());
|
g_fontengine->getTextHeight());
|
||||||
rect += v2s32(4, 0);
|
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);
|
m_toplefttext, rect, false, true, 0, -1);
|
||||||
|
|
||||||
//create formspecsource
|
//create formspecsource
|
||||||
@ -232,7 +234,7 @@ void GUIEngine::run()
|
|||||||
{
|
{
|
||||||
// Always create clouds because they may or may not be
|
// Always create clouds because they may or may not be
|
||||||
// needed based on the game selected
|
// needed based on the game selected
|
||||||
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
|
video::IVideoDriver *driver = m_rendering_engine->get_video_driver();
|
||||||
|
|
||||||
cloudInit();
|
cloudInit();
|
||||||
|
|
||||||
@ -259,10 +261,10 @@ void GUIEngine::run()
|
|||||||
fog_pixelfog, fog_rangefog);
|
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> ¤t_screen_size =
|
const irr::core::dimension2d<u32> ¤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
|
// Verify if window size has changed and save it if it's the case
|
||||||
// Ensure evaluating settings->getBool after verifying screensize
|
// Ensure evaluating settings->getBool after verifying screensize
|
||||||
// First condition is cheaper
|
// First condition is cheaper
|
||||||
@ -293,11 +295,11 @@ void GUIEngine::run()
|
|||||||
drawHeader(driver);
|
drawHeader(driver);
|
||||||
drawFooter(driver);
|
drawFooter(driver);
|
||||||
|
|
||||||
RenderingEngine::get_gui_env()->drawAll();
|
m_rendering_engine->get_gui_env()->drawAll();
|
||||||
|
|
||||||
driver->endScene();
|
driver->endScene();
|
||||||
|
|
||||||
IrrlichtDevice *device = RenderingEngine::get_raw_device();
|
IrrlichtDevice *device = m_rendering_engine->get_raw_device();
|
||||||
u32 frametime_min = 1000 / (device->isWindowFocused()
|
u32 frametime_min = 1000 / (device->isWindowFocused()
|
||||||
? g_settings->getFloat("fps_max")
|
? g_settings->getFloat("fps_max")
|
||||||
: g_settings->getFloat("fps_max_unfocused"));
|
: g_settings->getFloat("fps_max_unfocused"));
|
||||||
@ -330,7 +332,7 @@ GUIEngine::~GUIEngine()
|
|||||||
//clean up texture pointers
|
//clean up texture pointers
|
||||||
for (image_definition &texture : m_textures) {
|
for (image_definition &texture : m_textures) {
|
||||||
if (texture.texture)
|
if (texture.texture)
|
||||||
RenderingEngine::get_video_driver()->removeTexture(texture.texture);
|
m_rendering_engine->get_video_driver()->removeTexture(texture.texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete m_texture_source;
|
delete m_texture_source;
|
||||||
@ -350,13 +352,13 @@ void GUIEngine::cloudInit()
|
|||||||
v3f(0,0,0), v3f(0, 60, 100));
|
v3f(0,0,0), v3f(0, 60, 100));
|
||||||
m_cloud.camera->setFarValue(10000);
|
m_cloud.camera->setFarValue(10000);
|
||||||
|
|
||||||
m_cloud.lasttime = RenderingEngine::get_timer_time();
|
m_cloud.lasttime = m_rendering_engine->get_timer_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void GUIEngine::cloudPreProcess()
|
void GUIEngine::cloudPreProcess()
|
||||||
{
|
{
|
||||||
u32 time = RenderingEngine::get_timer_time();
|
u32 time = m_rendering_engine->get_timer_time();
|
||||||
|
|
||||||
if(time > m_cloud.lasttime)
|
if(time > m_cloud.lasttime)
|
||||||
m_cloud.dtime = (time - m_cloud.lasttime) / 1000.0;
|
m_cloud.dtime = (time - m_cloud.lasttime) / 1000.0;
|
||||||
@ -377,7 +379,7 @@ void GUIEngine::cloudPostProcess(u32 frametime_min, IrrlichtDevice *device)
|
|||||||
u32 busytime_u32;
|
u32 busytime_u32;
|
||||||
|
|
||||||
// not using getRealTime is necessary for wine
|
// 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)
|
if(time > m_cloud.lasttime)
|
||||||
busytime_u32 = time - m_cloud.lasttime;
|
busytime_u32 = time - m_cloud.lasttime;
|
||||||
else
|
else
|
||||||
@ -528,7 +530,7 @@ void GUIEngine::drawFooter(video::IVideoDriver *driver)
|
|||||||
bool GUIEngine::setTexture(texture_layer layer, const std::string &texturepath,
|
bool GUIEngine::setTexture(texture_layer layer, const std::string &texturepath,
|
||||||
bool tile_image, unsigned int minsize)
|
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) {
|
if (m_textures[layer].texture) {
|
||||||
driver->removeTexture(m_textures[layer].texture);
|
driver->removeTexture(m_textures[layer].texture);
|
||||||
@ -595,7 +597,7 @@ void GUIEngine::updateTopLeftTextSize()
|
|||||||
rect += v2s32(4, 0);
|
rect += v2s32(4, 0);
|
||||||
|
|
||||||
m_irr_toplefttext->remove();
|
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);
|
m_toplefttext, rect, false, true, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ struct image_definition {
|
|||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
class GUIEngine;
|
class GUIEngine;
|
||||||
|
class RenderingEngine;
|
||||||
class MainMenuScripting;
|
class MainMenuScripting;
|
||||||
class Clouds;
|
class Clouds;
|
||||||
struct MainMenuData;
|
struct MainMenuData;
|
||||||
@ -150,6 +151,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
GUIEngine(JoystickController *joystick,
|
GUIEngine(JoystickController *joystick,
|
||||||
gui::IGUIElement *parent,
|
gui::IGUIElement *parent,
|
||||||
|
RenderingEngine *rendering_engine,
|
||||||
IMenuManager *menumgr,
|
IMenuManager *menumgr,
|
||||||
MainMenuData *data,
|
MainMenuData *data,
|
||||||
bool &kill);
|
bool &kill);
|
||||||
@ -188,6 +190,7 @@ private:
|
|||||||
/** update size of topleftext element */
|
/** update size of topleftext element */
|
||||||
void updateTopLeftTextSize();
|
void updateTopLeftTextSize();
|
||||||
|
|
||||||
|
RenderingEngine *m_rendering_engine = nullptr;
|
||||||
/** parent gui element */
|
/** parent gui element */
|
||||||
gui::IGUIElement *m_parent = nullptr;
|
gui::IGUIElement *m_parent = nullptr;
|
||||||
/** manager to add menus to */
|
/** manager to add menus to */
|
||||||
|
@ -225,8 +225,7 @@ int main(int argc, char *argv[])
|
|||||||
return run_dedicated_server(game_params, cmd_args) ? 0 : 1;
|
return run_dedicated_server(game_params, cmd_args) ? 0 : 1;
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
ClientLauncher launcher;
|
retval = ClientLauncher().run(game_params, cmd_args) ? 0 : 1;
|
||||||
retval = launcher.run(game_params, cmd_args) ? 0 : 1;
|
|
||||||
#else
|
#else
|
||||||
retval = 0;
|
retval = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -790,7 +790,7 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
|
|||||||
lua_pushnumber(L,RenderingEngine::getDisplayDensity());
|
lua_pushnumber(L,RenderingEngine::getDisplayDensity());
|
||||||
lua_settable(L, top);
|
lua_settable(L, top);
|
||||||
|
|
||||||
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
|
const v2u32 &window_size = RenderingEngine::getWindowSize();
|
||||||
lua_pushstring(L,"window_width");
|
lua_pushstring(L,"window_width");
|
||||||
lua_pushnumber(L, window_size.X);
|
lua_pushnumber(L, window_size.X);
|
||||||
lua_settable(L, top);
|
lua_settable(L, top);
|
||||||
|
Loading…
Reference in New Issue
Block a user