PDA

View Full Version : glBindBufferRange for (Vertex) Array buffers of VAOs?



stimulate
08-21-2017, 05:20 AM
With glBindBufferRange (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindBufferRange.xhtml) I can bind a range of a buffer object to a target binding point (one of the bindings of GL_UNIFORM_BUFFER in most of my cases). But how can I bind a range of a buffer object to a GL_ARRAY_BUFFER binding point of a VAO?
Do I have to use the offset in glVertexArrayVertexBuffer (https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindVertexBuffer.xhtml)?

I want to stream to a VAO array buffer and since I advance into the buffer with every upload I somehow have to tell the shader the range it is supposed to use each frame. The shader is accessing the buffer through vertex attributes.

Alfonse Reinheart
08-21-2017, 04:06 PM
VAOs do not have a "GL_ARRAY_BUFFER binding point". That is a context bind point, which is not associated with the VAO itself.


I want to stream to a VAO array buffer and since I advance into the buffer with every upload I somehow have to tell the shader the range it is supposed to use each frame.

No, you don't. The "range" of data used by a rendering command is implicit, based on the vertex data actually used by that rendering command. Indices could cause fetches from anywhere in the buffer. Or at least, anywhere after the base offset.

You can adjust the offset in `glVertexArrayVertexBuffer` of course, but that defines the location of the 0 index in the array. There is nothing to explicitly tell OpenGL the maximum distance of the bytes you may read.