@@ -45,7 +45,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
45
45
#include < X11/Xlib.h>
46
46
#include < X11/Xutil.h>
47
47
#include < X11/Xatom.h>
48
+ #endif
48
49
50
+ #ifdef _WIN32
51
+ #include < windows.h>
52
+ #include < winuser.h>
49
53
#endif
50
54
51
55
#if ENABLE_GLES
@@ -318,6 +322,28 @@ void RenderingEngine::setupTopLevelXorgWindow(const std::string &name)
318
322
#endif
319
323
}
320
324
325
+ #ifdef _WIN32
326
+ static bool getWindowHandle (irr::video::IVideoDriver *driver, HWND &hWnd)
327
+ {
328
+ const video::SExposedVideoData exposedData = driver->getExposedVideoData ();
329
+
330
+ switch (driver->getDriverType ()) {
331
+ case video::EDT_DIRECT3D8:
332
+ hWnd = reinterpret_cast <HWND>(exposedData.D3D8 .HWnd );
333
+ break ;
334
+ case video::EDT_DIRECT3D9:
335
+ hWnd = reinterpret_cast <HWND>(exposedData.D3D9 .HWnd );
336
+ break ;
337
+ case video::EDT_OPENGL:
338
+ hWnd = reinterpret_cast <HWND>(exposedData.OpenGLWin32 .HWnd );
339
+ break ;
340
+ default :
341
+ return false ;
342
+ }
343
+
344
+ return true ;
345
+ }
346
+ #endif
321
347
322
348
bool RenderingEngine::setWindowIcon ()
323
349
{
@@ -335,22 +361,9 @@ bool RenderingEngine::setWindowIcon()
335
361
" -xorg-icon-128.png" );
336
362
#endif
337
363
#elif defined(_WIN32)
338
- const video::SExposedVideoData exposedData = driver->getExposedVideoData ();
339
364
HWND hWnd; // Window handle
340
-
341
- switch (driver->getDriverType ()) {
342
- case video::EDT_DIRECT3D8:
343
- hWnd = reinterpret_cast <HWND>(exposedData.D3D8 .HWnd );
344
- break ;
345
- case video::EDT_DIRECT3D9:
346
- hWnd = reinterpret_cast <HWND>(exposedData.D3D9 .HWnd );
347
- break ;
348
- case video::EDT_OPENGL:
349
- hWnd = reinterpret_cast <HWND>(exposedData.OpenGLWin32 .HWnd );
350
- break ;
351
- default :
365
+ if (!getWindowHandle (driver, hWnd))
352
366
return false ;
353
- }
354
367
355
368
// Load the ICON from resource file
356
369
const HICON hicon = LoadIcon (GetModuleHandle (NULL ),
@@ -632,7 +645,7 @@ const char *RenderingEngine::getVideoDriverFriendlyName(irr::video::E_DRIVER_TYP
632
645
}
633
646
634
647
#ifndef __ANDROID__
635
- #ifdef XORG_USED
648
+ #if defined( XORG_USED)
636
649
637
650
static float calcDisplayDensity ()
638
651
{
@@ -667,12 +680,42 @@ float RenderingEngine::getDisplayDensity()
667
680
return cached_display_density;
668
681
}
669
682
670
- #else // XORG_USED
683
+ #elif defined(_WIN32)
684
+
685
+
686
+ static float calcDisplayDensity (irr::video::IVideoDriver *driver)
687
+ {
688
+ HWND hWnd;
689
+ if (getWindowHandle (driver, hWnd)) {
690
+ HDC hdc = GetDC (hWnd);
691
+ float dpi = GetDeviceCaps (hdc, LOGPIXELSX);
692
+ ReleaseDC (hWnd, hdc);
693
+ return dpi / 96 .0f ;
694
+ }
695
+
696
+ /* return manually specified dpi */
697
+ return g_settings->getFloat (" screen_dpi" ) / 96 .0f ;
698
+ }
699
+
700
+ float RenderingEngine::getDisplayDensity ()
701
+ {
702
+ static bool cached = false ;
703
+ static float display_density;
704
+ if (!cached) {
705
+ display_density = calcDisplayDensity (get_video_driver ());
706
+ cached = true ;
707
+ }
708
+ return display_density;
709
+ }
710
+
711
+ #else
712
+
671
713
float RenderingEngine::getDisplayDensity ()
672
714
{
673
715
return g_settings->getFloat (" screen_dpi" ) / 96.0 ;
674
716
}
675
- #endif // XORG_USED
717
+
718
+ #endif
676
719
677
720
v2u32 RenderingEngine::getDisplaySize ()
678
721
{