Browse Source

Platform: fix Sdl2Application::setSwapInterval() with late swap behavior.

For quite a while, setSwapInterval() was reporting that "swap interval
was ignored by the driver". Since I used to have that behavior ages ago
on a NVidia Optimus machine (where it was just *impossible* to have
VSync, imagine that!!), I assumed it was a similar wart in Mesa and
didn't bother looking into it.

It turns out, however, that calling setSwapInterval(1) may result in
SDL_GL_GetSwapInterval() returning -1 instead of 1, thus helpfully
enabling late-swap behavior for me. Since -1 != -1, the code treated
that the same as if SDL_GL_GetSwapInterval() returned 0 (which was the
case with NV Optimus having broken VSync), but it's not an error in
fact.
pull/578/head
Vladimír Vondruš 4 years ago
parent
commit
527ee0f45d
  1. 3
      doc/changelog.dox
  2. 7
      src/Magnum/Platform/Sdl2Application.cpp

3
doc/changelog.dox

@ -725,6 +725,9 @@ See also:
case as for a WebGL-enabled context
- Fixed a crash in @ref Platform::GlfwApplication::setCursor() on the
upcoming GLFW 3.4
- Fixed @ref Platform::Sdl2Application::setSwapInterval() to take late swap
behavior (@cpp -1 @ce) into account instead of treating it as an error
and continuing with timer-based framerate capping
- @ref SceneGraph::BasicMatrixTransformation2D,
@ref SceneGraph::BasicMatrixTransformation3D,
@ref SceneGraph::BasicRigidMatrixTransformation2D and

7
src/Magnum/Platform/Sdl2Application.cpp

@ -781,8 +781,11 @@ bool Sdl2Application::setSwapInterval(const Int interval) {
return false;
}
if(SDL_GL_GetSwapInterval() != interval) {
Error() << "Platform::Sdl2Application::setSwapInterval(): swap interval setting ignored by the driver";
/* Setting interval to 1 may cause SDL_GL_GetSwapInterval() to return -1,
which is a valid case */
const Int actualInterval = SDL_GL_GetSwapInterval();
if(actualInterval != interval && !(interval == 1 && actualInterval == -1)) {
Error() << "Platform::Sdl2Application::setSwapInterval(): swap interval setting ignored by the driver:" << SDL_GetError();
_flags &= ~Flag::VSyncEnabled;
return false;
}

Loading…
Cancel
Save