mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
DPI Detection support
Windows only for now. Many builds may break (older visual studio, mingw32)
This commit is contained in:
parent
d31696e3db
commit
4f100f92d8
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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])
|
||||
|
@ -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'])
|
||||
|
@ -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;
|
||||
@ -1365,6 +1378,14 @@ Size2 OS_Windows::get_screen_size(int p_screen) const{
|
||||
ERR_FAIL_INDEX_V(p_screen,monitor_info.size(),Point2());
|
||||
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{
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user