Browse Source

Add GetMonitorWidth() and GetMonitorHeight() implementations for PLATFORM_WEB (#3636)

ubkp 1 year ago
parent
commit
10c82595b0
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/platforms/rcore_web.c

+ 7 - 5
src/platforms/rcore_web.c

@@ -572,15 +572,17 @@ Vector2 GetMonitorPosition(int monitor)
 // Get selected monitor width (currently used by monitor)
 // Get selected monitor width (currently used by monitor)
 int GetMonitorWidth(int monitor)
 int GetMonitorWidth(int monitor)
 {
 {
-    TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform");
-    return 0;
+    int w = 0;
+    w = EM_ASM_INT( { return screen.width; }, 0);
+    return w;
 }
 }
 
 
 // Get selected monitor height (currently used by monitor)
 // Get selected monitor height (currently used by monitor)
 int GetMonitorHeight(int monitor)
 int GetMonitorHeight(int monitor)
 {
 {
-    TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform");
-    return 0;
+    int h = 0;
+    h = EM_ASM_INT( { return screen.height; }, 0);
+    return h;
 }
 }
 
 
 // Get selected monitor physical width in millimetres
 // Get selected monitor physical width in millimetres
@@ -946,7 +948,7 @@ int InitPlatform(void)
 
 
     // NOTE: Some GLFW flags are not supported on HTML5
     // NOTE: Some GLFW flags are not supported on HTML5
     // e.g.: GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_MOUSE_PASSTHROUGH
     // e.g.: GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_MOUSE_PASSTHROUGH
-    
+
     // Scale content area based on the monitor content scale where window is placed on
     // Scale content area based on the monitor content scale where window is placed on
     // NOTE: This feature requires emscripten 3.1.51
     // NOTE: This feature requires emscripten 3.1.51
     //if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
     //if ((CORE.Window.flags & FLAG_WINDOW_HIGHDPI) > 0) glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);