From 0969f51298b1f5e50b674673bf9b26d1058874c6 Mon Sep 17 00:00:00 2001 From: asdqwe Date: Wed, 20 Nov 2024 20:30:53 -0300 Subject: [PATCH] Add GetMonitorScale() for PLATFORM_WEB --- src/platforms/rcore_web.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index e0b943fc7..8df87eb26 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -754,8 +754,11 @@ int GetMonitorRefreshRate(int monitor) // Get specified monitor scale Vector2 GetMonitorScale(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorScale() not implemented on target platform"); - return (Vector2){ 1.0f, 1.0f }; + // NOTE: Returned scale is relative to the current monitor where the browser window is located + Vector2 scale = { 1.0f, 1.0f }; + scale.x = (float)EM_ASM_DOUBLE( { return window.devicePixelRatio; } ); + scale.y = scale.x; + return scale; } // Get the human-readable, UTF-8 encoded name of the selected monitor