diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 602614935..dc1a745c9 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -427,7 +427,7 @@ namespace hex { } - static float s_targetFPS = 60.0F; + static float s_targetFPS = 14.0F; float getTargetFPS() { return s_targetFPS; diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index 4eefe62fc..7ca0961c0 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -265,7 +265,10 @@ namespace hex { // Limit frame rate const auto targetFps = ImHexApi::System::getTargetFPS(); - if (targetFps <= 200) { + if (targetFps < 15) { + glfwSwapInterval(1); + } else if (targetFps <= 200) { + glfwSwapInterval(0); auto leftoverFrameTime = i64((this->m_lastFrameTime + 1 / targetFps - glfwGetTime()) * 1000); if (leftoverFrameTime > 0) std::this_thread::sleep_for(std::chrono::milliseconds(leftoverFrameTime)); diff --git a/plugins/builtin/romfs/lang/en_US.json b/plugins/builtin/romfs/lang/en_US.json index 0b72fd7d8..4bf02f0ec 100644 --- a/plugins/builtin/romfs/lang/en_US.json +++ b/plugins/builtin/romfs/lang/en_US.json @@ -435,6 +435,7 @@ "hex.builtin.setting.interface.color": "Color theme", "hex.builtin.setting.interface.fps": "FPS Limit", "hex.builtin.setting.interface.fps.unlocked": "Unlocked", + "hex.builtin.setting.interface.fps.native": "Native", "hex.builtin.setting.interface.language": "Language", "hex.builtin.setting.interface.multi_windows": "Enable Multi Window support", "hex.builtin.setting.interface.pattern_tree_style": "Pattern Tree Style", diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 9687aa545..60530d590 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -223,9 +223,16 @@ namespace hex::plugin::builtin { ContentRegistry::Settings::add("hex.builtin.setting.interface", "hex.builtin.setting.interface.fps", 60, [](auto name, nlohmann::json &setting) { static int fps = static_cast(setting); - auto format = fps > 200 ? "hex.builtin.setting.interface.fps.unlocked"_lang : "%d FPS"; + auto format = [] -> std::string { + if (fps > 200) + return "hex.builtin.setting.interface.fps.unlocked"_lang; + else if (fps < 15) + return "hex.builtin.setting.interface.fps.native"_lang; + else + return "%d FPS"; + }(); - if (ImGui::SliderInt(name.data(), &fps, 15, 201, format, ImGuiSliderFlags_AlwaysClamp)) { + if (ImGui::SliderInt(name.data(), &fps, 14, 201, format.c_str(), ImGuiSliderFlags_AlwaysClamp)) { setting = fps; return true; } diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 75af335a9..6baf42e7e 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -461,7 +461,7 @@ namespace hex::plugin::builtin { } { - auto targetFps = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.fps", 60); + auto targetFps = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.fps", 14); ImHexApi::System::setTargetFPS(targetFps); }