Luanti 5.10.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"
13#include "debug.h"
14#include "config.h"
15#include "client/shader.h"
16#include "client/render/core.h"
17// include the shadow mapper classes too
19#include <IVideoDriver.h>
20
21#if !IS_CLIENT_BUILD
22#error Do not include in server builds
23#endif
24
26 std::string name;
27 std::string friendly_name;
28};
29
30class ITextureSource;
31class Camera;
32class Client;
33class LocalPlayer;
34class Hud;
35class Minimap;
36
37class RenderingCore;
38
39// Instead of a mechanism to disable fog we just set it to be really far away
40#define FOG_RANGE_ALL (100000 * BS)
41
42/* Helpers */
43
44struct FpsControl {
46
47 void reset();
48
49 void limit(IrrlichtDevice *device, f32 *dtime, bool assume_paused = false);
50
51 u32 getBusyMs() const { return busy_time / 1000; }
52
53 // all values in microseconds (us)
55};
56
57// Populates fogColor, fogDistance, fogShadingParameter with values from Irrlicht
64
65/* Rendering engine class */
66
68{
69public:
70 static const video::SColor MENU_SKY_COLOR;
71
72 RenderingEngine(MyEventReceiver *eventReceiver);
74
75 void setResizable(bool resize);
76
77 video::IVideoDriver *getVideoDriver() { return driver; }
78
79 static const VideoDriverInfo &getVideoDriverInfo(irr::video::E_DRIVER_TYPE type);
80 static float getDisplayDensity();
81
83 bool setWindowIcon();
84 void cleanupMeshCache();
85
86 void removeMesh(const scene::IMesh* mesh);
87
99
100 io::IFileSystem *get_filesystem()
101 {
102 return m_device->getFileSystem();
103 }
104
105 static video::IVideoDriver *get_video_driver()
106 {
108 return s_singleton->m_device->getVideoDriver();
109 }
110
111 scene::ISceneManager *get_scene_manager()
112 {
113 return m_device->getSceneManager();
114 }
115
116 static irr::IrrlichtDevice *get_raw_device()
117 {
119 return s_singleton->m_device;
120 }
121
122 gui::IGUIEnvironment *get_gui_env()
123 {
124 return m_device->getGUIEnvironment();
125 }
126
127 // If "indef_pos" is given, the value of "percent" is ignored and an indefinite
128 // progress bar is drawn.
129 void draw_load_screen(const std::wstring &text,
130 gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
131 float dtime = 0, int percent = 0, float *indef_pos = nullptr);
132
133 void draw_scene(video::SColor skycolor, bool show_hud,
134 bool draw_wield_tool, bool draw_crosshair);
135
136 void initialize(Client *client, Hud *hud);
137 void finalize();
138
139 bool run()
140 {
141 return m_device->run();
142 }
143
144 // FIXME: this is still global when it shouldn't be
146 {
149 return nullptr;
150 }
151 static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
152
153 static void autosaveScreensizeAndCo(
154 const irr::core::dimension2d<u32> initial_screen_size,
155 const bool initial_window_maximized);
156
162
163private:
164 static void settingChangedCallback(const std::string &name, void *data);
165 v2u32 _getWindowSize() const;
166
167 std::unique_ptr<RenderingCore> core;
168 irr::IrrlichtDevice *m_device = nullptr;
169 irr::video::IVideoDriver *driver;
172};
Definition camera.h:68
Definition client.h:105
Definition renderingengine.h:59
virtual IShaderConstantSetter * create()
Definition renderingengine.cpp:105
FogShaderConstantSetterFactory()
Definition renderingengine.h:61
Definition hud.h:35
Definition shader.h:60
Definition shader.h:51
Definition texturesource.h:36
Definition localplayer.h:49
Definition minimap.h:101
Definition inputhandler.h:123
PointerType getLastPointerType()
Definition inputhandler.h:191
Definition core.h:23
ShadowRenderer * get_shadow_renderer()
Definition core.h:51
Definition renderingengine.h:68
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:294
static void autosaveScreensizeAndCo(const irr::core::dimension2d< u32 > initial_screen_size, const bool initial_window_maximized)
Definition renderingengine.cpp:432
static ShadowRenderer * get_shadow_renderer()
Definition renderingengine.h:145
irr::IrrlichtDevice * m_device
Definition renderingengine.h:168
static RenderingEngine * s_singleton
Definition renderingengine.h:171
bool setWindowIcon()
Definition renderingengine.cpp:277
~RenderingEngine()
Definition renderingengine.cpp:221
static PointerType getLastPointerType()
Definition renderingengine.h:157
void initialize(Client *client, Hud *hud)
Definition renderingengine.cpp:391
RenderingEngine(MyEventReceiver *eventReceiver)
Definition renderingengine.cpp:160
void cleanupMeshCache()
Definition renderingengine.cpp:266
static std::vector< irr::video::E_DRIVER_TYPE > getSupportedVideoDrivers()
Definition renderingengine.cpp:371
static video::IVideoDriver * get_video_driver()
Definition renderingengine.h:105
scene::ISceneManager * get_scene_manager()
Definition renderingengine.h:111
static float getDisplayDensity()
Definition renderingengine.cpp:419
static const VideoDriverInfo & getVideoDriverInfo(irr::video::E_DRIVER_TYPE type)
Definition renderingengine.cpp:408
static void settingChangedCallback(const std::string &name, void *data)
Definition renderingengine.cpp:233
video::IVideoDriver * getVideoDriver()
Definition renderingengine.h:77
static const video::SColor MENU_SKY_COLOR
Definition renderingengine.h:70
irr::video::IVideoDriver * driver
Definition renderingengine.h:169
io::IFileSystem * get_filesystem()
Definition renderingengine.h:100
std::unique_ptr< RenderingCore > core
Definition renderingengine.h:167
void removeMesh(const scene::IMesh *mesh)
Definition renderingengine.cpp:261
void draw_scene(video::SColor skycolor, bool show_hud, bool draw_wield_tool, bool draw_crosshair)
Definition renderingengine.cpp:402
static irr::IrrlichtDevice * get_raw_device()
Definition renderingengine.h:116
gui::IGUIEnvironment * get_gui_env()
Definition renderingengine.h:122
void setResizable(bool resize)
Definition renderingengine.cpp:256
void finalize()
Definition renderingengine.cpp:397
bool run()
Definition renderingengine.h:139
v2u32 _getWindowSize() const
Definition renderingengine.cpp:249
bool setupTopLevelWindow()
Definition renderingengine.cpp:272
static v2u32 getWindowSize()
This takes 3d_mode into account - side-by-side will return a halved horizontal size.
Definition renderingengine.h:94
MyEventReceiver * m_receiver
Definition renderingengine.h:170
Definition dynamicshadowsrender.h:39
gui::IGUIEnvironment * guienv
Definition clientlauncher.cpp:34
#define sanity_check(expr)
Definition debug.h:56
PointerType
Definition inputhandler.h:14
core::vector2d< u32 > v2u32
Definition irr_v2d.h:14
Definition activeobjectmgr.cpp:11
Definition renderingengine.h:44
void reset()
Definition renderingengine.cpp:32
u64 busy_time
Definition renderingengine.h:54
FpsControl()
Definition renderingengine.h:45
void limit(IrrlichtDevice *device, f32 *dtime, bool assume_paused=false)
Definition renderingengine.cpp:37
u64 sleep_time
Definition renderingengine.h:54
u32 getBusyMs() const
Definition renderingengine.h:51
u64 last_time
Definition renderingengine.h:54
Definition renderingengine.h:25
std::string friendly_name
Definition renderingengine.h:27
std::string name
Definition renderingengine.h:26