Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
renderingengine.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation; either version 2.1 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License along
17with this program; if not, write to the Free Software Foundation, Inc.,
1851 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#pragma once
22
23#include <vector>
24#include <memory>
25#include <string>
27#include "debug.h"
28#include "client/shader.h"
29#include "client/render/core.h"
30// include the shadow mapper classes too
32#include <IVideoDriver.h>
33
34#ifdef SERVER
35#error Do not include in server builds
36#endif
37
39 std::string name;
40 std::string friendly_name;
41};
42
43class ITextureSource;
44class Camera;
45class Client;
46class LocalPlayer;
47class Hud;
48class Minimap;
49
50class RenderingCore;
51
52// Instead of a mechanism to disable fog we just set it to be really far away
53#define FOG_RANGE_ALL (100000 * BS)
54
55/* Helpers */
56
57struct FpsControl {
59
60 void reset();
61
62 void limit(IrrlichtDevice *device, f32 *dtime, bool assume_paused = false);
63
64 u32 getBusyMs() const { return busy_time / 1000; }
65
66 // all values in microseconds (us)
68};
69
70// Populates fogColor, fogDistance, fogShadingParameter with values from Irrlicht
77
78/* Rendering engine class */
79
81{
82public:
83 static const video::SColor MENU_SKY_COLOR;
84 static const float BASE_BLOOM_STRENGTH;
85
86 RenderingEngine(IEventReceiver *eventReceiver);
88
89 void setResizable(bool resize);
90
91 video::IVideoDriver *getVideoDriver() { return driver; }
92
93 static const VideoDriverInfo &getVideoDriverInfo(irr::video::E_DRIVER_TYPE type);
94 static float getDisplayDensity();
95
97 bool setWindowIcon();
98 void cleanupMeshCache();
99
100 void removeMesh(const scene::IMesh* mesh);
101
109 {
111 return s_singleton->_getWindowSize();
112 }
113
114 io::IFileSystem *get_filesystem()
115 {
116 return m_device->getFileSystem();
117 }
118
119 static video::IVideoDriver *get_video_driver()
120 {
122 return s_singleton->m_device->getVideoDriver();
123 }
124
125 scene::ISceneManager *get_scene_manager()
126 {
127 return m_device->getSceneManager();
128 }
129
130 static irr::IrrlichtDevice *get_raw_device()
131 {
133 return s_singleton->m_device;
134 }
135
136 gui::IGUIEnvironment *get_gui_env()
137 {
138 return m_device->getGUIEnvironment();
139 }
140
141 // If "indef_pos" is given, the value of "percent" is ignored and an indefinite
142 // progress bar is drawn.
143 void draw_load_screen(const std::wstring &text,
144 gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
145 float dtime = 0, int percent = 0, float *indef_pos = nullptr);
146
147 void draw_scene(video::SColor skycolor, bool show_hud,
148 bool draw_wield_tool, bool draw_crosshair);
149
150 void initialize(Client *client, Hud *hud);
151 void finalize();
152
153 bool run()
154 {
155 return m_device->run();
156 }
157
158 // FIXME: this is still global when it shouldn't be
160 {
163 return nullptr;
164 }
165 static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
166
167 static void autosaveScreensizeAndCo(
168 const irr::core::dimension2d<u32> initial_screen_size,
169 const bool initial_window_maximized);
170
171private:
172 static void settingChangedCallback(const std::string &name, void *data);
173 v2u32 _getWindowSize() const;
174
175 std::unique_ptr<RenderingCore> core;
176 irr::IrrlichtDevice *m_device = nullptr;
177 irr::video::IVideoDriver *driver;
179};
Definition camera.h:83
Definition client.h:119
Definition renderingengine.h:72
virtual IShaderConstantSetter * create()
Definition renderingengine.cpp:122
FogShaderConstantSetterFactory()
Definition renderingengine.h:74
Definition hud.h:36
Definition shader.h:75
Definition shader.h:66
Definition texturesource.h:45
Definition localplayer.h:65
Definition minimap.h:115
Definition core.h:38
ShadowRenderer * get_shadow_renderer()
Definition core.h:66
Definition renderingengine.h:81
static const float BASE_BLOOM_STRENGTH
Definition renderingengine.h:84
void draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime=0, int percent=0, float *indef_pos=nullptr)
Definition renderingengine.cpp:336
static void autosaveScreensizeAndCo(const irr::core::dimension2d< u32 > initial_screen_size, const bool initial_window_maximized)
Definition renderingengine.cpp:474
static ShadowRenderer * get_shadow_renderer()
Definition renderingengine.h:159
irr::IrrlichtDevice * m_device
Definition renderingengine.h:176
static RenderingEngine * s_singleton
Definition renderingengine.h:178
bool setWindowIcon()
Definition renderingengine.cpp:319
~RenderingEngine()
Definition renderingengine.cpp:262
void initialize(Client *client, Hud *hud)
Definition renderingengine.cpp:433
void cleanupMeshCache()
Definition renderingengine.cpp:308
static std::vector< irr::video::E_DRIVER_TYPE > getSupportedVideoDrivers()
Definition renderingengine.cpp:413
static video::IVideoDriver * get_video_driver()
Definition renderingengine.h:119
scene::ISceneManager * get_scene_manager()
Definition renderingengine.h:125
static float getDisplayDensity()
Definition renderingengine.cpp:461
static const VideoDriverInfo & getVideoDriverInfo(irr::video::E_DRIVER_TYPE type)
Definition renderingengine.cpp:450
static void settingChangedCallback(const std::string &name, void *data)
Definition renderingengine.cpp:275
video::IVideoDriver * getVideoDriver()
Definition renderingengine.h:91
static const video::SColor MENU_SKY_COLOR
Definition renderingengine.h:83
RenderingEngine(IEventReceiver *eventReceiver)
Definition renderingengine.cpp:198
irr::video::IVideoDriver * driver
Definition renderingengine.h:177
io::IFileSystem * get_filesystem()
Definition renderingengine.h:114
std::unique_ptr< RenderingCore > core
Definition renderingengine.h:175
void removeMesh(const scene::IMesh *mesh)
Definition renderingengine.cpp:303
void draw_scene(video::SColor skycolor, bool show_hud, bool draw_wield_tool, bool draw_crosshair)
Definition renderingengine.cpp:444
static irr::IrrlichtDevice * get_raw_device()
Definition renderingengine.h:130
gui::IGUIEnvironment * get_gui_env()
Definition renderingengine.h:136
void setResizable(bool resize)
Definition renderingengine.cpp:298
void finalize()
Definition renderingengine.cpp:439
bool run()
Definition renderingengine.h:153
v2u32 _getWindowSize() const
Definition renderingengine.cpp:291
bool setupTopLevelWindow()
Definition renderingengine.cpp:314
static v2u32 getWindowSize()
This takes 3d_mode into account - side-by-side will return a halved horizontal size.
Definition renderingengine.h:108
Definition dynamicshadowsrender.h:54
gui::IGUIEnvironment * guienv
Definition clientlauncher.cpp:47
#define sanity_check(expr)
Definition debug.h:71
core::vector2d< u32 > v2u32
Definition irr_v2d.h:29
Definition activeobjectmgr.cpp:26
Definition renderingengine.h:57
void reset()
Definition renderingengine.cpp:49
u64 busy_time
Definition renderingengine.h:67
FpsControl()
Definition renderingengine.h:58
void limit(IrrlichtDevice *device, f32 *dtime, bool assume_paused=false)
Definition renderingengine.cpp:54
u64 sleep_time
Definition renderingengine.h:67
u32 getBusyMs() const
Definition renderingengine.h:64
u64 last_time
Definition renderingengine.h:67
Definition renderingengine.h:38
std::string friendly_name
Definition renderingengine.h:40
std::string name
Definition renderingengine.h:39