diff --git a/main.cpp b/main.cpp index 9641a33..0426842 100644 --- a/main.cpp +++ b/main.cpp @@ -126,7 +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(1); // Enable vsync + SDL_GL_SetSwapInterval(0); // Enable vsync // Setup Dear ImGui context IMGUI_CHECKVERSION(); @@ -194,6 +194,7 @@ int main(int, char**) bool prefs_window = false; bool theme_editor = false; bool stopped = true; + bool vsync = false; { Json::Value config; std::ifstream stream; @@ -213,6 +214,10 @@ int main(int, char**) if (config.isMember("demo_window")) { show_demo_window = config["demo_window"].asBool(); } + if (config.isMember("vsync")) { + vsync = config["vsync"].asBool(); + SDL_GL_SetSwapInterval(vsync ? 1 : 0); + } stream.close(); } if (is_empty(Theme::themeDir)) { @@ -228,6 +233,7 @@ int main(int, char**) } } } + 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. // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage. @@ -349,6 +355,9 @@ int main(int, char**) ImGui::SetNextWindowSizeConstraints(min_size, max_size); ImGui::Begin("Preferences...", &prefs_window); { + if (ImGui::Checkbox("Enable VSync", &vsync)) { + SDL_GL_SetSwapInterval(vsync ? 1 : 0); + } if (ImGui::Button(ICON_FK_MAGIC "Theme Editor", ImVec2(ImGui::GetWindowWidth() - (ImGui::GetStyle().WindowPadding.x * 2.0f), 0))) { theme_editor = true; } @@ -364,6 +373,7 @@ int main(int, char**) if (ImGui::Selectable(themePath.stem().c_str(), is_selected)) { delete theme; theme = new Theme(themePath); + theme->Apply(accent_color); break; } if (is_selected) { @@ -380,8 +390,8 @@ int main(int, char**) } if (theme_editor) { Theme::ShowEditor(&theme_editor, theme); + theme->Apply(accent_color); } - theme->Apply(accent_color); fileDialog.Display(); if (fileDialog.HasSelected()) { @@ -439,6 +449,7 @@ int main(int, char**) } config["accent_color"] = accent_color; config["demo_window"] = show_demo_window; + config["vsync"] = vsync; stream << config; stream.close(); } diff --git a/meson.build b/meson.build index 5db5c6b..00166e4 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,7 @@ cmake = import('cmake') if get_option('debug') add_global_arguments('-DDEBUG', language: 'cpp') endif +add_global_arguments('-DIMGUI_IMPL_OPENGL_ES2', language: 'cpp') smx_opts = cmake.subproject_options() smx_opts.add_cmake_defines({'SDL_MIXER_X_STATIC': true, 'SDL_MIXER_X_SHARED': false}) smx_opts.set_override_option('c_std', 'c99')