]> git.lizzy.rs Git - dragonfireclient.git/blob - src/client/renderingengine.cpp
Remove unsupported video drivers (#11395)
[dragonfireclient.git] / src / client / renderingengine.cpp
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 #include <IrrlichtDevice.h>
22 #include <irrlicht.h>
23 #include "fontengine.h"
24 #include "client.h"
25 #include "clouds.h"
26 #include "util/numeric.h"
27 #include "guiscalingfilter.h"
28 #include "localplayer.h"
29 #include "client/hud.h"
30 #include "camera.h"
31 #include "minimap.h"
32 #include "clientmap.h"
33 #include "renderingengine.h"
34 #include "render/core.h"
35 #include "render/factory.h"
36 #include "inputhandler.h"
37 #include "gettext.h"
38 #include "../gui/guiSkin.h"
39
40 #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__) && \
41                 !defined(SERVER) && !defined(__HAIKU__)
42 #define XORG_USED
43 #endif
44 #ifdef XORG_USED
45 #include <X11/Xlib.h>
46 #include <X11/Xutil.h>
47 #include <X11/Xatom.h>
48 #endif
49
50 #ifdef _WIN32
51 #include <windows.h>
52 #include <winuser.h>
53 #endif
54
55 #if ENABLE_GLES
56 #include "filesys.h"
57 #endif
58
59 RenderingEngine *RenderingEngine::s_singleton = nullptr;
60
61
62 static gui::GUISkin *createSkin(gui::IGUIEnvironment *environment,
63                 gui::EGUI_SKIN_TYPE type, video::IVideoDriver *driver)
64 {
65         gui::GUISkin *skin = new gui::GUISkin(type, driver);
66
67         gui::IGUIFont *builtinfont = environment->getBuiltInFont();
68         gui::IGUIFontBitmap *bitfont = nullptr;
69         if (builtinfont && builtinfont->getType() == gui::EGFT_BITMAP)
70                 bitfont = (gui::IGUIFontBitmap*)builtinfont;
71
72         gui::IGUISpriteBank *bank = 0;
73         skin->setFont(builtinfont);
74
75         if (bitfont)
76                 bank = bitfont->getSpriteBank();
77
78         skin->setSpriteBank(bank);
79
80         return skin;
81 }
82
83
84 RenderingEngine::RenderingEngine(IEventReceiver *receiver)
85 {
86         sanity_check(!s_singleton);
87
88         // Resolution selection
89         bool fullscreen = g_settings->getBool("fullscreen");
90         u16 screen_w = g_settings->getU16("screen_w");
91         u16 screen_h = g_settings->getU16("screen_h");
92
93         // bpp, fsaa, vsync
94         bool vsync = g_settings->getBool("vsync");
95         u16 fsaa = g_settings->getU16("fsaa");
96
97         // stereo buffer required for pageflip stereo
98         bool stereo_buffer = g_settings->get("3d_mode") == "pageflip";
99
100         // Determine driver
101         video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
102         const std::string &driverstring = g_settings->get("video_driver");
103         std::vector<video::E_DRIVER_TYPE> drivers =
104                         RenderingEngine::getSupportedVideoDrivers();
105         u32 i;
106         for (i = 0; i != drivers.size(); i++) {
107                 if (!strcasecmp(driverstring.c_str(),
108                                 RenderingEngine::getVideoDriverName(drivers[i]))) {
109                         driverType = drivers[i];
110                         break;
111                 }
112         }
113         if (i == drivers.size()) {
114                 errorstream << "Invalid video_driver specified; "
115                                "defaulting to opengl"
116                             << std::endl;
117         }
118
119         SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
120         if (g_logger.getTraceEnabled())
121                 params.LoggingLevel = irr::ELL_DEBUG;
122         params.DriverType = driverType;
123         params.WindowSize = core::dimension2d<u32>(screen_w, screen_h);
124         params.AntiAlias = fsaa;
125         params.Fullscreen = fullscreen;
126         params.Stencilbuffer = false;
127         params.Stereobuffer = stereo_buffer;
128         params.Vsync = vsync;
129         params.EventReceiver = receiver;
130         params.HighPrecisionFPU = true;
131 #ifdef __ANDROID__
132         params.PrivateData = porting::app_global;
133 #endif
134 #if ENABLE_GLES
135         // there is no standardized path for these on desktop
136         std::string rel_path = std::string("client") + DIR_DELIM
137                         + "shaders" + DIR_DELIM + "Irrlicht";
138         params.OGLES2ShaderPath = (porting::path_share + DIR_DELIM + rel_path + DIR_DELIM).c_str();
139 #endif
140
141         m_device = createDeviceEx(params);
142         driver = m_device->getVideoDriver();
143
144         s_singleton = this;
145
146         auto skin = createSkin(m_device->getGUIEnvironment(),
147                         gui::EGST_WINDOWS_METALLIC, driver);
148         m_device->getGUIEnvironment()->setSkin(skin);
149         skin->drop();
150 }
151
152 RenderingEngine::~RenderingEngine()
153 {
154         core.reset();
155         m_device->closeDevice();
156         s_singleton = nullptr;
157 }
158
159 v2u32 RenderingEngine::_getWindowSize() const
160 {
161         if (core)
162                 return core->getVirtualSize();
163         return m_device->getVideoDriver()->getScreenSize();
164 }
165
166 void RenderingEngine::setResizable(bool resize)
167 {
168         m_device->setResizable(resize);
169 }
170
171 void RenderingEngine::removeMesh(const scene::IMesh* mesh)
172 {
173         m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
174 }
175
176 void RenderingEngine::cleanupMeshCache()
177 {
178         auto mesh_cache = m_device->getSceneManager()->getMeshCache();
179         while (mesh_cache->getMeshCount() != 0) {
180                 if (scene::IAnimatedMesh *mesh = mesh_cache->getMeshByIndex(0))
181                         mesh_cache->removeMesh(mesh);
182         }
183 }
184
185 bool RenderingEngine::setupTopLevelWindow(const std::string &name)
186 {
187         // FIXME: It would make more sense for there to be a switch of some
188         // sort here that would call the correct toplevel setup methods for
189         // the environment Minetest is running in.
190
191         /* Setting Xorg properties for the top level window */
192         setupTopLevelXorgWindow(name);
193
194         /* Setting general properties for the top level window */
195         verbosestream << "Client: Configuring general top level"
196                 << " window properties"
197                 << std::endl;
198         bool result = setWindowIcon();
199
200         return result;
201 }
202
203 void RenderingEngine::setupTopLevelXorgWindow(const std::string &name)
204 {
205 #ifdef XORG_USED
206         const video::SExposedVideoData exposedData = driver->getExposedVideoData();
207
208         Display *x11_dpl = reinterpret_cast<Display *>(exposedData.OpenGLLinux.X11Display);
209         if (x11_dpl == NULL) {
210                 warningstream << "Client: Could not find X11 Display in ExposedVideoData"
211                         << std::endl;
212                 return;
213         }
214
215         verbosestream << "Client: Configuring X11-specific top level"
216                 << " window properties"
217                 << std::endl;
218
219
220         Window x11_win = reinterpret_cast<Window>(exposedData.OpenGLLinux.X11Window);
221
222         // Set application name and class hints. For now name and class are the same.
223         XClassHint *classhint = XAllocClassHint();
224         classhint->res_name = const_cast<char *>(name.c_str());
225         classhint->res_class = const_cast<char *>(name.c_str());
226
227         XSetClassHint(x11_dpl, x11_win, classhint);
228         XFree(classhint);
229
230         // FIXME: In the future WMNormalHints should be set ... e.g see the
231         // gtk/gdk code (gdk/x11/gdksurface-x11.c) for the setup_top_level
232         // method. But for now (as it would require some significant changes)
233         // leave the code as is.
234
235         // The following is borrowed from the above gdk source for setting top
236         // level windows. The source indicates and the Xlib docs suggest that
237         // this will set the WM_CLIENT_MACHINE and WM_LOCAL_NAME. This will not
238         // set the WM_CLIENT_MACHINE to a Fully Qualified Domain Name (FQDN) which is
239         // required by the Extended Window Manager Hints (EWMH) spec when setting
240         // the _NET_WM_PID (see further down) but running Minetest in an env
241         // where the window manager is on another machine from Minetest (therefore
242         // making the PID useless) is not expected to be a problem. Further
243         // more, using gtk/gdk as the model it would seem that not using a FQDN is
244         // not an issue for modern Xorg window managers.
245
246         verbosestream << "Client: Setting Xorg window manager Properties"
247                 << std::endl;
248
249         XSetWMProperties (x11_dpl, x11_win, NULL, NULL, NULL, 0, NULL, NULL, NULL);
250
251         // Set the _NET_WM_PID window property according to the EWMH spec. _NET_WM_PID
252         // (in conjunction with WM_CLIENT_MACHINE) can be used by window managers to
253         // force a shutdown of an application if it doesn't respond to the destroy
254         // window message.
255
256         verbosestream << "Client: Setting Xorg _NET_WM_PID extened window manager property"
257                 << std::endl;
258
259         Atom NET_WM_PID = XInternAtom(x11_dpl, "_NET_WM_PID", false);
260
261         pid_t pid = getpid();
262
263         XChangeProperty(x11_dpl, x11_win, NET_WM_PID,
264                         XA_CARDINAL, 32, PropModeReplace,
265                         reinterpret_cast<unsigned char *>(&pid),1);
266
267         // Set the WM_CLIENT_LEADER window property here. Minetest has only one
268         // window and that window will always be the leader.
269
270         verbosestream << "Client: Setting Xorg WM_CLIENT_LEADER property"
271                 << std::endl;
272
273         Atom WM_CLIENT_LEADER = XInternAtom(x11_dpl, "WM_CLIENT_LEADER", false);
274
275         XChangeProperty (x11_dpl, x11_win, WM_CLIENT_LEADER,
276                 XA_WINDOW, 32, PropModeReplace,
277                 reinterpret_cast<unsigned char *>(&x11_win), 1);
278 #endif
279 }
280
281 #ifdef _WIN32
282 static bool getWindowHandle(irr::video::IVideoDriver *driver, HWND &hWnd)
283 {
284         const video::SExposedVideoData exposedData = driver->getExposedVideoData();
285
286         switch (driver->getDriverType()) {
287 #if ENABLE_GLES
288         case video::EDT_OGLES1:
289         case video::EDT_OGLES2:
290 #endif
291         case video::EDT_OPENGL:
292                 hWnd = reinterpret_cast<HWND>(exposedData.OpenGLWin32.HWnd);
293                 break;
294         default:
295                 return false;
296         }
297
298         return true;
299 }
300 #endif
301
302 bool RenderingEngine::setWindowIcon()
303 {
304 #if defined(XORG_USED)
305 #if RUN_IN_PLACE
306         return setXorgWindowIconFromPath(
307                         porting::path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png");
308 #else
309         // We have semi-support for reading in-place data if we are
310         // compiled with RUN_IN_PLACE. Don't break with this and
311         // also try the path_share location.
312         return setXorgWindowIconFromPath(
313                                ICON_DIR "/hicolor/128x128/apps/" PROJECT_NAME ".png") ||
314                setXorgWindowIconFromPath(porting::path_share + "/misc/" PROJECT_NAME
315                                                                "-xorg-icon-128.png");
316 #endif
317 #elif defined(_WIN32)
318         HWND hWnd; // Window handle
319         if (!getWindowHandle(driver, hWnd))
320                 return false;
321
322         // Load the ICON from resource file
323         const HICON hicon = LoadIcon(GetModuleHandle(NULL),
324                         MAKEINTRESOURCE(130) // The ID of the ICON defined in
325                                              // winresource.rc
326         );
327
328         if (hicon) {
329                 SendMessage(hWnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hicon));
330                 SendMessage(hWnd, WM_SETICON, ICON_SMALL,
331                                 reinterpret_cast<LPARAM>(hicon));
332                 return true;
333         }
334         return false;
335 #else
336         return false;
337 #endif
338 }
339
340 bool RenderingEngine::setXorgWindowIconFromPath(const std::string &icon_file)
341 {
342 #ifdef XORG_USED
343
344         video::IImageLoader *image_loader = NULL;
345         u32 cnt = driver->getImageLoaderCount();
346         for (u32 i = 0; i < cnt; i++) {
347                 if (driver->getImageLoader(i)->isALoadableFileExtension(
348                                     icon_file.c_str())) {
349                         image_loader = driver->getImageLoader(i);
350                         break;
351                 }
352         }
353
354         if (!image_loader) {
355                 warningstream << "Could not find image loader for file '" << icon_file
356                               << "'" << std::endl;
357                 return false;
358         }
359
360         io::IReadFile *icon_f =
361                         m_device->getFileSystem()->createAndOpenFile(icon_file.c_str());
362
363         if (!icon_f) {
364                 warningstream << "Could not load icon file '" << icon_file << "'"
365                               << std::endl;
366                 return false;
367         }
368
369         video::IImage *img = image_loader->loadImage(icon_f);
370
371         if (!img) {
372                 warningstream << "Could not load icon file '" << icon_file << "'"
373                               << std::endl;
374                 icon_f->drop();
375                 return false;
376         }
377
378         u32 height = img->getDimension().Height;
379         u32 width = img->getDimension().Width;
380
381         size_t icon_buffer_len = 2 + height * width;
382         long *icon_buffer = new long[icon_buffer_len];
383
384         icon_buffer[0] = width;
385         icon_buffer[1] = height;
386
387         for (u32 x = 0; x < width; x++) {
388                 for (u32 y = 0; y < height; y++) {
389                         video::SColor col = img->getPixel(x, y);
390                         long pixel_val = 0;
391                         pixel_val |= (u8)col.getAlpha() << 24;
392                         pixel_val |= (u8)col.getRed() << 16;
393                         pixel_val |= (u8)col.getGreen() << 8;
394                         pixel_val |= (u8)col.getBlue();
395                         icon_buffer[2 + x + y * width] = pixel_val;
396                 }
397         }
398
399         img->drop();
400         icon_f->drop();
401
402         const video::SExposedVideoData &video_data = driver->getExposedVideoData();
403
404         Display *x11_dpl = (Display *)video_data.OpenGLLinux.X11Display;
405
406         if (x11_dpl == NULL) {
407                 warningstream << "Could not find x11 display for setting its icon."
408                               << std::endl;
409                 delete[] icon_buffer;
410                 return false;
411         }
412
413         Window x11_win = (Window)video_data.OpenGLLinux.X11Window;
414
415         Atom net_wm_icon = XInternAtom(x11_dpl, "_NET_WM_ICON", False);
416         Atom cardinal = XInternAtom(x11_dpl, "CARDINAL", False);
417         XChangeProperty(x11_dpl, x11_win, net_wm_icon, cardinal, 32, PropModeReplace,
418                         (const unsigned char *)icon_buffer, icon_buffer_len);
419
420         delete[] icon_buffer;
421
422 #endif
423         return true;
424 }
425
426 /*
427         Draws a screen with a single text on it.
428         Text will be removed when the screen is drawn the next time.
429         Additionally, a progressbar can be drawn when percent is set between 0 and 100.
430 */
431 void RenderingEngine::draw_load_screen(const std::wstring &text,
432                 gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime,
433                 int percent, bool clouds)
434 {
435         v2u32 screensize = getWindowSize();
436
437         v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight());
438         v2s32 center(screensize.X / 2, screensize.Y / 2);
439         core::rect<s32> textrect(center - textsize / 2, center + textsize / 2);
440
441         gui::IGUIStaticText *guitext =
442                         guienv->addStaticText(text.c_str(), textrect, false, false);
443         guitext->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
444
445         bool cloud_menu_background = clouds && g_settings->getBool("menu_clouds");
446         if (cloud_menu_background) {
447                 g_menuclouds->step(dtime * 3);
448                 g_menuclouds->render();
449                 get_video_driver()->beginScene(
450                                 true, true, video::SColor(255, 140, 186, 250));
451                 g_menucloudsmgr->drawAll();
452         } else
453                 get_video_driver()->beginScene(true, true, video::SColor(255, 0, 0, 0));
454
455         // draw progress bar
456         if ((percent >= 0) && (percent <= 100)) {
457                 video::ITexture *progress_img = tsrc->getTexture("progress_bar.png");
458                 video::ITexture *progress_img_bg =
459                                 tsrc->getTexture("progress_bar_bg.png");
460
461                 if (progress_img && progress_img_bg) {
462 #ifndef __ANDROID__
463                         const core::dimension2d<u32> &img_size =
464                                         progress_img_bg->getSize();
465                         u32 imgW = rangelim(img_size.Width, 200, 600);
466                         u32 imgH = rangelim(img_size.Height, 24, 72);
467 #else
468                         const core::dimension2d<u32> img_size(256, 48);
469                         float imgRatio = (float)img_size.Height / img_size.Width;
470                         u32 imgW = screensize.X / 2.2f;
471                         u32 imgH = floor(imgW * imgRatio);
472 #endif
473                         v2s32 img_pos((screensize.X - imgW) / 2,
474                                         (screensize.Y - imgH) / 2);
475
476                         draw2DImageFilterScaled(get_video_driver(), progress_img_bg,
477                                         core::rect<s32>(img_pos.X, img_pos.Y,
478                                                         img_pos.X + imgW,
479                                                         img_pos.Y + imgH),
480                                         core::rect<s32>(0, 0, img_size.Width,
481                                                         img_size.Height),
482                                         0, 0, true);
483
484                         draw2DImageFilterScaled(get_video_driver(), progress_img,
485                                         core::rect<s32>(img_pos.X, img_pos.Y,
486                                                         img_pos.X + (percent * imgW) / 100,
487                                                         img_pos.Y + imgH),
488                                         core::rect<s32>(0, 0,
489                                                         (percent * img_size.Width) / 100,
490                                                         img_size.Height),
491                                         0, 0, true);
492                 }
493         }
494
495         guienv->drawAll();
496         get_video_driver()->endScene();
497         guitext->remove();
498 }
499
500 /*
501         Draws the menu scene including (optional) cloud background.
502 */
503 void RenderingEngine::draw_menu_scene(gui::IGUIEnvironment *guienv,
504                 float dtime, bool clouds)
505 {
506         bool cloud_menu_background = clouds && g_settings->getBool("menu_clouds");
507         if (cloud_menu_background) {
508                 g_menuclouds->step(dtime * 3);
509                 g_menuclouds->render();
510                 get_video_driver()->beginScene(
511                                 true, true, video::SColor(255, 140, 186, 250));
512                 g_menucloudsmgr->drawAll();
513         } else
514                 get_video_driver()->beginScene(true, true, video::SColor(255, 0, 0, 0));
515
516         guienv->drawAll();
517         get_video_driver()->endScene();
518 }
519
520 std::vector<irr::video::E_DRIVER_TYPE> RenderingEngine::getSupportedVideoDrivers()
521 {
522         // Only check these drivers.
523         // We do not support software and D3D in any capacity.
524         static const irr::video::E_DRIVER_TYPE glDrivers[4] = {
525                 irr::video::EDT_NULL,
526                 irr::video::EDT_OPENGL,
527                 irr::video::EDT_OGLES1,
528                 irr::video::EDT_OGLES2,
529         };
530         std::vector<irr::video::E_DRIVER_TYPE> drivers;
531
532         for (int i = 0; i < 4; i++) {
533                 if (irr::IrrlichtDevice::isDriverSupported(glDrivers[i]))
534                         drivers.push_back(glDrivers[i]);
535         }
536
537         return drivers;
538 }
539
540 void RenderingEngine::initialize(Client *client, Hud *hud)
541 {
542         const std::string &draw_mode = g_settings->get("3d_mode");
543         core.reset(createRenderingCore(draw_mode, m_device, client, hud));
544         core->initialize();
545 }
546
547 void RenderingEngine::finalize()
548 {
549         core.reset();
550 }
551
552 void RenderingEngine::draw_scene(video::SColor skycolor, bool show_hud,
553                 bool show_minimap, bool draw_wield_tool, bool draw_crosshair)
554 {
555         core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair);
556 }
557
558 const char *RenderingEngine::getVideoDriverName(irr::video::E_DRIVER_TYPE type)
559 {
560         static const std::unordered_map<irr::video::E_DRIVER_TYPE,const std::string> driver_ids = {
561                 {irr::video::EDT_NULL, "null"},
562                 {irr::video::EDT_OPENGL, "opengl"},
563                 {irr::video::EDT_OGLES1, "ogles1"},
564                 {irr::video::EDT_OGLES2, "ogles2"},
565         };
566
567         return driver_ids.at(type).c_str();
568 }
569
570 const char *RenderingEngine::getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type)
571 {
572         static const std::unordered_map<irr::video::E_DRIVER_TYPE,const std::string> driver_names = {
573                 {irr::video::EDT_NULL, "NULL Driver"},
574                 {irr::video::EDT_OPENGL, "OpenGL"},
575                 {irr::video::EDT_OGLES1, "OpenGL ES1"},
576                 {irr::video::EDT_OGLES2, "OpenGL ES2"},
577         };
578
579         return driver_names.at(type).c_str();
580 }
581
582 #ifndef __ANDROID__
583 #if defined(XORG_USED)
584
585 static float calcDisplayDensity()
586 {
587         const char *current_display = getenv("DISPLAY");
588
589         if (current_display != NULL) {
590                 Display *x11display = XOpenDisplay(current_display);
591
592                 if (x11display != NULL) {
593                         /* try x direct */
594                         int dh = DisplayHeight(x11display, 0);
595                         int dw = DisplayWidth(x11display, 0);
596                         int dh_mm = DisplayHeightMM(x11display, 0);
597                         int dw_mm = DisplayWidthMM(x11display, 0);
598                         XCloseDisplay(x11display);
599
600                         if (dh_mm != 0 && dw_mm != 0) {
601                                 float dpi_height = floor(dh / (dh_mm * 0.039370) + 0.5);
602                                 float dpi_width = floor(dw / (dw_mm * 0.039370) + 0.5);
603                                 return std::max(dpi_height, dpi_width) / 96.0;
604                         }
605                 }
606         }
607
608         /* return manually specified dpi */
609         return g_settings->getFloat("screen_dpi") / 96.0;
610 }
611
612 float RenderingEngine::getDisplayDensity()
613 {
614         static float cached_display_density = calcDisplayDensity();
615         return cached_display_density;
616 }
617
618 #elif defined(_WIN32)
619
620
621 static float calcDisplayDensity(irr::video::IVideoDriver *driver)
622 {
623         HWND hWnd;
624         if (getWindowHandle(driver, hWnd)) {
625                 HDC hdc = GetDC(hWnd);
626                 float dpi = GetDeviceCaps(hdc, LOGPIXELSX);
627                 ReleaseDC(hWnd, hdc);
628                 return dpi / 96.0f;
629         }
630
631         /* return manually specified dpi */
632         return g_settings->getFloat("screen_dpi") / 96.0f;
633 }
634
635 float RenderingEngine::getDisplayDensity()
636 {
637         static bool cached = false;
638         static float display_density;
639         if (!cached) {
640                 display_density = calcDisplayDensity(get_video_driver());
641                 cached = true;
642         }
643         return display_density;
644 }
645
646 #else
647
648 float RenderingEngine::getDisplayDensity()
649 {
650         return g_settings->getFloat("screen_dpi") / 96.0;
651 }
652
653 #endif
654
655 v2u32 RenderingEngine::getDisplaySize()
656 {
657         IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL);
658
659         core::dimension2d<u32> deskres =
660                         nulldevice->getVideoModeList()->getDesktopResolution();
661         nulldevice->drop();
662
663         return deskres;
664 }
665
666 #else // __ANDROID__
667 float RenderingEngine::getDisplayDensity()
668 {
669         return porting::getDisplayDensity();
670 }
671
672 v2u32 RenderingEngine::getDisplaySize()
673 {
674         return porting::getDisplaySize();
675 }
676 #endif // __ANDROID__