Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not reinitializing vao #20

Open
cbaggers opened this issue May 22, 2017 · 3 comments
Open

Not reinitializing vao #20

cbaggers opened this issue May 22, 2017 · 3 comments
Labels

Comments

@cbaggers
Copy link
Contributor

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.

@gregcman
Copy link

gregcman commented Apr 8, 2019

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))

modified version of sketch supporting multiple overlapping defsketches, using pure common lisp zpb-ttf, vecto, opticl and glfw rather sdl2-ttf, sdl2-image, and sdl2, which means the user can just do (ql:quickload :sketch) and not have to install anything [for most platforms]

@vydd vydd added the bug label Oct 16, 2022
@vydd
Copy link
Owner

vydd commented Nov 6, 2022

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?

@Gleefre
Copy link
Contributor

Gleefre commented Oct 21, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants