Add a mechanism to avoid blank window at startup
This commit is contained in:
parent
a0e3ab7933
commit
edaa8fb42b
|
@ -450,13 +450,21 @@ end)
|
||||||
|
|
||||||
|
|
||||||
function core.run()
|
function core.run()
|
||||||
|
local idle_iterations = 0
|
||||||
while true do
|
while true do
|
||||||
core.frame_start = system.get_time()
|
core.frame_start = system.get_time()
|
||||||
local did_redraw = core.step()
|
local did_redraw = core.step()
|
||||||
local need_more_work = run_threads()
|
local need_more_work = run_threads()
|
||||||
if not did_redraw and not need_more_work then
|
if not did_redraw and not need_more_work then
|
||||||
|
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()
|
system.wait_event()
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
idle_iterations = 0
|
||||||
|
end
|
||||||
local elapsed = system.get_time() - core.frame_start
|
local elapsed = system.get_time() - core.frame_start
|
||||||
system.sleep(math.max(0, 1 / config.fps - elapsed))
|
system.sleep(math.max(0, 1 / config.fps - elapsed))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue