]> git.lizzy.rs Git - dragonfireclient.git/blob - src/client/renderingengine.h
Drop --videomodes, fullscreen_bpp and high_precision_fpu settings
[dragonfireclient.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
33 class ITextureSource;
34 class Camera;
35 class Client;
36 class LocalPlayer;
37 class Hud;
38 class Minimap;
39
40 class RenderingCore;
41
42 class RenderingEngine
43 {
44 public:
45         RenderingEngine(IEventReceiver *eventReceiver);
46         ~RenderingEngine();
47
48         void setResizable(bool resize);
49
50         video::IVideoDriver *getVideoDriver() { return driver; }
51
52         static const char *getVideoDriverName(irr::video::E_DRIVER_TYPE type);
53         static const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type);
54         static float getDisplayDensity();
55         static v2u32 getDisplaySize();
56
57         bool setupTopLevelWindow(const std::string &name);
58         void setupTopLevelXorgWindow(const std::string &name);
59         bool setWindowIcon();
60         bool setXorgWindowIconFromPath(const std::string &icon_file);
61         static bool print_video_modes();
62         void cleanupMeshCache();
63
64         void removeMesh(const scene::IMesh* mesh);
65
66         static v2u32 getWindowSize()
67         {
68                 sanity_check(s_singleton);
69                 return s_singleton->_getWindowSize();
70         }
71
72         io::IFileSystem *get_filesystem()
73         {
74                 return m_device->getFileSystem();
75         }
76
77         static video::IVideoDriver *get_video_driver()
78         {
79                 sanity_check(s_singleton && s_singleton->m_device);
80                 return s_singleton->m_device->getVideoDriver();
81         }
82
83         scene::ISceneManager *get_scene_manager()
84         {
85                 return m_device->getSceneManager();
86         }
87
88         static irr::IrrlichtDevice *get_raw_device()
89         {
90                 sanity_check(s_singleton && s_singleton->m_device);
91                 return s_singleton->m_device;
92         }
93
94         u32 get_timer_time()
95         {
96                 return m_device->getTimer()->getTime();
97         }
98
99         gui::IGUIEnvironment *get_gui_env()
100         {
101                 return m_device->getGUIEnvironment();
102         }
103
104         void draw_load_screen(const std::wstring &text,
105                         gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
106                         float dtime = 0, int percent = 0, bool clouds = true);
107
108         void draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime, bool clouds);
109         void draw_scene(video::SColor skycolor, bool show_hud,
110                         bool show_minimap, bool draw_wield_tool, bool draw_crosshair);
111
112         void initialize(Client *client, Hud *hud);
113         void finalize();
114
115         bool run()
116         {
117                 return m_device->run();
118         }
119
120         // FIXME: this is still global when it shouldn't be
121         static ShadowRenderer *get_shadow_renderer()
122         {
123                 if (s_singleton && s_singleton->core)
124                         return s_singleton->core->get_shadow_renderer();
125                 return nullptr;
126         }
127         static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
128
129 private:
130         v2u32 _getWindowSize() const;
131
132         std::unique_ptr<RenderingCore> core;
133         irr::IrrlichtDevice *m_device = nullptr;
134         irr::video::IVideoDriver *driver;
135         static RenderingEngine *s_singleton;
136 };