<p>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 <code>GL_ELEMENT_ARRAY_BUFFER</code> while the VAO is bound.</p>

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

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

CC BY-SA 4.0
2022-09-25T11:51:54.837Z
This answer is very helpful. In Example 3.5 of the Ninth Edition of the OpenGL Programming Guide, the EBO is bound *before* the VAO is bound, which doesn't work on my computer. After reading this answer I switched the order, which made it work. In Joey de Vries' "learnopengl.com" website, the correct order is given.
Simon
CC BY-SA 3.0
2017-01-18T14:54:25.577Z
2017-01-18T14:54:25.577Z
ratchet freak
<blockquote>
  <p>How I call glVertexAttribPointer for the GL_ELEMENT_ARRAY_BUFFER buffer?</p>
</blockquote>

<p>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. <code>glDrawElements</code>.</p>

CC BY-SA 3.0
2017-01-17T21:52:15.573Z
2017-01-17T21:52:15.573Z
Nathan Reed
<p>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 <a href="http://alfonse.bitbucket.org/oldtut/Basics/Tut01%20Following%20the%20Data.html" rel="nofollow noreferrer">this</a> tutorial says:</p>

<blockquote>
  <p>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.</p>
</blockquote>

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

<opengl><vertex-buffer-object>
How glVertexAttribPointer works?
Adrian
# How glVertexAttribPointer works?

(Asked by: username_0 on 2017-01-17)

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](http://alfonse.bitbucket.org/oldtut/Basics/Tut01%20Following%20the%20Data.html) 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?

**Tags:** opengl, vertex-buffer-object


---

## 2 answers

### Answer by username_3 on 2017-01-17. Score: 4 | Accepted answer

> 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`.


---

### Answer by username_1 on 2017-01-18. Score: 5

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.

> **Comments:**
> **username_2**: This answer is very helpful. In Example 3.5 of the Ninth Edition of the OpenGL Programming Guide, the EBO is bound *before* the VAO is bound, which doesn't work on my computer. After reading this answer I switched the order, which made it work. In Joey de Vries' "learnopengl.com" website, the correct order is given.  

---

