I'm writing an OpenGL application, and the problem I'm facing now is as follows:
Let us say I have a Vertex Array, with its ID. However, I do not have its bound vertex buffer ID at hand. I am in need of the Buffer ID for an operation. SO, is it possible to retrieve current buffer binding from vertex array?
Note that I have come across glGetIntegerv
, however I think it only retrieves current buffer binding, NOT vertex array binding
CodePudding user response:
Let us say I have a Vertex Array, with its ID. However, I do not have its bound vertex buffer ID at hand.
In a well-behaved application, that should not be possible. It was your application that put that buffer into that VAO. Therefore, you should already know what buffer is attached to it. It's a question you don't need to ask.
However, if you have no other choice but to ask OpenGL a question that you ought to know the answer to, you must first bind the VAO to the context. If you're not using the separate attribute format API, then you can use glGetVertexAttribiv
with GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
, specifying the attribute index you're interested in querying. If you want to use the separate attribute format API, you need to use glGetIntegeri_v
with GL_VERTEX_BINDING_BUFFER
, specifying the binding index to query.
If you're using DSA (which requires using the separate attribute format), then you can use glGetVertexArrayIndexediv
, with GL_VERTEX_BINDING_BUFFER
and the appropriate binding index.