From 1c80e99008923f126853fe633e26d9d8ccefa13a Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 7 Jul 2013 23:29:13 +0200 Subject: [PATCH] Added forcing of swap interval on DWM composition. --- CMakeLists.txt | 8 ++++++++ README.md | 6 ++++++ src/config.h.in | 2 ++ src/wgl_context.c | 2 ++ 4 files changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a5ea841..13d51d25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,10 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) +if (WIN32) + option(GLFW_USE_DWM_SWAP_INTERVAL "Set swap interval even when DWM compositing is enabled" OFF) +endif() + if (APPLE) option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF) option(GLFW_USE_CHDIR "Make glfwInit chdir to Contents/Resources" ON) @@ -151,6 +155,10 @@ if (_GLFW_WIN32) set(_GLFW_NO_DLOAD_WINMM 1) list(APPEND glfw_LIBRARIES winmm) endif() + + if (GLFW_USE_DWM_SWAP_INTERVAL) + set(_GLFW_USE_DWM_SWAP_INTERVAL 1) + endif() endif() #-------------------------------------------------------------------- diff --git a/README.md b/README.md index f3446ebb..c0171a67 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ directory of bundled applications to the `Contents/Resources` directory. `USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the static library version of the Visual C++ runtime library. +`GLFW_USE_DWM_SWAP_INTERVAL` determines whether the swap interval is set even +when DWM compositing is enabled. This can lead to severe jitter and is not +usually recommended. + #### EGL specific options @@ -101,6 +105,8 @@ See the [GLFW 3.0 documentation](http://www.glfw.org/docs/3.0/). - Bugfix: The `-Wall` flag was not used with Clang and other GCC compatibles - Bugfix: The default for `GLFW_ALPHA_BITS` was set to zero + - [Win32] Added `_GLFW_USE_DWM_SWAP_INTERVAL` for forcing the swap interval + to be set even when DWM compositing is enabled - [Win32] Bugfix: The clipboard string was not freed on terminate - [Win32] Bugfix: Entry points for OpenGL 1.0 and 1.1 functions were not returned by `glfwGetProcAddress` diff --git a/src/config.h.in b/src/config.h.in index 4e60ccf0..22b9f695 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -56,6 +56,8 @@ // Define this to 1 to disable dynamic loading of winmm #cmakedefine _GLFW_NO_DLOAD_WINMM +// Define this to 1 if glfwSwapInterval should ignore DWM compositing status +#cmakedefine _GLFW_USE_DWM_SWAP_INTERVAL // Define this to 1 if glXGetProcAddress is available #cmakedefine _GLFW_HAS_GLXGETPROCADDRESS diff --git a/src/wgl_context.c b/src/wgl_context.c index 4c009124..7bac477c 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -600,12 +600,14 @@ void _glfwPlatformSwapInterval(int interval) { _GLFWwindow* window = _glfwPlatformGetCurrentContext(); +#if !defined(_GLFW_USE_DWM_SWAP_INTERVAL) if (_glfwIsCompositionEnabled()) { // Don't enabled vsync when desktop compositing is enabled, as it leads // to frame jitter return; } +#endif if (window->wgl.EXT_swap_control) window->wgl.SwapIntervalEXT(interval);