proper delta time
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 18 Dec 2021 00:17:43 +0000 (18:17 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 18 Dec 2021 00:17:43 +0000 (18:17 -0600)
src/main.onyx

index 2e3b9323f18408d2751f5afc45cae281bd06a416..f6cca9f408d61a8b730b4067f29fc3a88e3a284d 100644 (file)
@@ -303,9 +303,16 @@ draw :: () {
 }
 
 main_loop :: () {
+    last := glfwGetTime();
+    now  := last;
+
     while !glfwWindowShouldClose(window) {
         glfwPollEvents();
-        update(1.0f / 60);
+
+        now = glfwGetTime();
+        dt := now - last;
+        last = now;
+        update(~~dt);
         draw();
     }
 }