Fix the clocking system and add an fps counter
This commit is contained in:
parent
e80c9ce69a
commit
ad0f6a0eb8
3 changed files with 18 additions and 8 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
(in-package :stoe.debug)
|
(in-package :stoe.debug)
|
||||||
|
|
||||||
(defvar *swank-server-port* 4006)
|
(defvar *swank-server-port* 4006)
|
||||||
|
(defvar *frames-per-second* 0.0)
|
||||||
|
|
||||||
(defun initialize (&optional argv)
|
(defun initialize (&optional argv)
|
||||||
"Initialize the debug module.
|
"Initialize the debug module.
|
||||||
|
|
@ -31,12 +32,20 @@ start the swank server to accept remote connection."
|
||||||
(add-hook modules:*initialize-hook* #'initialize)
|
(add-hook modules:*initialize-hook* #'initialize)
|
||||||
(add-hook modules:*finalize-hook* #'finalize)
|
(add-hook modules:*finalize-hook* #'finalize)
|
||||||
|
|
||||||
(defun update (delta-time)
|
(let ((time-counter 0.0)
|
||||||
"Eval the repl each frame."
|
(frames-counter 0))
|
||||||
#+swank
|
(defun update (delta-time)
|
||||||
(let ((conn (or swank::*emacs-connection*
|
"Eval the repl each frame."
|
||||||
(swank::default-connection))))
|
#+swank
|
||||||
(when conn
|
(let ((conn (or swank::*emacs-connection*
|
||||||
(swank::handle-requests conn t))))
|
(swank::default-connection))))
|
||||||
|
(when conn
|
||||||
|
(swank::handle-requests conn t)))
|
||||||
|
(incf time-counter delta-time)
|
||||||
|
(incf frames-counter)
|
||||||
|
(when (> time-counter 1000000.0)
|
||||||
|
(setf *frames-per-second* frames-counter)
|
||||||
|
(setf time-counter 0.0)
|
||||||
|
(setf frames-counter 0))))
|
||||||
|
|
||||||
(add-hook modules:*update-hook* #'update)
|
(add-hook modules:*update-hook* #'update)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
continue unless `unprotected' is t."
|
continue unless `unprotected' is t."
|
||||||
(setf exit-main-loop nil)
|
(setf exit-main-loop nil)
|
||||||
(let ((clock (make-clock)))
|
(let ((clock (make-clock)))
|
||||||
|
(update-current-time)
|
||||||
(loop while (not exit-main-loop)
|
(loop while (not exit-main-loop)
|
||||||
do (restartable unprotected
|
do (restartable unprotected
|
||||||
(update-current-time)
|
(update-current-time)
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@
|
||||||
"Update clock using `sec' and `usec' values passed as parameter."
|
"Update clock using `sec' and `usec' values passed as parameter."
|
||||||
(unless (clock-paused clock)
|
(unless (clock-paused clock)
|
||||||
(setf (clock-last-time clock) (clock-time clock))
|
(setf (clock-last-time clock) (clock-time clock))
|
||||||
(setf (clock-time clock) (* (or delta-time (get-delta-time)) (clock-scale clock)))))
|
(incf (clock-time clock) (* (or delta-time (get-delta-time)) (clock-scale clock)))))
|
||||||
|
|
||||||
(defun clock-delta (clock)
|
(defun clock-delta (clock)
|
||||||
(- (clock-time clock) (clock-last-time clock)))
|
(- (clock-time clock) (clock-last-time clock)))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue