From f360965db64e1f90b578c9e9d28f73d0266fd4aa Mon Sep 17 00:00:00 2001 From: Ivan Mogilko Date: Sat, 18 Mar 2023 00:39:02 +0300 Subject: [PATCH] Fixed SDL_RenderSetVSync does not update flags if simulated vsync is on This lets the user to correctly detect current vsync state by reading SDL_RendererInfo. Also fixes SetVSync's return value check (it may be positive for error too). (cherry picked from commit d78072fcd46943288a6007cd6f4ab1f98f446b1d) --- src/render/SDL_render.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 1bb4afa50..653996981 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -4306,8 +4306,13 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync) } if (!renderer->SetVSync || - renderer->SetVSync(renderer, vsync) < 0) { + renderer->SetVSync(renderer, vsync) != 0) { renderer->simulate_vsync = vsync ? SDL_TRUE : SDL_FALSE; + if (renderer->simulate_vsync) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } else { + renderer->info.flags &= ~SDL_RENDERER_PRESENTVSYNC; + } } else { renderer->simulate_vsync = SDL_FALSE; }