From 40b81dd52a5120a4c7f4262659cca54d06d17d08 Mon Sep 17 00:00:00 2001 From: Ananyo Bhattacharya Date: Sun, 15 Mar 2026 13:12:50 +0530 Subject: [PATCH] Add GetMonitorVideoModes() to query all supported video modes for a monitor --- src/platforms/rcore_desktop_glfw.c | 34 ++++++++++++++++++++++++++++++ src/raylib.h | 10 +++++++++ 2 files changed, 44 insertions(+) diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 1975a7bfe..09585213f 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -1001,6 +1001,40 @@ int GetMonitorRefreshRate(int monitor) return refresh; } +// Get available video modes for the specified monitor +VideoMode *GetMonitorVideoModes(int monitor, int *count) +{ + VideoMode *modes = NULL; + *count = 0; + + int monitorCount = 0; + GLFWmonitor **monitors = glfwGetMonitors(&monitorCount); + + if ((monitor >= 0) && (monitor < monitorCount)) + { + int modeCount = 0; + const GLFWvidmode *glfwModes = glfwGetVideoModes(monitors[monitor], &modeCount); + + if (glfwModes) + { + modes = (VideoMode *)RL_MALLOC(modeCount*sizeof(VideoMode)); + + for (int i = 0; i < modeCount; i++) + { + modes[i].width = glfwModes[i].width; + modes[i].height = glfwModes[i].height; + modes[i].refreshRate = glfwModes[i].refreshRate; + } + + *count = modeCount; + } + else TRACELOG(LOG_WARNING, "GLFW: Failed to get video modes for selected monitor"); + } + else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor"); + + return modes; +} + // 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 a1391de19..60334effe 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -257,6 +257,13 @@ typedef struct Rectangle { float height; // Rectangle height } Rectangle; +// VideoMode, monitor video mode properties +typedef struct VideoMode { + int width; // Video mode screen width + int height; // Video mode screen height + int refreshRate; // Video mode screen refresh rate +} VideoMode; + // Image, pixel data stored in CPU memory (RAM) typedef struct Image { void *data; // Image raw data @@ -347,6 +354,8 @@ typedef struct Mesh { // Vertex attributes data float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + // ClearMouseCursorImage(); + // float *texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5) float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) @@ -1023,6 +1032,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 VideoMode *GetMonitorVideoModes(int monitor, int *count); // Get available video modes for a monitor 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