mirror of
https://github.com/glfw/glfw.git
synced 2026-09-20 16:30:45 +00:00
Use DwmFlush when DWM is enabled.
Use DwmFlush instead of WGL_EXT_swap_control when desktop compositing is enabled, to avoid the jitter of DWM and WGL vsync fighting. Fixes #516.
This commit is contained in:
+14
-6
@@ -570,6 +570,14 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
{
|
||||
// HACK: Use DwmFlush when desktop composition is enabled
|
||||
if (_glfwIsCompositionEnabled())
|
||||
{
|
||||
int count = window->wgl.interval;
|
||||
while (count--)
|
||||
_glfw_DwmFlush();
|
||||
}
|
||||
|
||||
SwapBuffers(window->wgl.dc);
|
||||
}
|
||||
|
||||
@@ -577,12 +585,12 @@ void _glfwPlatformSwapInterval(int interval)
|
||||
{
|
||||
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
|
||||
|
||||
#if !defined(_GLFW_USE_DWM_SWAP_INTERVAL)
|
||||
// HACK: Don't enabled vsync when desktop compositing is enabled, as it
|
||||
// leads to severe frame jitter on some cards
|
||||
if (_glfwIsCompositionEnabled() && interval)
|
||||
return;
|
||||
#endif
|
||||
window->wgl.interval = interval;
|
||||
|
||||
// HACK: Disable WGL swap interval when desktop composition is enabled to
|
||||
// avoid interfering with DWM vsync
|
||||
if (_glfwIsCompositionEnabled())
|
||||
interval = 0;
|
||||
|
||||
if (window->wgl.EXT_swap_control)
|
||||
window->wgl.SwapIntervalEXT(interval);
|
||||
|
||||
Reference in New Issue
Block a user