Reputation: 25
I'm currently working with OpenGL in C++, and I'm trying to debug by identifying what the currently bound vertex buffer and index buffer are. I have three functions.
GLint getBoundVAO()
{
GLint id = 0;
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &id);
return id;
};
GLint getBoundVBO()
{
GLint id = 0;
// ???
return id;
};
GLint getBoundIBO()
{
GLint id = 0;
// ???
return id;
};
How would I go about getting the vertex buffer and index buffer in a similar way to how I am getting the VAO? I've looked at the OpenGL page https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGet.xhtml and am not seeing a value which will allow me to get the index or vertex buffers.
Upvotes: 1
Views: 1974
Reputation: 3812
See the "Parameters" section here. The symbolic constants used for binding the buffers match the ones used for glGet* (but with a _BINDING suffix).
For the vertex buffer object, use:
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &id);
For the index buffer, use:
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &id);
Upvotes: 1