summaryrefslogtreecommitdiffhomepage
path: root/main/draw.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-01 19:33:40 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-01 19:44:18 +0100
commitf9767c694e85fe774a68072f10facc5fcf4c6403 (patch)
tree2da67803cdd7ca26c2e1e67bf36d69225e4a00a0 /main/draw.cpp
parente25a350f907a3833b39b8a7629a4a880fe7b0df4 (diff)
main: reorganize frame timing code
Diffstat (limited to 'main/draw.cpp')
-rw-r--r--main/draw.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/main/draw.cpp b/main/draw.cpp
index 9409d66c..d2fde66e 100644
--- a/main/draw.cpp
+++ b/main/draw.cpp
@@ -13,6 +13,13 @@
namespace floormat {
+namespace {
+
+size_t bad_frame_counter = 0;
+
+} // namespace
+
+
void main_impl::do_update()
{
constexpr auto eps = 1e-5f;
@@ -22,13 +29,14 @@ void main_impl::do_update()
#if 1
constexpr float RC = 60;
constexpr auto alpha = 1 / (1 + RC);
- _smoothed_frame_time = _smoothed_frame_time * (1 - alpha) + alpha * secs;
+ auto& value = _frame_timings.smoothed_frame_time;
+
+ value = value*(1 - alpha) + alpha * secs;
#else
- _frame_time = secs;
+ value = secs;
#endif
- static size_t ctr = 0;
if (secs > 35e-3f /* && !dt_expected.do_sleep */)
- fm_debug("%zu frame took %.2f milliseconds", ctr++, (double)secs*1e3);
+ fm_debug("%zu frame took %.2f milliseconds", bad_frame_counter++, (double)secs*1e3);
}
else
swapBuffers();