From 3fddffee5f08e97d6b9509196d9800888b098bcf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 10 Nov 2022 11:36:17 +0100 Subject: main: move update() into its own function --- main/draw.cpp | 9 ++++++++- main/main-impl.hpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'main') diff --git a/main/draw.cpp b/main/draw.cpp index 86d93582..2249d703 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -131,7 +131,7 @@ bool main_impl::check_chunk_visible(const Vector2d& offset, const Vector2i& size return X + W > 0 && X < size[x] && Y + H > 0 && Y < size[y]; } -void main_impl::drawEvent() +void main_impl::do_update() { float dt = timeline.previousFrameDuration(); if (dt > 0) @@ -155,6 +155,12 @@ void main_impl::drawEvent() dt = std::clamp(dt, 1e-5f, std::fmaxf(1e-1f, dt_expected.value)); app.update(dt); +} + +void main_impl::drawEvent() +{ + do_update(); + _shader.set_tint({1, 1, 1, 1}); { @@ -196,6 +202,7 @@ void main_impl::drawEvent() } else dt_expected.jitter = 0; + timeline.nextFrame(); } diff --git a/main/main-impl.hpp b/main/main-impl.hpp index 9efdd2ae..2b69cb29 100644 --- a/main/main-impl.hpp +++ b/main/main-impl.hpp @@ -52,6 +52,7 @@ struct main_impl final : Platform::Sdl2Application, floormat_main [[maybe_unused]] void anyEvent(SDL_Event& event) override; void drawEvent() override; + void do_update(); void update_window_state(); bool is_text_input_active() const noexcept override; -- cgit v1.2.3