From 5da376bc5f06f47bc4a7b0c5502ca9877f0d8945 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Oct 2022 14:00:19 +0200 Subject: throttle framerate only with vsync on --- main/setup.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main/setup.cpp b/main/setup.cpp index 428a797b..36e2b78a 100644 --- a/main/setup.cpp +++ b/main/setup.cpp @@ -97,15 +97,15 @@ void main_impl::update_window_state() dt_expected.jitter = 0; if (flags & SDL_WINDOW_HIDDEN) dt_expected.value = 1; - else if (!(flags & SDL_WINDOW_INPUT_FOCUS)) - dt_expected.value = 1.f / 30; else if (int interval = std::abs(SDL_GL_GetSwapInterval()); - s.vsync >= fm_tristate::maybe && interval > 0) - dt_expected.value = 0.5f / (get_window_refresh_rate(window())); -#if 1 - else if (!(flags & SDL_WINDOW_MOUSE_FOCUS)) - dt_expected.value = 1.f / 60; -#endif + s.vsync >= fm_tristate::maybe && interval > 0) + { + int hz = get_window_refresh_rate(window()) / interval; + if (!(flags & SDL_WINDOW_INPUT_FOCUS)) + dt_expected.value = 2.f / hz; + else + dt_expected.value = 0.95f / hz; + } else { dt_expected.do_sleep = false; -- cgit v1.2.3