From edaa8fb42b37ee75f3322059597c6583131a1518 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Mon, 16 Nov 2020 14:48:15 +0100 Subject: [PATCH] Add a mechanism to avoid blank window at startup --- data/core/init.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/data/core/init.lua b/data/core/init.lua index fe74b34..fd0b70e 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -450,12 +450,20 @@ end) function core.run() + local idle_iterations = 0 while true do core.frame_start = system.get_time() local did_redraw = core.step() local need_more_work = run_threads() if not did_redraw and not need_more_work then - system.wait_event() + idle_iterations = idle_iterations + 1 + -- do not wait of events at idle_iterations = 1 to give a chance at core.step to run + -- and set "redraw" flag. + if idle_iterations > 1 then + system.wait_event() + end + else + idle_iterations = 0 end local elapsed = system.get_time() - core.frame_start system.sleep(math.max(0, 1 / config.fps - elapsed))