-
Notifications
You must be signed in to change notification settings - Fork 24
/
vao.lisp
43 lines (36 loc) · 1004 Bytes
/
vao.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
;;;; entity.lisp
;;;; Please see the licence.txt for the CLinch
(in-package #:clinch)
(defparameter *current-vao* 0)
(defclass vao ()
((id
:reader id
:initform nil
:initarg :id)
(changed
:reader changed?
:initform t)
(manual-updating
:accessor manual-updating
:initform nil
:initarg :manual-updating)
(current-value
:initform (make-hash-table :test 'equal))))
(defmethod initalize-instance ((this vao))
(with-slots ((id id)) this
(unless id
(setf id (gl:gen-vertex-arrays 1)))))
(defmethod unload ((this vao) &key)
"Release buffer resources."
(trivial-garbage:cancel-finalization this)
(remove-uncollected this)
(! (when (slot-value this 'id)
(gl:delete-buffers (list (id this)))))
(setf (slot-value this 'id) nil))
(defmethod bind ((this vao))
(with-slots ((id id)) this
(when id
(gl:bind-buffer :array-buffer id))))
(defmethod unbind ((this vao))
(when (id this)
(gl:bind-buffer :array-buffer 0)))