summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-11-10 11:36:17 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-11-10 11:36:24 +0100
commit3fddffee5f08e97d6b9509196d9800888b098bcf (patch)
treeaf2d10e6219e535fa96b02c50d3f40daeebb9729 /main
parent0ec88d181a5a5c3c3e791426b7fa01d44195ec8c (diff)
main: move update() into its own function
Diffstat (limited to 'main')
-rw-r--r--main/draw.cpp9
-rw-r--r--main/main-impl.hpp1
2 files changed, 9 insertions, 1 deletions
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;