2 (asdf:oos
'asdf
:load-op
'#:cl-glfw
)
7 (glfw:do-window
("Spinning Triangle" 640 480)
8 ((glfw:enable glfw
:+sticky-keys
+)
10 (setf t0
(glfw:get-time
)
13 (when (eql (glfw:get-key glfw
:+key-esc
+) glfw
:+press
+)
14 (return-from glfw
:do-window
))
16 (setf t1
(glfw:get-time
))
18 (when (or (> (- t1 t0
) 1)
20 (glfw:set-window-title
(format nil
"Spinning Triangle (~,1f FPS)" (/ frames
(- t1 t0
))))
26 (destructuring-bind (width height
) (glfw:get-window-size
)
27 (setf height
(max height
1))
28 (gl:viewport
0 0 width height
)
30 (gl:clear-color
0 0 0 0)
31 (gl:clear gl
:+color-buffer-bit
+)
33 (gl:matrix-mode gl
:+projection
+)
35 (glu:perspective
65 (/ width height
) 1 100)
36 (gl:matrix-mode gl
:+modelview
+)
42 (gl:translate-f
0 14 0)
45 (destructuring-bind (x y
) (glfw:get-mouse-pos
)
47 (gl:rotate-f
(+ (* x
0.3)
51 (gl:with-begin gl
:+triangles
+
52 (gl:color-3f
1 0 0) (gl:vertex-3f -
5 0 -
4)
53 (gl:color-3f
0 1 0) (gl:vertex-3f
5 0 -
4)
54 (gl:color-3f
0 0 1) (gl:vertex-3f
0 0 6)))))