From 626ef8f9d28bdc51d01a68e327b25e92cbbffcac Mon Sep 17 00:00:00 2001 From: asdqwe Date: Wed, 20 Nov 2024 18:27:30 -0300 Subject: [PATCH] Add GetMonitorScale() --- src/platforms/rcore_android.c | 7 +++++++ src/platforms/rcore_desktop_glfw.c | 13 +++++++++++++ src/platforms/rcore_desktop_rgfw.c | 7 +++++++ src/platforms/rcore_desktop_sdl.c | 7 +++++++ src/platforms/rcore_drm.c | 7 +++++++ src/platforms/rcore_template.c | 7 +++++++ src/platforms/rcore_web.c | 7 +++++++ src/raylib.h | 1 + 8 files changed, 56 insertions(+) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 47dc5cabc..bb74ac566 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -480,6 +480,13 @@ int GetMonitorRefreshRate(int monitor) return 0; } +// Get specified monitor scale +Vector2 GetMonitorScale(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorScale() not implemented on target platform"); + return 0; +} + // Get the human-readable, UTF-8 encoded name of the selected monitor const char *GetMonitorName(int monitor) { diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 5caf17ead..6a7afd293 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -921,6 +921,19 @@ int GetMonitorRefreshRate(int monitor) return refresh; } +// Get specified monitor scale +Vector2 GetMonitorScale(int monitor) +{ + Vector2 scale = { 1.0f, 1.0f }; + int monitorCount = 0; + GLFWmonitor **monitors = glfwGetMonitors(&monitorCount); + + if ((monitor >= 0) && (monitor < monitorCount)) glfwGetMonitorContentScale(monitors[monitor], &scale.x, &scale.y); + else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor"); + + return scale; +} + // Get the human-readable, UTF-8 encoded name of the selected monitor const char *GetMonitorName(int monitor) { diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index 1d3ddf60f..a7f858da2 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -629,6 +629,13 @@ int GetMonitorRefreshRate(int monitor) return 0; } +// Get specified monitor scale +Vector2 GetMonitorScale(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorScale() not implemented on target platform"); + return 0; +} + // Get the human-readable, UTF-8 encoded name of the selected monitor const char *GetMonitorName(int monitor) { diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 99de9af22..294fa7766 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -1036,6 +1036,13 @@ int GetMonitorRefreshRate(int monitor) return refresh; } +// Get specified monitor scale +Vector2 GetMonitorScale(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorScale() not implemented on target platform"); + return 0; +} + // Get the human-readable, UTF-8 encoded name of the selected monitor const char *GetMonitorName(int monitor) { diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index e9a236868..6ca4711c0 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -466,6 +466,13 @@ int GetMonitorRefreshRate(int monitor) return refresh; } +// Get specified monitor scale +Vector2 GetMonitorScale(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorScale() not implemented on target platform"); + return 0; +} + // Get the human-readable, UTF-8 encoded name of the selected monitor const char *GetMonitorName(int monitor) { diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 891c4ab34..966b88b54 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -257,6 +257,13 @@ int GetMonitorRefreshRate(int monitor) return 0; } +// Get specified monitor scale +Vector2 GetMonitorScale(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorScale() not implemented on target platform"); + return 0; +} + // Get the human-readable, UTF-8 encoded name of the selected monitor const char *GetMonitorName(int monitor) { diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 859b2c1f3..78bb95903 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -751,6 +751,13 @@ int GetMonitorRefreshRate(int monitor) return 0; } +// Get specified monitor scale +Vector2 GetMonitorScale(int monitor) +{ + TRACELOG(LOG_WARNING, "GetMonitorScale() not implemented on target platform"); + return 0; +} + // Get the human-readable, UTF-8 encoded name of the selected monitor const char *GetMonitorName(int monitor) { diff --git a/src/raylib.h b/src/raylib.h index a26b8ce6b..dd4ad2386 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1006,6 +1006,7 @@ RLAPI int GetMonitorHeight(int monitor); // Get specifi RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate +RLAPI Vector2 GetMonitorScale(int monitor); // Get specified monitor scale RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor