arekkusu, thanks for the tip.
I found ARRAY_BUFFER_BINDING in section 2.9.6 of the 3.2core spec. The spec isn’t very clear. ARRAY_BUFFER_BINDING is mentioned only once: “For example, the VertexAttribPoint command copies the value of ARRAY_BUFFER_BINDING (the queriable name of the buffer binding corresponding to the target ARRAY_BUFFER) to the client state variable VERTEX_ATTRIB_ARRAY_BUFFER_BINDING for the specified index.”
This is the only place that I could find ARRAY_BUFFER_BINDING mentioned in the text of the spec. It has a value which apparently corresponds to the “queriable name of the buffer binding corresponding to the target ARRAY_BUFFER.”
I know what a buffer is. But what is a buffer binding? It is first mentioned on the top of page 44 but the term is not defined. I searched Google but also came up short for a definition. Whatever it is, it is an integer and apparently has a name.
Table 6.6 does include ARRAY_BUFFER_BINDING and says that it is a positive integer, has an initial value of 0, and is described as the “current buffer binding.”
Section 2.9.1 describes creating and binding buffer objects. I am guessing that a call to BindBuffer creates a buffer binding. However, the spec doesn’t explicitly say if this is the case. Table 6.6 provides some hints. The caption of table 6.6 says, “Vertex Array Data (not in Vertex Array objects).” There are four rows in the table. As already mentioned, one of the four rows contains ARRAY_BUFFER_BINDING. So, it appears that ARRAY_BUFFER_BINDING is the name of a state variable that is not stored in a VAO. Its value is the name of the current buffer binding. Now, GenBuffers reserves and returns buffer object names. Let’s see if we can put this all together.
A call to GenBuffers returns one or more buffer object names. At the time GenBuffers is called, a buffer object name is reserved but no buffer has been bound. To bind a buffer we need to call BindBuffer and pass a target (in this case the value ARRAY_BUFFER) and a buffer object name. At this point a buffer has been created, associated with a name, and bound to the target.
A side effect of calling BindBuffer is the setting of state variable(s). One state variable is referred to as ARRAY_BUFFER_BINDING. Its value is set to the name of the buffer object that was passed to BindBuffer. The state variable appears to have global scope because it is not stored in any VAO according to table 6.6.
It seems that this scenario could be represented as follows:
// The function BindBuffer
IF (target == ARRAY_BUFFER)
GlobalState[ARRAY_BUFFER_BINDING] = name;
// get a bunch of buffer object names
// get one of the buffer object names
name = buffers[i];
// bind the buffer object name to the target ARRAY_BUFFER