summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-05-29 13:40:00 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-05-29 13:40:21 -0300
commit4f100f92d859848f44c972c08e7fbf37c04e8d3e (patch)
tree988ebf8014e22d2ded723d79e91e990c2c9bd1f9
parentd31696e3dbe54111cfcf444abf854a55c94bdb76 (diff)
DPI Detection support
Windows only for now. Many builds may break (older visual studio, mingw32)
-rw-r--r--core/bind/core_bind.cpp6
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/os/os.h1
-rw-r--r--drivers/freetype/SCsub8
-rw-r--r--platform/windows/detect.py4
-rw-r--r--platform/windows/os_windows.cpp23
-rw-r--r--platform/windows/os_windows.h3
7 files changed, 39 insertions, 7 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index e8703dccca..addc26525e 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -226,6 +226,11 @@ Size2 _OS::get_screen_size(int p_screen) const {
return OS::get_singleton()->get_screen_size(p_screen);
}
+int _OS::get_screen_dpi(int p_screen) const {
+
+ return OS::get_singleton()->get_screen_dpi(p_screen);
+}
+
Point2 _OS::get_window_position() const {
return OS::get_singleton()->get_window_position();
}
@@ -984,6 +989,7 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_current_screen","screen"),&_OS::set_current_screen);
ObjectTypeDB::bind_method(_MD("get_screen_position","screen"),&_OS::get_screen_position,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_screen_size","screen"),&_OS::get_screen_size,DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("get_screen_dpi","screen"),&_OS::get_screen_dpi,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position);
ObjectTypeDB::bind_method(_MD("set_window_position","position"),&_OS::set_window_position);
ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 0c768651ff..af89536c45 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -117,6 +117,7 @@ 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;
diff --git a/core/os/os.h b/core/os/os.h
index 160c0495bb..5fd2bd6c25 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -160,6 +160,7 @@ public:
virtual void set_current_screen(int p_screen) { }
virtual Point2 get_screen_position(int p_screen=0) const { return Point2(); }
virtual Size2 get_screen_size(int p_screen=0) const { return get_window_size(); }
+ virtual int get_screen_dpi(int p_screen=0) const { return 72; }
virtual Point2 get_window_position() const { return Vector2(); }
virtual void set_window_position(const Point2& p_position) {}
virtual Size2 get_window_size() const=0;
diff --git a/drivers/freetype/SCsub b/drivers/freetype/SCsub
index 75e872a06f..c0921c683a 100644
--- a/drivers/freetype/SCsub
+++ b/drivers/freetype/SCsub
@@ -58,10 +58,10 @@ if (env["freetype"]=="builtin"):
else:
half1.append(x)
- lib = env.Library("freetype_builtin1",half1)
- env.Prepend(LIBS=[lib])
- lib = env.Library("freetype_builtin2",half2)
- env.Prepend(LIBS=[lib])
+ lib = env.Library("freetype_builtin1",half2)
+ env.Append(LIBS=[lib])
+ lib = env.Library("freetype_builtin2",half1)
+ env.Append(LIBS=[lib])
# lib = env.Library("freetype_builtin",ft_sources)
# env.Prepend(LIBS=[lib])
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;