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