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

@@ -1290,7 +1290,6 @@ const char *VideoDriver_Win32OpenGL::Start(const StringList &param)
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) return "Only real blitters supported";
Dimension old_res = _cur_resolution; // Save current screen resolution in case of errors, as MakeWindow invalidates it.
this->vsync = GetDriverParamBool(param, "vsync");
LoadWGLExtensions();
@@ -1335,6 +1334,15 @@ void VideoDriver_Win32OpenGL::DestroyContext()
}
}
void VideoDriver_Win32OpenGL::ToggleVsync(bool vsync)
{
if (_wglSwapIntervalEXT != nullptr) {
_wglSwapIntervalEXT(vsync);
} else if (vsync) {
DEBUG(driver, 0, "OpenGL: Vsync requested, but not supported by driver");
}
}
const char *VideoDriver_Win32OpenGL::AllocateContext()
{
this->dc = GetDC(this->main_wnd);
@@ -1363,12 +1371,7 @@ const char *VideoDriver_Win32OpenGL::AllocateContext()
}
if (!wglMakeCurrent(this->dc, rc)) return "Can't active GL context";
/* Enable/disable Vsync if supported. */
if (_wglSwapIntervalEXT != nullptr) {
_wglSwapIntervalEXT(this->vsync ? 1 : 0);
} else if (vsync) {
DEBUG(driver, 0, "OpenGL: Vsync requested, but not supported by driver");
}
this->ToggleVsync(_video_vsync);
this->gl_rc = rc;
return OpenGLBackend::Create(&GetOGLProcAddressCallback);