Luanti 5.16.0-dev
Loading...
Searching...
No Matches
renderingengine.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4// Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
5
6#pragma once
7
8#include <vector>
9#include <memory>
10#include <string>
11#include "client/inputhandler.h"
12#include "debug.h"
13#include "config.h"
14#include "client/shader.h"
15#include "client/render/core.h"
16// include the shadow mapper classes too
18#include <IVideoDriver.h>
19
20#if !IS_CLIENT_BUILD
21#error Do not include in server builds
22#endif
23
25 std::string name;
26 std::string friendly_name;
27};
28
29class ITextureSource;
30class Client;
31class Hud;
32
33class RenderingCore;
34
35// Instead of a mechanism to disable fog we just set it to be really far away
36#define FOG_RANGE_ALL (100000 * BS)
37
38/* Helpers */
39
40struct FpsControl {
42
43 void reset();
44
45 void limit(IrrlichtDevice *device, f32 *dtime);
46
47 u32 getBusyMs() const { return busy_time / 1000; }
48
49 // all values in microseconds (us)
51};
52
53// Populates fogColor, fogDistance, fogShadingParameter with values from Irrlicht
55{
56public:
58 virtual IShaderUniformSetter *create(const std::string &name);
59};
60
61/* Rendering engine class */
62
64{
65public:
66 RenderingEngine(MyEventReceiver *eventReceiver);
68
69 void setResizable(bool resize);
70
71 video::IVideoDriver *getVideoDriver() { return driver; }
72
73 static const VideoDriverInfo &getVideoDriverInfo(video::E_DRIVER_TYPE type);
74 static float getDisplayDensity();
75
76 // Show error message box to user. Intended for situations where graphics
77 // output might not even be working.
78 // Will block.
79 static void showErrorMessageBox(const std::string &message);
80
82 bool setWindowIcon();
83 void cleanupMeshCache();
84
85 void removeMesh(const scene::IMesh* mesh);
86
94 {
96 return s_singleton->_getWindowSize();
97 }
98
99 io::IFileSystem *get_filesystem()
100 {
101 return m_device->getFileSystem();
102 }
103
104 static video::IVideoDriver *get_video_driver()
105 {
107 return s_singleton->m_device->getVideoDriver();
108 }
109
110 scene::ISceneManager *get_scene_manager()
111 {
112 return m_device->getSceneManager();
113 }
114
115 static IrrlichtDevice *get_raw_device()
116 {
118 return s_singleton->m_device;
119 }
120
121 gui::IGUIEnvironment *get_gui_env()
122 {
123 return m_device->getGUIEnvironment();
124 }
125
126 // If "indef_pos" is given, the value of "percent" is ignored and an indefinite
127 // progress bar is drawn.
128 void draw_load_screen(const std::wstring &text,
129 gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
130 float dtime = 0, int percent = 0, float *indef_pos = nullptr);
131
132 void draw_scene(video::SColor skycolor, bool show_hud,
133 bool draw_wield_tool, bool draw_crosshair);
134
135 void initialize(Client *client, Hud *hud);
136 void finalize();
137
138 bool run()
139 {
140 return m_device->run();
141 }
142
143 // FIXME: this is still global when it shouldn't be
145 {
146 if (s_singleton && s_singleton->core)
147 return s_singleton->core->get_shadow_renderer();
148 return nullptr;
149 }
150 static std::vector<video::E_DRIVER_TYPE> getSupportedVideoDrivers();
151
152 static void autosaveScreensizeAndCo(
153 const core::dimension2d<u32> initial_screen_size,
154 const bool initial_window_maximized);
155
157 {
158 sanity_check(s_singleton && s_singleton->m_receiver);
159 return s_singleton->m_receiver->getLastPointerType();
160 }
161
162 video::SColor m_menu_sky_color = video::SColor(255, 140, 186, 250);
163 video::SColor m_menu_clouds_color = video::SColor(255, 240, 240, 255);
164
165private:
166 static void settingChangedCallback(const std::string &name, void *data);
167 v2u32 _getWindowSize() const;
168
169 std::unique_ptr<RenderingCore> core;
170 IrrlichtDevice *m_device = nullptr;
171 video::IVideoDriver *driver;
174};
Definition client.h:107
virtual IShaderUniformSetter * create(const std::string &name)
Called to create an uniform setter for a specific shader.
Definition renderingengine.cpp:105
FogShaderUniformSetterFactory()
Definition renderingengine.h:57
Definition hud.h:35
Definition shader.h:74
Definition shader.h:56
Definition texturesource.h:45
Definition inputhandler.h:25
Definition core.h:20
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:297
static ShadowRenderer * get_shadow_renderer()
Definition renderingengine.h:144
IrrlichtDevice * m_device
Definition renderingengine.h:170
static RenderingEngine * s_singleton
Definition renderingengine.h:173
bool setWindowIcon()
Definition renderingengine.cpp:280
video::IVideoDriver * driver
Definition renderingengine.h:171
~RenderingEngine()
Definition renderingengine.cpp:224
static void showErrorMessageBox(const std::string &message)
Definition renderingengine.cpp:423
static PointerType getLastPointerType()
Definition renderingengine.h:156
void initialize(Client *client, Hud *hud)
Definition renderingengine.cpp:395
RenderingEngine(MyEventReceiver *eventReceiver)
Definition renderingengine.cpp:160
void cleanupMeshCache()
Definition renderingengine.cpp:269
static std::vector< video::E_DRIVER_TYPE > getSupportedVideoDrivers()
Definition renderingengine.cpp:375
video::SColor m_menu_sky_color
Definition renderingengine.h:162
static video::IVideoDriver * get_video_driver()
Definition renderingengine.h:104
scene::ISceneManager * get_scene_manager()
Definition renderingengine.h:110
static float getDisplayDensity()
Definition renderingengine.cpp:429
static void settingChangedCallback(const std::string &name, void *data)
Definition renderingengine.cpp:236
static IrrlichtDevice * get_raw_device()
Definition renderingengine.h:115
video::IVideoDriver * getVideoDriver()
Definition renderingengine.h:71
video::SColor m_menu_clouds_color
Definition renderingengine.h:163
io::IFileSystem * get_filesystem()
Definition renderingengine.h:99
void removeMesh(const scene::IMesh *mesh)
Definition renderingengine.cpp:264
void draw_scene(video::SColor skycolor, bool show_hud, bool draw_wield_tool, bool draw_crosshair)
Definition renderingengine.cpp:406
static void autosaveScreensizeAndCo(const core::dimension2d< u32 > initial_screen_size, const bool initial_window_maximized)
Definition renderingengine.cpp:442
static const VideoDriverInfo & getVideoDriverInfo(video::E_DRIVER_TYPE type)
Definition renderingengine.cpp:412
gui::IGUIEnvironment * get_gui_env()
Definition renderingengine.h:121
void setResizable(bool resize)
Definition renderingengine.cpp:259
void finalize()
Definition renderingengine.cpp:401
bool run()
Definition renderingengine.h:138
v2u32 _getWindowSize() const
Definition renderingengine.cpp:252
bool setupTopLevelWindow()
Definition renderingengine.cpp:275
static v2u32 getWindowSize()
This takes 3d_mode into account - side-by-side will return a halved horizontal size.
Definition renderingengine.h:93
MyEventReceiver * m_receiver
Definition renderingengine.h:172
Definition dynamicshadowsrender.h:42
gui::IGUIEnvironment * guienv
Definition clientlauncher.cpp:36
#define sanity_check(expr)
Definition debug.h:55
PointerType
Definition inputhandler.h:19
core::vector2d< u32 > v2u32
Definition irr_v2d.h:14
Definition activeobjectmgr.cpp:11
Definition printing.h:10
void reset()
Definition renderingengine.cpp:33
u64 busy_time
Definition renderingengine.h:50
FpsControl()
Definition renderingengine.h:41
u64 sleep_time
Definition renderingengine.h:50
void limit(IrrlichtDevice *device, f32 *dtime)
Definition renderingengine.cpp:38
u32 getBusyMs() const
Definition renderingengine.h:47
u64 last_time
Definition renderingengine.h:50
Definition renderingengine.h:24
std::string friendly_name
Definition renderingengine.h:26
std::string name
Definition renderingengine.h:25