From 0a98f9c69a5659b5a8f523c2f6d2a5eca37973ec Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 26 Oct 2022 20:45:41 +0100 Subject: [PATCH] SDL: Support setting vsync at runtime Allows vid_wait to work under software without having to switch to OpenGL and then back --- src/sdl/i_video.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 05cb385e..f0a8a719 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -102,7 +102,7 @@ rendermode_t rendermode = render_none; boolean highcolor = false; // synchronize page flipping with screen refresh -consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; UINT8 graphics_started = 0; // Is used in console.c and screen.c @@ -2131,4 +2131,9 @@ UINT32 I_GetRefreshRate(void) return refresh_rate; } +static void Impl_SetVsync(void) +{ +#if SDL_VERSION_ATLEAST(2,0,18) + if (renderer) + SDL_RenderSetVSync(renderer, cv_vidwait.value); #endif