summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorJeffery Myers <[email protected]>2021-03-08 09:08:37 -0800
committerGitHub <[email protected]>2021-03-08 18:08:37 +0100
commit3e6f0d7372268545e56ced5515764e1176d95d70 (patch)
tree89697c83c6f67e97f33202a295164b759475a864 /src/core.c
parent0d096b43c236895054cc278364fecf7b415d20d7 (diff)
downloadraylib-3e6f0d7372268545e56ced5515764e1176d95d70.tar.gz
raylib-3e6f0d7372268545e56ced5515764e1176d95d70.zip
Always try to set vsync. (#1636)
Use the internal monitor function to correctly get the display for windows.
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/core.c b/src/core.c
index 889eae8a..75b38766 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1034,7 +1034,13 @@ void ToggleFullscreen(void)
// Store previous window position (in case we exit fullscreen)
glfwGetWindowPos(CORE.Window.handle, &CORE.Window.position.x, &CORE.Window.position.y);
- GLFWmonitor *monitor = glfwGetWindowMonitor(CORE.Window.handle);
+ int monitorCount = 0;
+ GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);
+
+ int monitorIndex = GetCurrentMonitor();
+ // use GetCurrentMonitor so we correctly get the display the window is on
+ GLFWmonitor* monitor = monitorIndex < monitorCount ? monitors[monitorIndex] : NULL;
+
if (!monitor)
{
TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor");
@@ -1048,10 +1054,6 @@ void ToggleFullscreen(void)
glfwSetWindowSizeCallback(CORE.Window.handle, NULL);
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback);
-
- // Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
- // NOTE: V-Sync can be enabled by graphic driver configuration
- if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1);
}
else
{
@@ -1060,6 +1062,10 @@ void ToggleFullscreen(void)
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback);
}
+ // Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS)
+ // NOTE: V-Sync can be enabled by graphic driver configuration
+ if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1);
+
CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag
CORE.Window.flags ^= FLAG_FULLSCREEN_MODE;