-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrectangle.lisp
47 lines (40 loc) · 1.15 KB
/
rectangle.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
(require "~/quicklisp/setup.lisp")
(ql:quickload "cl-opengl")
(defclass rectangle ()
((x :initarg :x
:accessor x
:initform 0)
(y :initarg :y
:accessor y
:initform 0)
(width :initarg :width
:accessor width
:initform 0)
(height :initarg :height
:accessor height
:initform 0)))
(defun create-rectangle (x y width height)
(make-instance 'rectangle :x x :y y :width width :height height))
(defmethod print-object ((rect rectangle) stream)
(format stream "(~a, ~a, ~a, ~a)" (x rect) (y rect) (width rect) (height rect)))
(defun draw-rectangle ((rect rectangle))
(let ((x (x rect))
(y (y rect))
(w (width rect))
(h (height rect)))
; (gl:with-primitives :quads
; (gl:color 0.0 0.0 0.0)
; (gl:vertex x y 0.0)
; (gl:vertex (+ x w) y 0.0)
; (gl:vertex (+ x w) (+ y h) 0.0)
; (gl:vertex x (+ y h) 0.0))
(incf x)
(incf y)
(decf w)
(decf h)
(gl:with-primitives :quads
(gl:color 1.0 1.0 1.0)
(gl:vertex x y 0.0)
(gl:vertex (+ x w) y 0.0)
(gl:vertex (+ x w) (+ y h) 0.0)
(gl:vertex x (+ y h) 0.0))))