From 40ea4b0665dc747fe5dfb09b4d5a8444a3c24cc4 Mon Sep 17 00:00:00 2001 From: 0scar Date: Tue, 13 Feb 2024 10:25:00 +0100 Subject: Show FPS for 1 sec Before we showed cumulative fps --- src/core/src/loop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/src/loop.c b/src/core/src/loop.c index ac82603..e8dfc47 100644 --- a/src/core/src/loop.c +++ b/src/core/src/loop.c @@ -319,6 +319,7 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) { StateType (*update_func)(f64,void*) = State_updateFunc(state); f64 last_fps_measurement = get_time(); + f64 last_fps_ticks = 0; /* Main loop */ do { @@ -327,8 +328,9 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) { time = now; if (now - last_fps_measurement > 1.000) { + printf("\n FPS: %.1f \t ticks: %lu", (double)(ticks - last_fps_ticks) / (now - last_fps_measurement), ticks); last_fps_measurement = now; - printf("\n FPS: %.1f \t ticks: %lu", (double)ticks / now, ticks); + last_fps_ticks = ticks; } glfwPollEvents(); -- cgit v1.3