2017-06-26 20:11:17 +02:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
2017-10-31 19:27:10 +01:00
|
|
|
#include <memory>
|
2017-06-26 20:11:17 +02:00
|
|
|
#include <string>
|
|
|
|
#include "irrlichttypes_extrabloated.h"
|
|
|
|
#include "debug.h"
|
2021-06-06 18:51:21 +02:00
|
|
|
#include "client/render/core.h"
|
|
|
|
// include the shadow mapper classes too
|
|
|
|
#include "client/shadows/dynamicshadowsrender.h"
|
|
|
|
|
2021-07-11 09:50:34 +02:00
|
|
|
struct VideoDriverInfo {
|
|
|
|
std::string name;
|
|
|
|
std::string friendly_name;
|
|
|
|
};
|
2017-06-26 20:11:17 +02:00
|
|
|
|
|
|
|
class ITextureSource;
|
|
|
|
class Camera;
|
|
|
|
class Client;
|
|
|
|
class LocalPlayer;
|
|
|
|
class Hud;
|
|
|
|
class Minimap;
|
|
|
|
|
2017-10-31 19:27:10 +01:00
|
|
|
class RenderingCore;
|
|
|
|
|
2017-06-26 20:11:17 +02:00
|
|
|
class RenderingEngine
|
|
|
|
{
|
|
|
|
public:
|
2023-04-13 19:12:48 +02:00
|
|
|
static const video::SColor MENU_SKY_COLOR;
|
2022-11-02 09:09:48 +01:00
|
|
|
static const float BASE_BLOOM_STRENGTH;
|
2022-09-29 20:34:05 +02:00
|
|
|
|
2017-06-26 20:11:17 +02:00
|
|
|
RenderingEngine(IEventReceiver *eventReceiver);
|
|
|
|
~RenderingEngine();
|
|
|
|
|
|
|
|
void setResizable(bool resize);
|
|
|
|
|
2017-10-31 19:27:10 +01:00
|
|
|
video::IVideoDriver *getVideoDriver() { return driver; }
|
2017-06-26 20:11:17 +02:00
|
|
|
|
2021-07-11 09:50:34 +02:00
|
|
|
static const VideoDriverInfo &getVideoDriverInfo(irr::video::E_DRIVER_TYPE type);
|
2017-06-26 20:11:17 +02:00
|
|
|
static float getDisplayDensity();
|
|
|
|
|
2023-06-11 14:17:39 +02:00
|
|
|
bool setupTopLevelWindow();
|
2017-06-26 20:11:17 +02:00
|
|
|
bool setWindowIcon();
|
|
|
|
static bool print_video_modes();
|
2021-04-28 10:53:36 +02:00
|
|
|
void cleanupMeshCache();
|
2017-06-26 20:11:17 +02:00
|
|
|
|
2021-05-03 10:27:00 +02:00
|
|
|
void removeMesh(const scene::IMesh* mesh);
|
2021-04-28 11:07:28 +02:00
|
|
|
|
2023-02-27 23:58:41 +01:00
|
|
|
/**
|
|
|
|
* This takes 3d_mode into account - side-by-side will return a
|
|
|
|
* halved horizontal size.
|
|
|
|
*
|
|
|
|
* @return "window" size
|
|
|
|
*/
|
2021-04-28 12:48:13 +02:00
|
|
|
static v2u32 getWindowSize()
|
|
|
|
{
|
|
|
|
sanity_check(s_singleton);
|
|
|
|
return s_singleton->_getWindowSize();
|
|
|
|
}
|
2017-06-26 20:11:17 +02:00
|
|
|
|
2021-04-28 10:22:13 +02:00
|
|
|
io::IFileSystem *get_filesystem()
|
2017-06-26 20:11:17 +02:00
|
|
|
{
|
2021-04-28 10:22:13 +02:00
|
|
|
return m_device->getFileSystem();
|
2017-06-26 20:11:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static video::IVideoDriver *get_video_driver()
|
|
|
|
{
|
|
|
|
sanity_check(s_singleton && s_singleton->m_device);
|
|
|
|
return s_singleton->m_device->getVideoDriver();
|
|
|
|
}
|
|
|
|
|
2021-04-29 09:40:56 +02:00
|
|
|
scene::ISceneManager *get_scene_manager()
|
2017-06-26 20:11:17 +02:00
|
|
|
{
|
2021-04-29 09:40:56 +02:00
|
|
|
return m_device->getSceneManager();
|
2017-06-26 20:11:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static irr::IrrlichtDevice *get_raw_device()
|
|
|
|
{
|
|
|
|
sanity_check(s_singleton && s_singleton->m_device);
|
|
|
|
return s_singleton->m_device;
|
|
|
|
}
|
|
|
|
|
2021-04-28 12:48:13 +02:00
|
|
|
u32 get_timer_time()
|
2017-06-26 20:11:17 +02:00
|
|
|
{
|
2021-04-28 12:48:13 +02:00
|
|
|
return m_device->getTimer()->getTime();
|
2017-06-26 20:11:17 +02:00
|
|
|
}
|
|
|
|
|
2021-04-29 20:38:35 +02:00
|
|
|
gui::IGUIEnvironment *get_gui_env()
|
2017-06-26 20:11:17 +02:00
|
|
|
{
|
2021-04-29 20:38:35 +02:00
|
|
|
return m_device->getGUIEnvironment();
|
2017-06-26 20:11:17 +02:00
|
|
|
}
|
|
|
|
|
2023-08-22 19:20:49 +02:00
|
|
|
void draw_load_screen(const std::wstring &text,
|
|
|
|
gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
|
2023-04-13 19:12:48 +02:00
|
|
|
float dtime = 0, int percent = 0, bool sky = true);
|
2017-06-26 20:11:17 +02:00
|
|
|
|
2021-04-28 12:48:13 +02:00
|
|
|
void draw_scene(video::SColor skycolor, bool show_hud,
|
|
|
|
bool show_minimap, bool draw_wield_tool, bool draw_crosshair);
|
2018-01-13 12:07:16 +01:00
|
|
|
|
2021-04-28 12:48:13 +02:00
|
|
|
void initialize(Client *client, Hud *hud);
|
|
|
|
void finalize();
|
2017-10-31 19:27:10 +01:00
|
|
|
|
2021-04-28 12:48:13 +02:00
|
|
|
bool run()
|
2017-06-26 20:11:17 +02:00
|
|
|
{
|
2021-04-28 12:48:13 +02:00
|
|
|
return m_device->run();
|
2017-06-26 20:11:17 +02:00
|
|
|
}
|
|
|
|
|
2021-06-06 18:51:21 +02:00
|
|
|
// FIXME: this is still global when it shouldn't be
|
|
|
|
static ShadowRenderer *get_shadow_renderer()
|
|
|
|
{
|
2022-01-31 22:48:14 +01:00
|
|
|
if (s_singleton && s_singleton->core)
|
|
|
|
return s_singleton->core->get_shadow_renderer();
|
2021-06-06 18:51:21 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2017-06-26 20:11:17 +02:00
|
|
|
static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
|
|
|
|
|
2023-04-14 21:04:03 +02:00
|
|
|
static void autosaveScreensizeAndCo(
|
|
|
|
const irr::core::dimension2d<u32> initial_screen_size,
|
|
|
|
const bool initial_window_maximized);
|
|
|
|
|
2017-06-26 20:11:17 +02:00
|
|
|
private:
|
2021-04-28 12:48:13 +02:00
|
|
|
v2u32 _getWindowSize() const;
|
2017-06-26 20:11:17 +02:00
|
|
|
|
2017-10-31 19:27:10 +01:00
|
|
|
std::unique_ptr<RenderingCore> core;
|
2017-06-26 20:11:17 +02:00
|
|
|
irr::IrrlichtDevice *m_device = nullptr;
|
2017-10-31 19:27:10 +01:00
|
|
|
irr::video::IVideoDriver *driver;
|
2017-06-26 20:11:17 +02:00
|
|
|
static RenderingEngine *s_singleton;
|
|
|
|
};
|