Browse Source

Platform: finally add VSync support to Sdl2Application.

Sorry that it took ages. Oh, actually, I'm not able to test this AT ALL
because my awesomely amazing NVidia Optimus laptop CANNOT (what?!) do
VSync because of some bad design decisions from previous century that
led to the disaster that we now know as X11 and as I heard it is
impossible to work around that or something. Ugh.
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
3060e1d1a2
  1. 18
      src/Magnum/Platform/Sdl2Application.cpp
  2. 14
      src/Magnum/Platform/Sdl2Application.h

18
src/Magnum/Platform/Sdl2Application.cpp

@ -215,6 +215,24 @@ void Sdl2Application::swapBuffers() {
#endif
}
Int Sdl2Application::swapInterval() const {
return SDL_GL_GetSwapInterval();
}
bool Sdl2Application::setSwapInterval(const Int interval) {
if(SDL_GL_SetSwapInterval(interval) == -1) {
Error() << "Platform::Sdl2Application::setSwapInterval(): cannot set swap interval:" << SDL_GetError();
return false;
}
if(SDL_GL_GetSwapInterval() != interval) {
Error() << "Platform::Sdl2Application::setSwapInterval(): swap interval setting ignored by the driver";
return false;
}
return true;
}
Sdl2Application::~Sdl2Application() {
_context.reset();

14
src/Magnum/Platform/Sdl2Application.h

@ -276,9 +276,23 @@ class Sdl2Application {
* @brief Swap buffers
*
* Paints currently rendered framebuffer on screen.
* @see @ref setSwapInterval()
*/
void swapBuffers();
/** @brief Swap interval */
Int swapInterval() const;
/**
* @brief Set swap interval
*
* Set `0` for no VSync, `1` for enabled VSync. Some platforms support
* `-1` for late swap tearing. Prints error message and returns `false`
* if swap interval cannot be set, `true` otherwise. Default is
* driver-dependent, you can query the value with @ref swapInterval().
*/
bool setSwapInterval(Int interval);
/**
* @brief Redraw immediately
*

Loading…
Cancel
Save