Luanti 5.17.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
92 {
94 return s_singleton->_getWindowSize();
95 }
96
97 io::IFileSystem *get_filesystem()
98 {
99 return m_device->getFileSystem();
100 }
101
102 static video::IVideoDriver *get_video_driver()
103 {
105 return s_singleton->m_device->getVideoDriver();
106 }
107
108 scene::ISceneManager *get_scene_manager()
109 {
110 return m_device->getSceneManager();
111 }
112
113 static IrrlichtDevice *get_raw_device()
114 {
116 return s_singleton->m_device;
117 }
118
119 gui::IGUIEnvironment *get_gui_env()
120 {
121 return m_device->getGUIEnvironment();
122 }
123
124 // If "indef_pos" is given, the value of "percent" is ignored and an indefinite
125 // progress bar is drawn.
126 void draw_load_screen(const std::wstring &text,
127 gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
128 float dtime = 0, int percent = 0, float *indef_pos = nullptr,
129 const std::wstring &bottom_text = {});
130
131 void draw_scene(video::SColor skycolor, bool show_hud,
132 bool draw_wield_tool, bool draw_crosshair);
133
134 void initialize(Client *client, Hud *hud);
135 void finalize();
136
137 bool run()
138 {
139 return m_device->run();
140 }
141
142 // FIXME: this is still global when it shouldn't be
144 {
145 if (s_singleton && s_singleton->core)
146 return s_singleton->core->get_shadow_renderer();
147 return nullptr;
148 }
149 static std::vector<video::E_DRIVER_TYPE> getSupportedVideoDrivers();
150
151 static void autosaveScreensizeAndCo(
152 const core::dimension2d<u32> initial_screen_size,
153 const bool initial_window_maximized);
154
156 {
157 sanity_check(s_singleton && s_singleton->m_receiver);
158 return s_singleton->m_receiver->getLastPointerType();
159 }
160
161 video::SColor m_menu_sky_color = video::SColor(255, 140, 186, 250);
162 video::SColor m_menu_clouds_color = video::SColor(255, 240, 240, 255);
163
164private:
165 static void settingChangedCallback(const std::string &name, void *data);
166 v2u32 _getWindowSize() const;
167
168 std::unique_ptr<RenderingCore> core;
169 IrrlichtDevice *m_device = nullptr;
170 video::IVideoDriver *driver;
173};
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:27
Definition core.h:20
static ShadowRenderer * get_shadow_renderer()
Definition renderingengine.h:143
IrrlichtDevice * m_device
Definition renderingengine.h:169
static RenderingEngine * s_singleton
Definition renderingengine.h:172
bool setWindowIcon()
Definition renderingengine.cpp:275
video::IVideoDriver * driver
Definition renderingengine.h:170
~RenderingEngine()
Definition renderingengine.cpp:224
static void showErrorMessageBox(const std::string &message)
Definition renderingengine.cpp:428
static PointerType getLastPointerType()
Definition renderingengine.h:155
void initialize(Client *client, Hud *hud)
Definition renderingengine.cpp:400
RenderingEngine(MyEventReceiver *eventReceiver)
Definition renderingengine.cpp:160
void cleanupMeshCache()
Definition renderingengine.cpp:264
static std::vector< video::E_DRIVER_TYPE > getSupportedVideoDrivers()
Definition renderingengine.cpp:380
video::SColor m_menu_sky_color
Definition renderingengine.h:161
static video::IVideoDriver * get_video_driver()
Definition renderingengine.h:102
scene::ISceneManager * get_scene_manager()
Definition renderingengine.h:108
static float getDisplayDensity()
Definition renderingengine.cpp:434
static void settingChangedCallback(const std::string &name, void *data)
Definition renderingengine.cpp:236
static IrrlichtDevice * get_raw_device()
Definition renderingengine.h:113
video::IVideoDriver * getVideoDriver()
Definition renderingengine.h:71
void draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime=0, int percent=0, float *indef_pos=nullptr, const std::wstring &bottom_text={})
Definition renderingengine.cpp:292
video::SColor m_menu_clouds_color
Definition renderingengine.h:162
io::IFileSystem * get_filesystem()
Definition renderingengine.h:97
void draw_scene(video::SColor skycolor, bool show_hud, bool draw_wield_tool, bool draw_crosshair)
Definition renderingengine.cpp:411
static void autosaveScreensizeAndCo(const core::dimension2d< u32 > initial_screen_size, const bool initial_window_maximized)
Definition renderingengine.cpp:447
static const VideoDriverInfo & getVideoDriverInfo(video::E_DRIVER_TYPE type)
Definition renderingengine.cpp:417
gui::IGUIEnvironment * get_gui_env()
Definition renderingengine.h:119
void setResizable(bool resize)
Definition renderingengine.cpp:259
void finalize()
Definition renderingengine.cpp:406
bool run()
Definition renderingengine.h:137
v2u32 _getWindowSize() const
Definition renderingengine.cpp:252
bool setupTopLevelWindow()
Definition renderingengine.cpp:270
static v2u32 getWindowSize()
This takes 3d_mode into account - side-by-side will return a halved horizontal size.
Definition renderingengine.h:91
MyEventReceiver * m_receiver
Definition renderingengine.h:171
Definition dynamicshadowsrender.h:42
gui::IGUIEnvironment * guienv
Definition clientlauncher.cpp:36
#define sanity_check(expr)
Definition debug.h:55
PointerType
Definition inputhandler.h:21
core::vector2d< u32 > v2u32
Definition irr_v2d.h:14
Definition printing.h:10
@ Client
Definition s_base.h:45
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