diff options
| author | onelin <oscar@nelin.dk> | 2025-03-13 17:14:43 +0000 |
|---|---|---|
| committer | onelin <oscar@nelin.dk> | 2025-03-13 17:16:18 +0000 |
| commit | 02ddad3b34d57924fc4120d7ea633d6aef751027 (patch) | |
| tree | 856dfb4cbd702cb16c5c5b8aab5f83103e524b85 | |
| parent | c3bd31cf9f6e9a010eefed0a9b123becceeafd9f (diff) | |
Use delta relative to delta-time
| -rw-r--r-- | src/core/src/loop.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/src/loop.c b/src/core/src/loop.c index 15d6ae1..1663219 100644 --- a/src/core/src/loop.c +++ b/src/core/src/loop.c @@ -312,8 +312,14 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) { /* Main loop */ do { + /* frame_start is milliseconds since engine was initialized */ const f64 now = get_time(); + + /* dt measured in milliseconds */ const f64 dt = now - time; + + const f64 delta = dt / fps_cap; + time = now; glfwPollEvents(); @@ -344,6 +350,7 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) { // // /* update */ StateType next_state; + // TODO: maybe use delta instead? next_state = update_func(dt, (void*)(mem->data)); if (next_state != STATE_null) { |
