Here is the formal declaration for glBufferData
which is used to populate a VBO:
void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
What is confusing, however, is that you can have multiple VBOs, but this function does not require a handle to a particular VBO, so how does it know which VBO you are intending?
The target
parameter can be either GL_ARRAY_BUFFER
or GL_ELEMENT_ARRAY_BUFFER
but my understanding is that you can have more than one of each of these.
The same is true of the similar glBufferSubData
method, which is intended to be called subsequent times on a VBO -- how does it know which VBO to handle?
OpenGL operations that use a buffer object, make use of the buffer that has been bound by the most recent call to glBindBuffer on the used target.
This is a common pattern in OpenGL to bind object to a target and perform operations on it by issuing function calls without a handle. The same applies to the textures.
glBindBuffer
is a function that exposes the given buffer as bound. Such aglBufferData
access it then by side-effect, through the currently bound buffer object.