diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-07-08 23:09:16 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-07-08 23:09:16 +0200 |
commit | 7392c2c9fc7d7ecf640dd6688be2599f031f2c6f (patch) | |
tree | 9db1ddf38f0fd1ed959a942a2cfc8750f527c9a3 | |
parent | bc67d0600b6e5f0f01344122cc741804623e0a8e (diff) |
Rework FPS log is correct and add possible FPSs
-rw-r--r-- | bytepusher.scm | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/bytepusher.scm b/bytepusher.scm index 0db879b..fde6230 100644 --- a/bytepusher.scm +++ b/bytepusher.scm @@ -183,13 +183,19 @@ (load-display! texture) (render-copy renderer texture) (present-renderer renderer) - (let ((t1 (sdl-ticks))) - (unless (> t1 (+ t0 1000/60)) - (usleep (floor (* 1000 (- (+ t0 1000/60) t1)))))) - (display (string-append - "FPS: " - (number->string - (exact->inexact (/ 1000 (- (sdl-ticks) t0)))) "\n"))) + (let* ((t1 (sdl-ticks)) + (frame-time (exact->inexact 1000/60)) + (max-time (+ t0 frame-time))) + (when (> max-time t1) + (usleep (inexact->exact (floor (* 1000 (- max-time t1)))))) + (display (string-append + "FPS: " + (number->string + (exact->inexact (/ 1000 (- (sdl-ticks) t0)))) + "(" + (number->string + (exact->inexact (/ 1000 (- t1 t0)))) + ")\n")))) (loop))) (define (main) |