4
$\begingroup$

I know that when you call glVertexAttribPointer, you are specifying how the buffer currently binded should take its own data. But if you can have binded one buffer per type (Let's say GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER) then, Are you specifying two buffers simultaneously? In this tutorial says:

glVertexAttribPointer always refers to whatever buffer is bound to GL_ARRAY_BUFFER at the time that this function is called. Therefore it does not take a buffer object handle; it simply uses the handle we bound previously.

If glVertexAttribPointer refers to the GL_ARRAY_BUFFER buffer currently binded, How I call glVertexAttribPointer for the GL_ELEMENT_ARRAY_BUFFER buffer?

$\endgroup$
4
$\begingroup$

How I call glVertexAttribPointer for the GL_ELEMENT_ARRAY_BUFFER buffer?

You don't. The element array buffer is used to store vertex indices, not vertex attribute data and therefore it doesn't have attribute pointers. The count, size, and offset for index data is specified in the draw call, e.g. glDrawElements.

$\endgroup$
4
$\begingroup$

A VAO holds the attribute information. This means that for each attribute it has a buffer, offset, size, type, stride and whether it's normalized. Separately from those is the element buffer binding that is set by binding the GL_ELEMENT_ARRAY_BUFFER while the VAO is bound.

Yes that odd but the reason this is the case is because VAO's were added after VBO and EBO.

In 4.5 (or with the Direct_state_access extension) you can instead use glVertexArrayElementBuffer to directly set the element buffer of a vao.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.