🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How do I determine what VBO is being used by a VAO

Started by
2 comments, last by Tyranna 3 years ago

I need to bind a VAO , and then determine what VBO it is referencing.

I am trying to use transform feedback , so I need to get the buffer size to allocate storage for the transform buffer.

I have bound the VAO , but calls to:

glGetBufferParameteriv( GL_ARRAY_BUFFER , GL_BUFFER_SIZE , &nBufferSize );

cause:

GL_INVALID_OPERATION in glGetBufferParameteriv(no buffer bound)

Advertisement

As far as I remeber correctly, VBOs are attached to vertex attributes, since you can have more than one VBO and also several other kinds of buffers like an index buffer attached to the VAO. So you have to determine the attribute the buffer is attached to first to get it's ID.

Something like

int attributes; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &attributes);
glBindVertexArray(vaoId);

for (int i = 0; i < attributes; i++) 
{
    int id; glGetVertexAttribiv(i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &id);
    if (id > 0) 
    {
        //Do yout thing
    }
}

should work to iterate all buffers attached to your VAO.

Also make sure to be on a propper GL version to use this

Thanks, that is what I was looking for!

This topic is closed to new replies.

Advertisement