SDL: Support setting vsync at runtime

Allows vid_wait to work under software without having to switch to OpenGL and then back
This commit is contained in:
toaster 2022-10-26 20:45:41 +01:00
parent 427944f633
commit 0a98f9c69a

View file

@ -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