summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorgulrak <[email protected]>2022-06-09 21:00:04 +0200
committerGitHub <[email protected]>2022-06-09 21:00:04 +0200
commit5e3ef4220185781d31190723a149d42c30aac492 (patch)
treee4fe6d317b18454e10800283c0dc9639e27df670
parent59a808516e6d1bc1db1f0caad60b45fc26afaf97 (diff)
downloadraylib-5e3ef4220185781d31190723a149d42c30aac492.tar.gz
raylib-5e3ef4220185781d31190723a149d42c30aac492.zip
GetMonitorWidth()/GetMonitorHeight(): return current video resolution instead max available (#2514)
* GetMonitorWidth()/GetMonitorHeight(): current video resolution instead max available * adapt header comment to reflect change
-rw-r--r--src/raylib.h4
-rw-r--r--src/rcore.c20
2 files changed, 9 insertions, 15 deletions
diff --git a/src/raylib.h b/src/raylib.h
index b6037eda..47218129 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -939,8 +939,8 @@ RLAPI int GetRenderHeight(void); // Get current
RLAPI int GetMonitorCount(void); // Get number of connected monitors
RLAPI int GetCurrentMonitor(void); // Get current connected monitor
RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position
-RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (max available by monitor)
-RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (max available by monitor)
+RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor)
+RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor)
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
diff --git a/src/rcore.c b/src/rcore.c
index fa9fdf93..6dca7ddc 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -1723,7 +1723,7 @@ int GetCurrentMonitor(void)
#endif
}
-// Get selected monitor width
+// Get selected monitor position
Vector2 GetMonitorPosition(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@@ -1742,7 +1742,7 @@ Vector2 GetMonitorPosition(int monitor)
return (Vector2){ 0, 0 };
}
-// Get selected monitor width (max available by monitor)
+// Get selected monitor width (currently used by monitor)
int GetMonitorWidth(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@@ -1751,11 +1751,8 @@ int GetMonitorWidth(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
- int count = 0;
- const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
-
- // We return the maximum resolution available, the last one in the modes array
- if (count > 0) return modes[count - 1].width;
+ const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
+ if(mode) return mode->width;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
@@ -1763,7 +1760,7 @@ int GetMonitorWidth(int monitor)
return 0;
}
-// Get selected monitor width (max available by monitor)
+// Get selected monitor height (currently used by monitor)
int GetMonitorHeight(int monitor)
{
#if defined(PLATFORM_DESKTOP)
@@ -1772,11 +1769,8 @@ int GetMonitorHeight(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
- int count = 0;
- const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
-
- // We return the maximum resolution available, the last one in the modes array
- if (count > 0) return modes[count - 1].height;
+ const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
+ if(mode) return mode->height;
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");