Always set VSync swap interval at startup, and only once at startup
This commit is contained in:
parent
ec7b3079a7
commit
bcc899bc78
1 changed files with 2 additions and 3 deletions
5
main.cpp
5
main.cpp
|
@ -126,8 +126,7 @@ 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();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue