3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
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.
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.
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.
26 #include "irrlichttypes_extrabloated.h"
41 RenderingEngine(IEventReceiver *eventReceiver);
44 v2u32 getWindowSize() const;
45 void setResizable(bool resize);
47 video::IVideoDriver *getVideoDriver() { return driver; }
49 static const char *getVideoDriverName(irr::video::E_DRIVER_TYPE type);
50 static const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type);
51 static float getDisplayDensity();
52 static v2u32 getDisplaySize();
54 bool setupTopLevelWindow(const std::string &name);
55 void setupTopLevelXorgWindow(const std::string &name);
57 bool setXorgWindowIconFromPath(const std::string &icon_file);
58 static bool print_video_modes();
60 static RenderingEngine *get_instance() { return s_singleton; }
62 static io::IFileSystem *get_filesystem()
64 sanity_check(s_singleton && s_singleton->m_device);
65 return s_singleton->m_device->getFileSystem();
68 static video::IVideoDriver *get_video_driver()
70 sanity_check(s_singleton && s_singleton->m_device);
71 return s_singleton->m_device->getVideoDriver();
74 static scene::IMeshCache *get_mesh_cache()
76 sanity_check(s_singleton && s_singleton->m_device);
77 return s_singleton->m_device->getSceneManager()->getMeshCache();
80 static scene::ISceneManager *get_scene_manager()
82 sanity_check(s_singleton && s_singleton->m_device);
83 return s_singleton->m_device->getSceneManager();
86 static irr::IrrlichtDevice *get_raw_device()
88 sanity_check(s_singleton && s_singleton->m_device);
89 return s_singleton->m_device;
92 static u32 get_timer_time()
94 sanity_check(s_singleton && s_singleton->m_device &&
95 s_singleton->m_device->getTimer());
96 return s_singleton->m_device->getTimer()->getTime();
99 static gui::IGUIEnvironment *get_gui_env()
101 sanity_check(s_singleton && s_singleton->m_device);
102 return s_singleton->m_device->getGUIEnvironment();
105 inline static void draw_load_screen(const std::wstring &text,
106 gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
107 float dtime = 0, int percent = 0, bool clouds = true)
109 s_singleton->_draw_load_screen(
110 text, guienv, tsrc, dtime, percent, clouds);
113 inline static void draw_menu_scene(
114 gui::IGUIEnvironment *guienv, float dtime, bool clouds)
116 s_singleton->_draw_menu_scene(guienv, dtime, clouds);
119 inline static void draw_scene(video::SColor skycolor, bool show_hud,
120 bool show_minimap, bool draw_wield_tool, bool draw_crosshair)
122 s_singleton->_draw_scene(skycolor, show_hud, show_minimap,
123 draw_wield_tool, draw_crosshair);
126 inline static void initialize(Client *client, Hud *hud)
128 s_singleton->_initialize(client, hud);
131 inline static void finalize() { s_singleton->_finalize(); }
135 sanity_check(s_singleton && s_singleton->m_device);
136 return s_singleton->m_device->run();
139 static std::vector<core::vector3d<u32>> getSupportedVideoModes();
140 static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
143 void _draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv,
144 ITextureSource *tsrc, float dtime = 0, int percent = 0,
147 void _draw_menu_scene(gui::IGUIEnvironment *guienv, float dtime = 0,
150 void _draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap,
151 bool draw_wield_tool, bool draw_crosshair);
153 void _initialize(Client *client, Hud *hud);
157 std::unique_ptr<RenderingCore> core;
158 irr::IrrlichtDevice *m_device = nullptr;
159 irr::video::IVideoDriver *driver;
160 static RenderingEngine *s_singleton;