Always set VSync swap interval at startup, and only once at startup

This commit is contained in:
Zachary Hall 2023-07-16 12:37:34 -07:00
parent ec7b3079a7
commit bcc899bc78

View file

@ -126,7 +126,6 @@ int main(int, char**)
SDL_SetWindowIcon(window, icon); SDL_SetWindowIcon(window, icon);
SDL_GLContext gl_context = SDL_GL_CreateContext(window); SDL_GLContext gl_context = SDL_GL_CreateContext(window);
SDL_GL_MakeCurrent(window, gl_context); SDL_GL_MakeCurrent(window, gl_context);
SDL_GL_SetSwapInterval(0); // Enable vsync
// Setup Dear ImGui context // Setup Dear ImGui context
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
@ -216,7 +215,6 @@ int main(int, char**)
} }
if (config.isMember("vsync")) { if (config.isMember("vsync")) {
vsync = config["vsync"].asBool(); vsync = config["vsync"].asBool();
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
} }
stream.close(); stream.close();
} }
@ -233,6 +231,7 @@ int main(int, char**)
} }
} }
} }
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
theme->Apply(accent_color); theme->Apply(accent_color);
#ifdef __EMSCRIPTEN__ #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. // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.