forked from BradWBeer/clinch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewport.lisp
60 lines (49 loc) · 1.11 KB
/
viewport.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
;;;; node.lisp
;;;; Please see the licence.txt for the CLinch
(in-package #:clinch)
(defclass viewport ()
((x
:initform 0
:initarg :x
:accessor x)
(y
:initform 0
:initarg :y
:accessor y)
(width
:initform 0
:initarg :width
:accessor width)
(height
:initform 0
:initarg :height
:accessor height)
(children
:initform nil
:initarg :children
:accessor children)))
(defmethod resize ((this viewport) x y w h)
(setf (x this) x
(y this) y
(width this) w
(height this) h)
(gl:viewport x y w h))
(defmethod render ((this viewport) &key)
(with-accessors ((x x)
(y y)
(w width)
(h height)) this
(gl:viewport x y w h)
(loop for c in (children this)
if (active c)
do (render c :w (width this) :h (height this)))))
(defmethod quick-set ((this viewport) x y w h)
(setf (x this) x
(y this) y
(width this) w
(height this) h))
(defmethod add-child ((this viewport) child &key)
(with-accessors ((children children)) this
(unless (member child children)
(setf children
(cons child children)))))