Skip to content
Permalink
Browse files

Further improve buffer updating by handling replacement of vertex-arr…

…ays wholesale
  • Loading branch information...
Shinmera committed Oct 27, 2019
1 parent 764a145 commit f756f590264d83ff031c1ce854146a73d669c6c7
Showing with 12 additions and 6 deletions.
  1. +10 −0 geometry.lisp
  2. +2 −6 workbench.lisp
@@ -219,6 +219,16 @@
(resize-buffer buffer (* (length (buffer-data buffer)) (gl-type-size (element-type buffer))) :data (buffer-data buffer)))
buffer)

(defmethod replace-vertex-data ((array vertex-array) (mesh vertex-mesh) &key (attributes T) update)
(let ((buffers ()))
(dolist (binding (bindings array))
(pushnew (unlist binding) buffers))
(dolist (buffer buffers)
(replace-vertex-data buffer mesh :attributes attributes :update update)
(when (eq (buffer-type buffer) :element-array-buffer)
(setf (size array) (length (buffer-data buffer)))))
array))

(defmethod make-vertex-data ((mesh vertex-mesh) &key (attributes T))
;; Would be better if we didn't have to create an adjustable vector...
(replace-vertex-data (make-array 0 :adjustable T :element-type 'single-float)
@@ -25,12 +25,8 @@
(srad (+ (* (/ s 60) -2 PI) (/ PI 2)))
(mesh (make-lines (list (vec 0 0 0) (vec (* (cos hrad) 70) (* (sin hrad) 70) 0)
(vec 0 0 0) (vec (* (cos mrad) 90) (* (sin mrad) 90) 0)
(list (vec 0 0 0) (vec 1 0 0 1)) (list (vec (* (cos srad) 90) (* (sin srad) 90) 0) (vec 1 0 0 1)))))
(ebo (car (bindings (vertex-array simple-clock))))
(vbo (caadr (bindings (vertex-array simple-clock)))))
(replace-vertex-data ebo mesh :update T)
(replace-vertex-data vbo mesh :update T)
(setf (size (vertex-array simple-clock)) (length (buffer-data ebo)))))
(list (vec 0 0 0) (vec 1 0 0 1)) (list (vec (* (cos srad) 90) (* (sin srad) 90) 0) (vec 1 0 0 1))))))
(replace-vertex-data (vertex-array simple-clock) mesh :update T)))

(progn
(defmethod setup-scene ((workbench workbench) scene)

0 comments on commit f756f59

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