I have a problem understanding association between VAO and buffer bound to GL_ELEMENT_ARRAY_BUFFER
(let's call it EBO). I got to know that it is part of VAO state, but differ from buffers used along with glVertexAttribPointer
calls (those buffers are simply remembered by VAO as attributes storage omitting need to bind them - if I understood correctly).
In this discussion it is claimed:
Unlike GL_ARRAY_BUFFER, a VAO store the current binding for GL_ELEMENT_ARRAY_BUFFER. Calling glBindBuffer(GL_ELEMENT_ARRAY_BUFFER) stores a reference to the specified buffer in the currently-bound VAO. glDrawElements() etc take the vertex indices from the buffer stored in the currently-bound VAO. So switching between VAOs switches between element arrays.
But do I need to call glBindBuffer(GL_ELEMENT_ARRAY_BUFFER)
between bind and unbind of VAO to make sure it will 'save' it in its state or VAO will just take currently bound EBO when VAO gets created?
Also the answer quoted above isn't clear to me whether VAO just 'knows' (as attribute storage buffers) which buffer indices (glDrawElements
) have to be taken from or does VAO binds proper EBO when VAO gets bound?
edit: First of my questions has been answered here, however I believe the second one was answered by @Rabbid76.