From a0ba0b39d8d5ea13f7050b91944b7e6a025bdae9 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sat, 6 Jan 2024 18:23:06 +0100 Subject: [PATCH] add fps reduced mode --- external/solanaceae_toxcore | 2 +- src/main_screen.cpp | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/external/solanaceae_toxcore b/external/solanaceae_toxcore index 54084b5..08b3d69 160000 --- a/external/solanaceae_toxcore +++ b/external/solanaceae_toxcore @@ -1 +1 @@ -Subproject commit 54084b5a53e1617ff9b0c225880b0f1d60fe65ea +Subproject commit 08b3d69c159ca93aaaf38b6ee06507aa0eefd403 diff --git a/src/main_screen.cpp b/src/main_screen.cpp index 0911819..f2ff869 100644 --- a/src/main_screen.cpp +++ b/src/main_screen.cpp @@ -119,6 +119,24 @@ bool MainScreen::handleEvent(SDL_Event& e) { return true; // forward? } + if ( + _fps_perf_mode <= 1 && ( + e.type == SDL_EVENT_MOUSE_MOTION || + e.type == SDL_EVENT_MOUSE_WHEEL || + e.type == SDL_EVENT_MOUSE_BUTTON_DOWN || + e.type == SDL_EVENT_MOUSE_BUTTON_UP || + e.type == SDL_EVENT_TEXT_INPUT || + e.type == SDL_EVENT_KEY_DOWN || + e.type == SDL_EVENT_KEY_UP || + e.type == SDL_EVENT_WINDOW_MOUSE_ENTER || + e.type == SDL_EVENT_WINDOW_MOUSE_LEAVE || + e.type == SDL_EVENT_WINDOW_FOCUS_GAINED || + e.type == SDL_EVENT_WINDOW_FOCUS_LOST + ) + ) { + _render_interval = 1.f/60.f; // TODO: magic + } + return false; } @@ -162,13 +180,13 @@ Screen* MainScreen::render(float time_delta, bool& quit) { // ImGui::Separator(); // why do we not need this???? if (ImGui::BeginMenu("Performance")) { { // fps - const auto targets = "normal\0power save\0"; + const auto targets = "normal\0reduced\0powersave\0"; ImGui::SetNextItemWidth(ImGui::GetFontSize()*10); ImGui::Combo("fps mode", &_fps_perf_mode, targets, 4); } { // compute - const auto targets = "normal\0power save\0"; + const auto targets = "normal\0powersave\0"; ImGui::SetNextItemWidth(ImGui::GetFontSize()*10); ImGui::Combo("compute mode", &_compute_perf_mode, targets, 4); ImGui::SetItemTooltip("Limiting compute can slow down things filetransfers."); @@ -189,7 +207,7 @@ Screen* MainScreen::render(float time_delta, bool& quit) { } if ( - _fps_perf_mode == 1 || // TODO: magic + _fps_perf_mode >= 1 || // TODO: magic _window_hidden ) { _render_interval = 1.f/4.f;