]> git.lizzy.rs Git - minetest.git/blob - src/client/renderingengine.h
b477da0273c2279099054d7435500d22784f6dc5
[minetest.git] / src / client / renderingengine.h
1 /*
2 Minetest
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 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #pragma once
22
23 #include <vector>
24 #include <memory>
25 #include <string>
26 #include "irrlichttypes_extrabloated.h"
27 #include "debug.h"
28 #include "client/render/core.h"
29 // include the shadow mapper classes too
30 #include "client/shadows/dynamicshadowsrender.h"
31
32 struct VideoDriverInfo {
33         std::string name;
34         std::string friendly_name;
35 };
36
37 class ITextureSource;
38 class Camera;
39 class Client;
40 class LocalPlayer;
41 class Hud;
42 class Minimap;
43
44 class RenderingCore;
45
46 class RenderingEngine
47 {
48 public:
49         static const float BASE_BLOOM_STRENGTH;
50
51         RenderingEngine(IEventReceiver *eventReceiver);
52         ~RenderingEngine();
53
54         void setResizable(bool resize);
55
56         video::IVideoDriver *getVideoDriver() { return driver; }
57
58         static const VideoDriverInfo &getVideoDriverInfo(irr::video::E_DRIVER_TYPE type);
59         static float getDisplayDensity();
60
61         bool setupTopLevelWindow(const std::string &name);
62         void setupTopLevelXorgWindow(const std::string &name);
63         bool setWindowIcon();
64         bool setXorgWindowIconFromPath(const std::string &icon_file);
65         static bool print_video_modes();
66         void cleanupMeshCache();
67
68         void removeMesh(const scene::IMesh* mesh);
69
70         static v2u32 getWindowSize()
71         {
72                 sanity_check(s_singleton);
73                 return s_singleton->_getWindowSize();
74         }
75
76         io::IFileSystem *get_filesystem()
77         {
78                 return m_device->getFileSystem();
79         }
80
81         static video::IVideoDriver *get_video_driver()
82         {
83                 sanity_check(s_singleton && s_singleton->m_device);
84                 return s_singleton->m_device->getVideoDriver();
85         }
86
87         scene::ISceneManager *get_scene_manager()
88         {
89                 return m_device->getSceneManager();
90         }
91
92         static irr::IrrlichtDevice *get_raw_device()
93         {
94                 sanity_check(s_singleton && s_singleton->m_device);
95                 return s_singleton->m_device;
96         }
97
98         u32 get_timer_time()
99         {
100                 return m_device->getTimer()->getTime();
101         }
102
103         gui::IGUIEnvironment *get_gui_env()
104         {
105                 return m_device->getGUIEnvironment();
106         }
107
108         void draw_load_screen(const std::wstring &text,
109                         gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
110                         float dtime = 0, int percent = 0, bool clouds = true);
111
112         void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds);
113         void draw_scene(video::SColor skycolor, bool show_hud,
114                         bool show_minimap, bool draw_wield_tool, bool draw_crosshair);
115
116         void initialize(Client *client, Hud *hud);
117         void finalize();
118
119         bool run()
120         {
121                 return m_device->run();
122         }
123
124         // FIXME: this is still global when it shouldn't be
125         static ShadowRenderer *get_shadow_renderer()
126         {
127                 if (s_singleton && s_singleton->core)
128                         return s_singleton->core->get_shadow_renderer();
129                 return nullptr;
130         }
131         static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
132
133 private:
134         v2u32 _getWindowSize() const;
135
136         std::unique_ptr<RenderingCore> core;
137         irr::IrrlichtDevice *m_device = nullptr;
138         irr::video::IVideoDriver *driver;
139         static RenderingEngine *s_singleton;
140 };