Skip to content
Permalink
Browse files

Move vertex-form to vao, which is a much better place, honestly.

  • Loading branch information...
Shinmera committed Aug 1, 2019
1 parent f824faa commit 19890c4ef2b070d11ca6d83b0f303777e11870e8
Showing with 11 additions and 7 deletions.
  1. +4 −0 geometry.lisp
  2. +2 −3 helpers.lisp
  3. +4 −2 resources/vertex-array.lisp
  4. +1 −2 workbench.lisp
@@ -210,6 +210,10 @@
mesh :attributes attributes))

(defmethod update-instance-for-different-class ((mesh vertex-mesh) (array vertex-array) &key (data-usage :static-draw) (attributes T))
(setf (vertex-form array) (ecase (face-length mesh)
(1 :points)
(2 :lines)
(3 :triangles)))
(if (< 0 (length (vertices mesh)))
(let* ((primer (aref (vertices mesh) 0))
(attributes (etypecase attributes
@@ -66,8 +66,7 @@
(flare:update clocked-subject))

(define-shader-entity vertex-entity ()
((vertex-array :initarg :vertex-array :accessor vertex-array)
(vertex-form :initarg :vertex-form :initform :triangles :accessor vertex-form)))
((vertex-array :initarg :vertex-array :accessor vertex-array)))

(defmethod paint ((subject vertex-entity) (pass shader-pass))
(let ((program (shader-program-for-pass pass subject)))
@@ -76,7 +75,7 @@
(setf (uniform program "projection_matrix") (projection-matrix)))
(let ((vao (vertex-array subject)))
(gl:bind-vertex-array (gl-name vao))
(%gl:draw-elements (vertex-form subject) (size vao) :unsigned-int 0)
(%gl:draw-elements (vertex-form vao) (size vao) :unsigned-int 0)
(gl:bind-vertex-array 0)))

(define-class-shader (vertex-entity :vertex-shader)
@@ -8,9 +8,11 @@

(defclass vertex-array (gl-resource)
((size :initarg :size :initform NIL :accessor size)
(bindings :initarg :bindings :accessor bindings))
(bindings :initarg :bindings :accessor bindings)
(vertex-form :initarg :vertex-form :accessor vertex-form))
(:default-initargs
:bindings (error "BINDINGS required.")))
:bindings (error "BINDINGS required.")
:vertex-form :triangles))

(defmethod print-object ((array vertex-array) stream)
(print-unreadable-object (array stream :type T :identity T)
@@ -34,8 +34,7 @@

(define-shader-subject grid (vertex-entity colored-entity)
()
(:default-initargs :vertex-array (asset 'workbench 'grid)
:vertex-form :lines))
(:default-initargs :vertex-array (asset 'workbench 'grid)))

(define-handler (cube tick) (ev)
(incf (vz (rotation cube)) (vel cube)))

0 comments on commit 19890c4

Please sign in to comment.
You can’t perform that action at this time.