sketch
sketch copied to clipboard
Not reinitializing vao
In the guide here http://onrendering.blogspot.no/2011/10/buffer-object-streaming-in-opengl.html it shows that after orphaning the buffer you need to reset your vao. In sketch currently it is only rebound.
instead something like this should be added to glkit
(defun reinit-vao (vao)
(with-slots ((vao-type type) id vbos vertex-count) vao
(with-slots (groups) vao-type
(loop for group across groups
as vbo-offset = 0 then (+ vbo-offset vbo-count)
as vbo-count = (vao-vbo-count group)
as vbo-subset = (make-array vbo-count :displaced-to vbos
:displaced-index-offset vbo-offset)
as attr-offset = 0 then (+ attr-offset attr-count)
as attr-count = (vao-attr-count group)
do (loop for i from 0 below (vao-attr-count group)
do (%gl:enable-vertex-attrib-array (+ i attr-offset)))
(vao-set-pointers group attr-offset vertex-count vbo-subset)))))
and this be called from start-draw, as in:
(defun start-draw ()
(%gl:bind-buffer :array-buffer 1)
(%gl:buffer-data :array-buffer *buffer-size* (cffi:null-pointer) :stream-draw)
(setf (env-buffer-position *env*) 0)
(kit.gl.vao:vao-bind (env-vao *env*))
(kit.gl.vao::reinit-vao (env-vao *env*)))
This has been working but I think only because there is only one vao.
not sure if this is related but
(%gl:bind-buffer :array-buffer 1)
only works because there is a single VBO for the entire time, named 1
(let ((the-vbo (aref (slot-value (env-vao *env*) 'kit.gl.vao::vbos) 0)))
(%gl:bind-buffer :array-buffer the-vbo))
Hey @gregcman ! I wanted to look at your linked example, but it appears to be removed from github. Is it available on a branch somewhere?
I think it can be found here: https://github.com/gregcman/sucle/tree/1e95ca02beabc624f9f6c89308217de4229d7817/application/subsystems/sketch-sucle