summaryrefslogtreecommitdiff
path: root/src/video/win32_v.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-04-10 14:53:26 +0200
committerPatric Stout <github@truebrain.nl>2021-04-11 14:26:00 +0200
commitf0f20730067ef79dd87fd24b5a670ef3f38c0b88 (patch)
treef11a3f4093d92ebc80b8a8e6d2fda603ab94ff53 /src/video/win32_v.cpp
parent56f982fa7f6da6134cff0d81040ebdf39b72ea2d (diff)
downloadopenttd-f0f20730067ef79dd87fd24b5a670ef3f38c0b88.tar.xz
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.
Diffstat (limited to 'src/video/win32_v.cpp')
-rw-r--r--src/video/win32_v.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 426d74c0a..467478461 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -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);