浏览代码

Disabling WindowSizeCallback around fullscreen toggle. (#1480)

* Disabling WindowSizeCallback around fullscreen toggle.

#1294 fixed the issue that toggle fullscreen changes the screen size because of the WindowSizeCallback. The proposed edit by @raysan5 was to comment out WindowSizeCallback which I essentially simplified to disable the callback around the set window monitor functions.

The developers using the ToggleFullscreen function should be aware that they need to size the screen correctly on that same frame. Otherwise they should check if fullscreen and size properly using the GetMonitorWidth and GetMonitorHeight functions.

* Update core.c

Fix issue from merge
pull/1573/head
hristo 4 年前
committed by GitHub
父节点
当前提交
70965f20d5
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. +10
    -1
      src/core.c

+ 10
- 1
src/core.c 查看文件

@ -1038,18 +1038,27 @@ void ToggleFullscreen(void)
if (!monitor) if (!monitor)
{ {
TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor"); TRACELOG(LOG_WARNING, "GLFW: Failed to get monitor");
glfwSetWindowSizeCallback(CORE.Window.handle, NULL);
glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE); glfwSetWindowMonitor(CORE.Window.handle, glfwGetPrimaryMonitor(), 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback);
return; return;
} }
const GLFWvidmode *mode = glfwGetVideoMode(monitor); const GLFWvidmode *mode = glfwGetVideoMode(monitor);
glfwSetWindowSizeCallback(CORE.Window.handle, NULL);
glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate); glfwSetWindowMonitor(CORE.Window.handle, monitor, 0, 0, CORE.Window.screen.width, CORE.Window.screen.height, mode->refreshRate);
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback);
// Try to enable GPU V-Sync, so frames are limited to screen refresh rate (60Hz -> 60 FPS) // 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 // NOTE: V-Sync can be enabled by graphic driver configuration
if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1); if (CORE.Window.flags & FLAG_VSYNC_HINT) glfwSwapInterval(1);
} }
else glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
else
{
glfwSetWindowSizeCallback(CORE.Window.handle, NULL);
glfwSetWindowMonitor(CORE.Window.handle, NULL, CORE.Window.position.x, CORE.Window.position.y, CORE.Window.screen.width, CORE.Window.screen.height, GLFW_DONT_CARE);
glfwSetWindowSizeCallback(CORE.Window.handle, WindowSizeCallback);
}
CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag CORE.Window.fullscreen = !CORE.Window.fullscreen; // Toggle fullscreen flag
CORE.Window.flags ^= FLAG_FULLSCREEN_MODE; CORE.Window.flags ^= FLAG_FULLSCREEN_MODE;

正在加载...
取消
保存