12

glfwSwapInterval(1)似乎不适合我。如果我在 CCC 或setVerticalSyncEnabled(true)SFML 中强制 VSync,我的 fps 会下降到 60,但 GLFW 只会继续以 9000 fps 运行。我是以错误的方式解决这个问题还是 GLFW 被窃听了?

4

3 回答 3

8

看起来 GLFW 不想在启用桌面合成时打开 VSync。如果您仍然想要 VSync,这将在 Windows 上运行:

#ifdef _WIN32
    // Turn on vertical screen sync under Windows.
    // (I.e. it uses the WGL_EXT_swap_control extension)
    typedef BOOL (WINAPI *PFNWGLSWAPINTERVALEXTPROC)(int interval);
    PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
    wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
    if(wglSwapIntervalEXT)
        wglSwapIntervalEXT(1);
#endif

对于其他操作系统,谷歌会帮助你。

于 2013-04-30T15:42:05.500 回答
3

使用 GLFW_USE_DWM_SWAP_INTERVAL 选项重建 GLFW3。

glfw/src/config.h

GLFW 文档警告抖动问题,但我自己没有看到这些问题。

于 2013-09-17T23:21:22.443 回答
1

发现glfwSwapInterval需要在窗口模式和全屏模式之间切换后再次调用,否则帧率会很大。

if (fullScreen)
            {
                glfwSetWindowMonitor(window, monitor, 0, 0, monitorMode->width, monitorMode->height, monitorMode->refreshRate);

                // Added to fix framerate to vertical refresh //
                glfwSwapInterval(1);
            }
            else
            {
                glfwSetWindowMonitor(window, NULL, 0, 0, monitorMode->width, monitorMode->height, monitorMode->refreshRate);
            }
于 2019-01-01T21:37:09.490 回答