summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-26 14:00:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-26 14:00:24 +0200
commit5da376bc5f06f47bc4a7b0c5502ca9877f0d8945 (patch)
treecb0886756e40a2a40dcfa981037e0508df174e48 /main
parentec53e1734036b35f93ec142a0a3e9ce4e8bbb3f3 (diff)
throttle framerate only with vsync on
Diffstat (limited to 'main')
-rw-r--r--main/setup.cpp16
1 files 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;