From 71292a1995317d485246e4afd661217981135a6f Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Wed, 31 Jul 2024 18:24:21 +0300 Subject: [PATCH] main.c: proper fix for render frame drops --- townengine/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/townengine/main.c b/townengine/main.c index 82eb017..638f7ea 100644 --- a/townengine/main.c +++ b/townengine/main.c @@ -144,8 +144,11 @@ static void main_loop(void) { } /* finally, let's get to work */ + int frames = 0; while (ctx.frame_accumulator >= ctx.desired_frametime * ctx.update_multiplicity) { + frames += 1; for (size_t i = 0; i < ctx.update_multiplicity; ++i) { + /* TODO: disable rendering pushes on not-last ? */ render_queue_clear(); poll_events(); @@ -163,9 +166,11 @@ static void main_loop(void) { ctx.frame_accumulator -= ctx.desired_frametime; ctx.tick_count = (ctx.tick_count % ULLONG_MAX) + 1; - render(); } } + + if (frames != 0) + render(); }