Direct State AccessGL 4.5

glVertexArrayVertexBuffer

Plugs a vertex buffer into a numbered binding slot of a VAO.

Signature

void glVertexArrayVertexBuffer(GLuint vaobj, GLuint bindingindex, GLuint buffer,
                               GLintptr offset, GLsizei stride);

How it works

A VAO has several buffer binding slots. This puts a buffer in one of them, together with where the data starts and the stride between vertices. Attributes are then connected to the slot with glVertexArrayAttribBinding.

Parameters

vaobjGLuint

The VAO.

bindingindexGLuint

Binding slot number (NOT an attribute location).

bufferGLuint

Vertex buffer.

offsetGLintptr

Byte offset of the first vertex in the buffer.

strideGLsizei

Bytes between consecutive vertices. Unlike the old API, 0 does NOT mean tightly packed.

Tips & pitfalls

  • Direct State Access (GL 4.5): the object is passed as a parameter, so nothing needs to be bound and no global state is disturbed.

Example

example.cpp
1glVertexArrayVertexBuffer(vao, 0, vbo, 0, sizeof(Vertex));
Official Khronos documentation