summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorhristo <[email protected]>2021-02-07 21:44:38 +0200
committerGitHub <[email protected]>2021-02-07 20:44:38 +0100
commit6be1be4573f18e39976308a41603289f90d712f3 (patch)
tree97a4911f4febf2eabcb5dcda940b3dfc0909f1f7 /src/core.c
parentc49ce58f02c37ff08574afb1b6847f300c55ca50 (diff)
downloadraylib-6be1be4573f18e39976308a41603289f90d712f3.tar.gz
raylib-6be1be4573f18e39976308a41603289f90d712f3.zip
Fix wrong values shown for monitor width and height in pixels when fullscreen is toggled. (#1479)
This solves issue #1322 which in my opinion was prematurely closed. As the monitor resolution is expected to be the maximum that the monitor supports. My change is that as per GLFW documentation you can get all current video modes sorted by max resolution. When you toggle fullscreen the first video mode returned would be the current screen resolution setup but that doesn't help if you want to know the maximum supported.
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/core.c b/src/core.c
index 20fb06f6..8efb900c 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1041,7 +1041,7 @@ void ToggleFullscreen(void)
glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
return;
}
-
+
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate);
@@ -1537,8 +1537,13 @@ int GetMonitorWidth(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
- const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
- return mode->width;
+ int count = 0;
+ const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
+
+ if(count > 0)
+ {
+ return modes[count - 1].width;
+ } else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
#endif
@@ -1554,8 +1559,13 @@ int GetMonitorHeight(int monitor)
if ((monitor >= 0) && (monitor < monitorCount))
{
- const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
- return mode->height;
+ int count = 0;
+ const GLFWvidmode *modes = glfwGetVideoModes(monitors[monitor], &count);
+
+ if(count > 0)
+ {
+ return modes[count - 1].height;
+ } else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
#endif