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.
25 #include "irrlichttypes_extrabloated.h"
38 RenderingEngine(IEventReceiver *eventReceiver);
41 v2u32 getWindowSize() const;
42 void setResizable(bool resize);
44 video::IVideoDriver *getVideoDriver();
46 static const char *getVideoDriverName(irr::video::E_DRIVER_TYPE type);
47 static const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type);
48 static float getDisplayDensity();
49 static v2u32 getDisplaySize();
51 static void setXorgClassHint(const video::SExposedVideoData &video_data,
52 const std::string &name);
54 bool setXorgWindowIconFromPath(const std::string &icon_file);
55 static bool print_video_modes();
57 static RenderingEngine *get_instance() { return s_singleton; }
59 static io::IFileSystem *get_filesystem()
61 sanity_check(s_singleton && s_singleton->m_device);
62 return s_singleton->m_device->getFileSystem();
65 static video::IVideoDriver *get_video_driver()
67 sanity_check(s_singleton && s_singleton->m_device);
68 return s_singleton->m_device->getVideoDriver();
71 static scene::IMeshCache *get_mesh_cache()
73 sanity_check(s_singleton && s_singleton->m_device);
74 return s_singleton->m_device->getSceneManager()->getMeshCache();
77 static scene::ISceneManager *get_scene_manager()
79 sanity_check(s_singleton && s_singleton->m_device);
80 return s_singleton->m_device->getSceneManager();
83 static irr::IrrlichtDevice *get_raw_device()
85 sanity_check(s_singleton && s_singleton->m_device);
86 return s_singleton->m_device;
89 static u32 get_timer_time()
91 sanity_check(s_singleton && s_singleton->m_device &&
92 s_singleton->m_device->getTimer());
93 return s_singleton->m_device->getTimer()->getTime();
96 static gui::IGUIEnvironment *get_gui_env()
98 sanity_check(s_singleton && s_singleton->m_device);
99 return s_singleton->m_device->getGUIEnvironment();
102 inline static void draw_load_screen(const std::wstring &text,
103 gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
104 float dtime = 0, int percent = 0, bool clouds = true)
106 s_singleton->_draw_load_screen(
107 text, guienv, tsrc, dtime, percent, clouds);
110 inline static void draw_scene(Camera *camera, Client *client, LocalPlayer *player,
111 Hud *hud, Minimap *mapper, gui::IGUIEnvironment *guienv,
112 const v2u32 &screensize, const video::SColor &skycolor,
113 bool show_hud, bool show_minimap)
115 s_singleton->_draw_scene(camera, client, player, hud, mapper, guienv,
116 screensize, skycolor, show_hud, show_minimap);
121 sanity_check(s_singleton && s_singleton->m_device);
122 return s_singleton->m_device->run();
125 static std::vector<core::vector3d<u32>> getSupportedVideoModes();
126 static std::vector<irr::video::E_DRIVER_TYPE> getSupportedVideoDrivers();
136 void _draw_load_screen(const std::wstring &text, gui::IGUIEnvironment *guienv,
137 ITextureSource *tsrc, float dtime = 0, int percent = 0,
140 void _draw_scene(Camera *camera, Client *client, LocalPlayer *player, Hud *hud,
141 Minimap *mapper, gui::IGUIEnvironment *guienv,
142 const v2u32 &screensize, const video::SColor &skycolor,
143 bool show_hud, bool show_minimap);
145 void draw_anaglyph_3d_mode(Camera *camera, bool show_hud, Hud *hud,
146 bool draw_wield_tool, Client *client,
147 gui::IGUIEnvironment *guienv);
149 void draw_interlaced_3d_mode(Camera *camera, bool show_hud, Hud *hud,
150 const v2u32 &screensize, bool draw_wield_tool, Client *client,
151 gui::IGUIEnvironment *guienv, const video::SColor &skycolor);
153 void draw_sidebyside_3d_mode(Camera *camera, bool show_hud, Hud *hud,
154 const v2u32 &screensize, bool draw_wield_tool, Client *client,
155 gui::IGUIEnvironment *guienv, const video::SColor &skycolor);
157 void draw_top_bottom_3d_mode(Camera *camera, bool show_hud, Hud *hud,
158 const v2u32 &screensize, bool draw_wield_tool, Client *client,
159 gui::IGUIEnvironment *guienv, const video::SColor &skycolor);
161 void draw_pageflip_3d_mode(Camera *camera, bool show_hud, Hud *hud,
162 const v2u32 &screensize, bool draw_wield_tool, Client *client,
163 gui::IGUIEnvironment *guienv, const video::SColor &skycolor);
165 void draw_plain(Camera *camera, bool show_hud, Hud *hud, const v2u32 &screensize,
166 bool draw_wield_tool, Client *client,
167 gui::IGUIEnvironment *guienv, const video::SColor &skycolor);
169 void init_texture(const v2u32 &screensize, video::ITexture **texture,
172 video::ITexture *draw_image(const v2u32 &screensize, parallax_sign psign,
173 const irr::core::matrix4 &startMatrix,
174 const irr::core::vector3df &focusPoint, bool show_hud,
175 Camera *camera, Hud *hud, bool draw_wield_tool, Client *client,
176 gui::IGUIEnvironment *guienv, const video::SColor &skycolor);
178 video::ITexture *draw_hud(const v2u32 &screensize, bool show_hud, Hud *hud,
179 Client *client, bool draw_crosshair,
180 const video::SColor &skycolor, gui::IGUIEnvironment *guienv,
183 irr::IrrlichtDevice *m_device = nullptr;
184 static RenderingEngine *s_singleton;