Direct State AccessGL 4.5
glCreateVertexArrays
Creates VAOs that can be configured without binding them.
Part of the family glCreate*
Signature
void glCreateVertexArrays(GLsizei n, GLuint *arrays);
How it works
The DSA VAO API also separates two ideas that glVertexAttribPointer mixes: the attribute FORMAT (what a vec3 at offset 12 looks like) and the buffer BINDING (which buffer and stride to read from). This makes switching buffers cheap and code clearer.
Parameters
nGLsizei
How many VAOs.
arraysGLuint *
Array receiving the IDs.
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
1GLuint vao;
2glCreateVertexArrays(1, &vao);
3glVertexArrayVertexBuffer(vao, 0, vbo, 0, sizeof(Vertex));
4glVertexArrayElementBuffer(vao, ebo);