From bcc899bc78f96598b69641f0dc38d23a67d30e1c Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Sun, 16 Jul 2023 12:37:34 -0700 Subject: [PATCH] Always set VSync swap interval at startup, and only once at startup --- main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 0426842..307eaf2 100644 --- a/main.cpp +++ b/main.cpp @@ -126,8 +126,7 @@ int main(int, char**) SDL_SetWindowIcon(window, icon); SDL_GLContext gl_context = SDL_GL_CreateContext(window); SDL_GL_MakeCurrent(window, gl_context); - SDL_GL_SetSwapInterval(0); // Enable vsync - + // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); @@ -216,7 +215,6 @@ int main(int, char**) } if (config.isMember("vsync")) { vsync = config["vsync"].asBool(); - SDL_GL_SetSwapInterval(vsync ? 1 : 0); } stream.close(); } @@ -233,6 +231,7 @@ int main(int, char**) } } } + SDL_GL_SetSwapInterval(vsync ? 1 : 0); theme->Apply(accent_color); #ifdef __EMSCRIPTEN__ // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.