From 9d5064c8579b36da9c3160763469d4b93a92e046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 6 Jan 2020 11:12:37 +0100 Subject: [PATCH] Platform: fix Sdl2Application::setSwapInterval(0) + setMinLoopPeriod(). It thought VSync was enabled even when it was set to 0. Also clarified the docs a bit. --- doc/changelog.dox | 3 +++ src/Magnum/Platform/Sdl2Application.cpp | 3 ++- src/Magnum/Platform/Sdl2Application.h | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 6aa5069bc..0893a1c7d 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -185,6 +185,9 @@ See also: @cpp #include  @ce, causing iOS builds to fail to initialize. The include got added back and initialization failures are reported with more information now. +- Calling @ref Platform::Sdl2Application::setSwapInterval() with @cpp 0 @ce + caused @ref Platform::Sdl2Application::setMinimalLoopPeriod() "setMinimalLoopPeriod()" + to be ignored even though Vsync was in fact not enabled. @subsection changelog-latest-deprecated Deprecated APIs diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index a629fec7e..fb8e9a865 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -719,7 +719,8 @@ bool Sdl2Application::setSwapInterval(const Int interval) { return false; } - _flags |= Flag::VSyncEnabled; + if(interval) _flags |= Flag::VSyncEnabled; + else _flags &= ~Flag::VSyncEnabled; return true; } diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index ee1149dce..46c19767c 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -822,7 +822,8 @@ class Sdl2Application { * * This setting reduces the main loop frequency in case VSync is * not/cannot be enabled or no drawing is done. Default is @cpp 0 @ce - * (i.e. looping at maximum frequency). + * (i.e. looping at maximum frequency). If the application is drawing + * on the screen and VSync is enabled, this setting is ignored. * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten", * the browser is managing the frequency instead. * @see @ref setSwapInterval()