-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3d-experiments.lisp
64 lines (62 loc) · 2.06 KB
/
3d-experiments.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(defpackage #:how.3d-experiments
(:use :cl))
(in-package :how.3d-experiments)
(defun render-cube (x y z length mode)
(flet ((v (x y z) (gl:vertex x y z)))
(gl:with-primitive mode
(v x y z)
(v (+ x length) y z)
(v (+ x length) (+ y length) z)
(v x (+ y length) z)
(v x y z)
(v (+ x length) y z)
(v (+ x length) y (+ z length))
(v x y (+ z length))
(v x y z)
(v x (+ y length) z)
(v x (+ y length) (+ z length))
(v x y (+ z length))
(v (+ x length) y z)
(v (+ x length) (+ y length) z)
(v (+ x length) (+ y length) (+ z length))
(v (+ x length) y (+ z length))
(v x (+ y length) z)
(v (+ x length) (+ y length) z)
(v (+ x length) (+ y length) (+ z length))
(v x (+ y length) (+ z length))
(v x y (+ z length))
(v (+ x length) y (+ z length))
(v (+ x length) (+ y length) (+ z length))
(v x (+ y length) (+ z length)))))
(defun 3d-test-1 ()
(let ((angle 0))
(sdl:with-init ()
(sdl:window 800 600
:title-caption "OpenGL Example"
:icon-caption "OpenGL Example"
:opengl t
:opengl-attributes '((:SDL-GL-DOUBLEBUFFER 1)))
(gl:viewport 0 0 800 600)
(gl:matrix-mode :projection)
(gl:load-identity)
(glu:perspective 45.0 (/ 800 600) 1.0 500.0)
(gl:matrix-mode :modelview)
(gl:load-identity)
(gl:clear-color 0 0 0 0)
(gl:translate 3 2 -60)
(sdl:with-events ()
(:quit-event () t)
(:key-down-event (:key key)
(when (sdl:key= key :sdl-key-escape) (sdl:push-quit-event)))
(:idle ()
(gl:clear :color-buffer-bit)
(gl:color 1 1 1)
(gl:rotate 1 1 1 1)
(gl:polygon-mode :front-and-back :fill)
(render-cube 10 10 0 5 :quads)
(gl:polygon-mode :front-and-back :line)
(render-cube 0 0 0 5 :quads)
(gl:polygon-mode :front-and-back :point)
(render-cube -10 -10 0 5 :quads)
(gl:flush)
(sdl:update-display))))))