From a53a8958f293c0cc5760021cce616574408aee50 Mon Sep 17 00:00:00 2001 From: Asdqwe Date: Fri, 22 Nov 2024 06:52:55 -0300 Subject: [PATCH] Add implementation to GetWindowScaleDPI() for PLATFORM_WEB (#4526) --- 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 859b2c1f..d0be0251 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -771,8 +771,11 @@ Vector2 GetWindowPosition(void) // Get window scale DPI factor for current monitor Vector2 GetWindowScaleDPI(void) { - TRACELOG(LOG_WARNING, "GetWindowScaleDPI() 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; } // Set clipboard text content