From 19ab0816e8a1603856d93a70ce10ede273366b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aksel=20Kornesj=C3=B6?= Date: Thu, 7 Jan 2021 18:14:32 +0100 Subject: [PATCH 1/3] Added method winGetPixelSize to SDL, for getting pixel size of high DPI windows --- libs/sdl/sdl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/sdl/sdl.c b/libs/sdl/sdl.c index bbcfb3f3e..dea66f25d 100644 --- a/libs/sdl/sdl.c +++ b/libs/sdl/sdl.c @@ -526,6 +526,10 @@ HL_PRIM void HL_NAME(win_set_max_size)(SDL_Window *win, int width, int height) { SDL_SetWindowMaximumSize(win, width, height); } +HL_PRIM void HL_NAME(win_get_pixel_size)(SDL_Window *win, int *width, int *height) { + SDL_GL_GetDrawableSize(win, width, height); +} + HL_PRIM void HL_NAME(win_get_size)(SDL_Window *win, int *width, int *height) { SDL_GetWindowSize(win, width, height); } @@ -605,6 +609,7 @@ DEFINE_PRIM(_VOID, win_get_position, TWIN _REF(_I32) _REF(_I32)); DEFINE_PRIM(_VOID, win_set_size, TWIN _I32 _I32); DEFINE_PRIM(_VOID, win_set_min_size, TWIN _I32 _I32); DEFINE_PRIM(_VOID, win_set_max_size, TWIN _I32 _I32); +DEFINE_PRIM(_VOID, win_get_pixel_size, TWIN _REF(_I32) _REF(_I32)); DEFINE_PRIM(_VOID, win_get_size, TWIN _REF(_I32) _REF(_I32)); DEFINE_PRIM(_VOID, win_get_min_size, TWIN _REF(_I32) _REF(_I32)); DEFINE_PRIM(_VOID, win_get_max_size, TWIN _REF(_I32) _REF(_I32)); From 64f16e7b4fbf63acc698448ed968c8db1914c6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aksel=20Kornesj=C3=B6?= Date: Fri, 8 Jan 2021 01:12:15 +0100 Subject: [PATCH 2/3] Added pixelWidth and pixelHeight to Window --- libs/sdl/sdl/Window.hx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libs/sdl/sdl/Window.hx b/libs/sdl/sdl/Window.hx index 899307101..082b0bd1c 100644 --- a/libs/sdl/sdl/Window.hx +++ b/libs/sdl/sdl/Window.hx @@ -50,6 +50,8 @@ class Window { public var vsync(default, set) : Bool; public var width(get, never) : Int; public var height(get, never) : Int; + public var pixelWidth(get, never) : Int; + public var pixelHeight(get, never) : Int; public var minWidth(get, never) : Int; public var minHeight(get, never) : Int; public var maxWidth(get, never) : Int; @@ -176,6 +178,18 @@ class Window { return w; } + function get_pixelWidth() { + var w = 0; + winGetPixelSize(win, w, null); + return w; + } + + function get_pixelHeight() { + var h = 0; + winGetPixelSize(win, null, h); + return h; + } + function get_height() { var h = 0; winGetSize(win, null, h); @@ -312,6 +326,9 @@ class Window { static function winGetSize( win : WinPtr, width : hl.Ref, height : hl.Ref ) { } + static function winGetPixelSize( win : WinPtr, width : hl.Ref, height : hl.Ref ) { + } + static function winGetMinSize( win : WinPtr, width : hl.Ref, height : hl.Ref ) { } From d65a34d71a027e394f724d478b79a54f3ecae40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aksel=20Kornesj=C3=B6?= Date: Fri, 8 Jan 2021 21:36:00 +0100 Subject: [PATCH 3/3] Swapped pixelWidth and pixelHeight to windowToPixelRatio --- libs/directx/dx/Window.hx | 6 ++++++ libs/sdl/sdl/Window.hx | 17 ++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libs/directx/dx/Window.hx b/libs/directx/dx/Window.hx index a0c5b7872..dba321a58 100644 --- a/libs/directx/dx/Window.hx +++ b/libs/directx/dx/Window.hx @@ -28,6 +28,7 @@ class Window { public var title(default, set) : String; public var width(get, never) : Int; public var height(get, never) : Int; + public var windowToPixelRatio(get, never) : Float; public var minWidth(get, never) : Int; public var minHeight(get, never) : Int; public var maxWidth(get, never) : Int; @@ -112,6 +113,11 @@ class Window { return h; } + function get_windowToPixelRatio() { + // Not yet implemented + return 1.0; + } + function get_minWidth() { var w = 0; winGetMinSize(win, w, null); diff --git a/libs/sdl/sdl/Window.hx b/libs/sdl/sdl/Window.hx index 082b0bd1c..e9b2dd7fe 100644 --- a/libs/sdl/sdl/Window.hx +++ b/libs/sdl/sdl/Window.hx @@ -50,8 +50,7 @@ class Window { public var vsync(default, set) : Bool; public var width(get, never) : Int; public var height(get, never) : Int; - public var pixelWidth(get, never) : Int; - public var pixelHeight(get, never) : Int; + public var windowToPixelRatio(get, never) : Float; public var minWidth(get, never) : Int; public var minHeight(get, never) : Int; public var maxWidth(get, never) : Int; @@ -178,16 +177,12 @@ class Window { return w; } - function get_pixelWidth() { - var w = 0; - winGetPixelSize(win, w, null); - return w; - } + function get_windowToPixelRatio() { + var pixelHeight = 0; + winGetPixelSize(win, null, pixelHeight); + var h : Float = height; - function get_pixelHeight() { - var h = 0; - winGetPixelSize(win, null, h); - return h; + return h / pixelHeight; } function get_height() {