tried converting cube to sdl... and tried adding fps counter to 3bb
This commit is contained in:
parent
5b0900ca93
commit
763300daf0
16
3bb-1.lisp
16
3bb-1.lisp
|
@ -36,6 +36,9 @@
|
|||
(rotate-vertex (second tri) time)
|
||||
(rotate-vertex (third tri) time)))
|
||||
|
||||
(defparameter *last-time* nil)
|
||||
(defparameter *num-frames* 0)
|
||||
|
||||
(defun draw ()
|
||||
"draw a frame"
|
||||
(let* ((time (- (wall-time) *start-time*))
|
||||
|
@ -61,7 +64,18 @@
|
|||
|
||||
;; finish the frame
|
||||
(gl:flush)
|
||||
(sdl:update-display)))
|
||||
(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))))
|
||||
|
||||
|
||||
(format t "FPS since last:~a->~a since start:~a/~a->~a ~%" short-interval short-fps *num-frames* long-interval long-fps))))
|
||||
|
||||
(setf *last-time* (wall-time)))
|
||||
|
||||
|
||||
|
||||
|
|
23
cube.lisp
23
cube.lisp
|
@ -1,3 +1,9 @@
|
|||
(defmacro restartable (&body body)
|
||||
`(restart-case
|
||||
(progn ,@body)
|
||||
(continue () :report "Continue")))
|
||||
|
||||
|
||||
(defparameter *light-diffuse* (vector 1.0 0.0 0.0 1.0)) ;; red diffuse light
|
||||
(defparameter *light-position* (vector 1.0 1.0 1.0 0.0)) ;; infinite light position
|
||||
|
||||
|
@ -27,10 +33,13 @@
|
|||
(dotimes (x 4)
|
||||
(gl:vertex (3delt face x *v* 0) (3delt face x *v* 1) (3delt face x *v* 1)))))))
|
||||
|
||||
(cffi:defcallback display :void ()
|
||||
;(cffi:defcallback display :void ()
|
||||
(defun display ()
|
||||
(gl:clear :color-buffer-bit :depth-buffer-bit)
|
||||
(draw-box)
|
||||
;;glut:swap-buffers
|
||||
(gl:flush)
|
||||
(sdl:update-display)
|
||||
)
|
||||
|
||||
(defun init ()
|
||||
|
@ -55,7 +64,7 @@
|
|||
(gl:rotate 60 1.0 0.0 0.0)
|
||||
(gl:rotate -20 0.0 0.0 1.0))
|
||||
|
||||
(defun cube-main ()
|
||||
(defun cube-main-glut ()
|
||||
(glut:init "Cube")
|
||||
(glut:init-display-mode :double :rgb :depth)
|
||||
(glut:create-window "red 3D lighted cube")
|
||||
|
@ -63,4 +72,12 @@
|
|||
(init)
|
||||
(glut:main-loop)
|
||||
)
|
||||
|
||||
|
||||
(defun cube-main-sdl ()
|
||||
(sdl:with-init ()
|
||||
(sdl:window 320 240 :flags sdl:sdl-opengl)
|
||||
(setf cl-opengl-bindings:*gl-get-proc-address* #'sdl-cffi::sdl-gl-get-proc-address)
|
||||
(sdl:with-events ()
|
||||
(:quit-event () t)
|
||||
(:idle ()
|
||||
(restartable (display))))))
|
Loading…
Reference in New Issue