diff --git a/3bb-1.lisp b/3bb-1.lisp index ce59758..64fd758 100644 --- a/3bb-1.lisp +++ b/3bb-1.lisp @@ -10,7 +10,7 @@ (+ (* (get-internal-real-time) time-units) offset))) -(defvar *start-time* (wall-time)) +(defparameter *start-time* (wall-time)) (defun shift-color (time) (values @@ -66,20 +66,23 @@ (gl:flush) (sdl:update-display) (incf *num-frames*) - ;(if (not (eql (floor *last-time*) time)) - (let* ((short-interval (- time (if *last-time* *last-time* time))) - (long-interval (- time *start-time*)) - (short-fps (if (zerop short-interval) 0 (/ 1 short-interval))) - (long-fps (if (zerop long-interval) 0 (/ *num-frames* long-interval)))) + (if (not (eql (floor *last-time*) (floor time))) + (let* ((short-interval (- time *last-time* )) + (long-interval time) + (short-fps (floor (if (zerop short-interval) 0 (/ 1 short-interval)))) + (long-fps (floor (if (zerop long-interval) 0 (/ *num-frames* long-interval))))) - (format t "FPS since last:~a->~a since start:~a/~a->~a ~%" short-interval short-fps *num-frames* long-interval long-fps)))) + (format t "FPS since last:(~a - ~a) ~a->~a since start:~a/~a)->~a ~%" time *last-time* short-interval short-fps *num-frames* long-interval long-fps))) - (setf *last-time* (wall-time))) + (setf *last-time* time))) (defun main-loop () + (setf *start-time* (wall-time)) + (setf *num-frames* 0) + (setf *last-time* 0) (sdl:with-init () (sdl:window 320 240 :flags sdl:sdl-opengl) ;; cl-opengl needs platform specific support to be able to load GL