Element buffer binding is VAO or context state?


I’m getting pretty confused about what state is really element buffer binding.
According to my experience it is VAO state thus switching VAOs also switches element array buffer binding.
However, I’m now confused because AFAIK the GL spec language does not state this anywhere.
It says the following about what VAOs encapsulate:

The currently bound vertex array object is used for all commands which modify
vertex array state, such as VertexAttribPointer and EnableVertexAttribArray;
all commands which draw from vertex arrays, such as DrawArrays and DrawEle-
ments; and all queries of vertex array state (see chapter 6).

Also, I did not found in the GL core spec 4.1 any binding like ELEMENT_ARRAY_BUFFER_BINDING for them as it was ELEMENT_ARRAY_BUFFER_BINDING_ARB in the GL_ARB_vertex_buffer_object.

Can anybody clarify this to me?
Why there is no explicit wording about it in the spec?

Did you look at the state tables titled “Vertex Array Object state?”

// init
compile vao

// render
bind vao
bind array element

And there are pretty good reasons for that.
You often want to use same vertex arrays with different indexes, topologies, offsets or primitive count.

Thanks Alfonse. I was pretty sure this is the case but I was frustrated that I didn’t find the ELEMENT_ARRAY_BUFFER_BINDING in the spec. Maybe PDF search bug :smiley:

As a general rule when searching the spec PDFs: if you’re looking for a Get field, search won’t find it. For some reason, it can’t search the stuff in the state tables. Which means if the Get field isn’t mentioned in the text, the search can’t find it.

So if you’re looking for a Get, it’s best to just go straight to the source.

Thanks for the tip, didn’t realize this problem earlier.
Anyway, that means one more feature that’s missing from GL_EXT_direct_state_access :smiley: