diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-05-29 13:40:00 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-05-29 13:40:21 -0300 |
commit | 4f100f92d859848f44c972c08e7fbf37c04e8d3e (patch) | |
tree | 988ebf8014e22d2ded723d79e91e990c2c9bd1f9 /platform | |
parent | d31696e3dbe54111cfcf444abf854a55c94bdb76 (diff) |
DPI Detection support
Windows only for now.
Many builds may break (older visual studio, mingw32)
Diffstat (limited to 'platform')
-rw-r--r-- | platform/windows/detect.py | 4 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 23 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 3 |
3 files changed, 27 insertions, 3 deletions
diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 97d2461e58..795c49a7f5 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -243,7 +243,7 @@ def configure(env): env.Append(CCFLAGS=['/DGLES2_ENABLED']) env.Append(CCFLAGS=['/DGLEW_ENABLED']) - LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid'] + LIBS=['winmm','opengl32','dsound','kernel32','ole32','oleaut32','user32','gdi32', 'IPHLPAPI','Shcore','Shlwapi', 'wsock32', 'shell32','advapi32','dinput8','dxguid'] env.Append(LINKFLAGS=[p+env["LIBSUFFIX"] for p in LIBS]) env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"]) @@ -370,7 +370,7 @@ def configure(env): env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows']) env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED']) env.Append(CCFLAGS=['-DGLES2_ENABLED','-DGLEW_ENABLED']) - env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','shlwapi','wsock32','kernel32', 'oleaut32', 'dinput8', 'dxguid']) + env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','iphlpapi','shlwapi','wsock32','shcore','kernel32', 'oleaut32', 'dinput8', 'dxguid']) # if (env["bits"]=="32"): # env.Append(LIBS=['gcc_s']) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index bf8b0ee6b5..8bb5de5d5d 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -57,6 +57,13 @@ #include <regstr.h> #include <process.h> +#if (_MSC_VER >= 1700) +#define HIDPI_SUPPORT +#endif + +#ifdef HIDPI_SUPPORT +#include <ShellScalingAPI.h> +#endif static const WORD MAX_CONSOLE_LINES = 1500; extern "C" { @@ -854,7 +861,13 @@ BOOL CALLBACK OS_Windows::MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPR minfo.rect.pos.y=lprcMonitor->top; minfo.rect.size.x=lprcMonitor->right - lprcMonitor->left; minfo.rect.size.y=lprcMonitor->bottom - lprcMonitor->top; - +#ifdef HIDPI_SUPPORT + UINT dpix,dpiy; + GetDpiForMonitor(hMonitor,MDT_EFFECTIVE_DPI,&dpix,&dpiy); + minfo.dpi=(dpix + dpiy)/2; +#else + minfo.dpi=72; +#endif self->monitor_info.push_back(minfo); return TRUE; @@ -1366,6 +1379,14 @@ Size2 OS_Windows::get_screen_size(int p_screen) const{ return Vector2( monitor_info[p_screen].rect.size ); } + +int OS_Windows::get_screen_dpi(int p_screen) const { + + ERR_FAIL_INDEX_V(p_screen,monitor_info.size(),72); + UINT dpix,dpiy; + return monitor_info[p_screen].dpi; + +} Point2 OS_Windows::get_window_position() const{ RECT r; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 810da1b3cd..6dd5b78bfd 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -172,6 +172,7 @@ protected: HMONITOR hMonitor; HDC hdcMonitor; Rect2 rect; + int dpi; }; @@ -213,6 +214,8 @@ public: virtual void set_current_screen(int p_screen); virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; + virtual int get_screen_dpi(int p_screen=0) const; + virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; |