diff --git a/src/graphic/Fast3D/gfx_dxgi.cpp b/src/graphic/Fast3D/gfx_dxgi.cpp index f997df40c..29d50bd87 100644 --- a/src/graphic/Fast3D/gfx_dxgi.cpp +++ b/src/graphic/Fast3D/gfx_dxgi.cpp @@ -801,12 +801,8 @@ static bool gfx_dxgi_is_frame_ready() { // dxgi.length_in_vsync_frames is used as present interval. Present interval >1 (aka fractional V-Sync) // breaks VRR and introduces even more input lag than capping via normal V-Sync does. // Get the present interval the user wants instead (V-Sync toggle). - if (dxgi.is_vsync_enabled != - Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1)) { - // Make sure only 0 or 1 is set, as present interval technically accepts a range from 0 to 4. - dxgi.is_vsync_enabled = - !!Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1); - } + dxgi.is_vsync_enabled = + (Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1) ? 1 : 0); dxgi.length_in_vsync_frames = dxgi.is_vsync_enabled; return true; } diff --git a/src/graphic/Fast3D/gfx_sdl2.cpp b/src/graphic/Fast3D/gfx_sdl2.cpp index a9869c081..59bb70c0c 100644 --- a/src/graphic/Fast3D/gfx_sdl2.cpp +++ b/src/graphic/Fast3D/gfx_sdl2.cpp @@ -662,6 +662,14 @@ static inline void sync_framerate_with_timer() { } static void gfx_sdl_swap_buffers_begin() { + // Make sure only 0 or 1 is set. + if (vsync_enabled = + !(Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1) ? 1 : 0)) { + vsync_enabled = !vsync_enabled; + SDL_GL_SetSwapInterval(vsync_enabled); + SDL_RenderSetVSync(renderer, vsync_enabled); + } + sync_framerate_with_timer(); SDL_GL_SwapWindow(wnd); } @@ -686,7 +694,7 @@ static const char* gfx_sdl_get_key_name(int scancode) { } bool gfx_sdl_can_disable_vsync() { - return false; + return true; } bool gfx_sdl_is_running() {