Feature: allow a toggle to enable/disable vsync

Vsync should be off by default, as for most players it will be
better to play without vsync. Exception exist, mainly people who
play in fullscreen mode.
This commit is contained in:
Patric Stout
2021-04-10 14:53:26 +02:00
committed by Patric Stout
parent 56f982fa7f
commit f0f2073006
10 changed files with 68 additions and 12 deletions

View File

@@ -70,8 +70,6 @@ const char *VideoDriver_SDL_OpenGL::Start(const StringList &param)
SDL_GetWindowSize(this->sdl_window, &w, &h);
this->ClientSizeChanged(w, h, true);
SDL_GL_SetSwapInterval(GetDriverParamBool(param, "vsync") ? 1 : 0);
return nullptr;
}
@@ -91,6 +89,11 @@ void VideoDriver_SDL_OpenGL::DestroyContext()
}
}
void VideoDriver_SDL_OpenGL::ToggleVsync(bool vsync)
{
SDL_GL_SetSwapInterval(vsync);
}
const char *VideoDriver_SDL_OpenGL::AllocateContext()
{
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
@@ -107,6 +110,8 @@ const char *VideoDriver_SDL_OpenGL::AllocateContext()
this->gl_context = SDL_GL_CreateContext(this->sdl_window);
if (this->gl_context == nullptr) return "SDL2: Can't active GL context";
ToggleVsync(_video_vsync);
return OpenGLBackend::Create(&GetOGLProcAddressCallback);
}