-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshapes.lisp
75 lines (65 loc) · 1.66 KB
/
shapes.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
65
66
67
68
69
70
71
72
73
74
75
;;
;; Lire - low-level drawing
;;
(in-package :lire)
(defmacro define-textured (fname &body body)
`(defun ,fname (texture x y rotation scale-x scale-y)
(gl:bind-texture :texture-2d texture)
(gl:push-matrix)
(gl:translate x y 0)
(gl:rotate rotation 0 0 1)
(gl:scale scale-x scale-y 1)
,@body
(gl:end)
(gl:pop-matrix)))
(defmacro define-shape (fname &body body)
`(defun ,fname (x y rotation scale-x scale-y)
(gl:bind-texture :texture-2d 0)
(gl:push-matrix)
(gl:translate x y 0)
(gl:rotate rotation 0 0 1)
(gl:scale scale-x scale-y 1)
,@body
(gl:end)
(gl:pop-matrix)))
(define-textured quad-textured
(gl:begin :triangle-fan)
(gl:tex-coord 0 0) (gl:vertex -1 -1)
(gl:tex-coord 1 0) (gl:vertex 1 -1)
(gl:tex-coord 1 1) (gl:vertex 1 1)
(gl:tex-coord 0 1) (gl:vertex -1 1))
(define-shape quad-shape
(gl:begin :triangle-fan)
(gl:vertex -1 -1)
(gl:vertex 1 -1)
(gl:vertex 1 1)
(gl:vertex -1 1))
(define-shape aligned-quad-shape
(gl:begin :triangle-fan)
(gl:vertex 0 0)
(gl:vertex 1 0)
(gl:vertex 1 1)
(gl:vertex 0 1))
(define-shape quad-lines
(gl:begin :line-loop)
(gl:vertex -1 -1)
(gl:vertex 1 -1)
(gl:vertex 1 1)
(gl:vertex -1 1))
(define-shape aligned-quad-lines
(gl:begin :line-loop)
(gl:vertex 0 0)
(gl:vertex 1 0)
(gl:vertex 1 1)
(gl:vertex 0 1))
(defun simple-line (x1 y1 x2 y2)
(gl:bind-texture :texture-2d 0)
(gl:begin :lines)
(gl:vertex x1 y1)
(gl:vertex x2 y2)
(gl:end))
(defun simple-cross (x y size)
(simple-line (- x size) y
(+ x size) y)
(simple-line x (- y size)
x (+ y size)))