Vertex arraysGL 3.0
glGenVertexArrays
Reserves names (IDs) for new vertex array objects (VAOs).
Part of the family glGen*
Signature
void glGenVertexArrays(GLsizei n, GLuint *arrays);
How it works
A VAO is a small object that remembers how to read your vertex buffers: which buffer each attribute comes from, its format, stride and offset, plus which index buffer to use.
Without a VAO you would repeat every glVertexAttribPointer call before each draw. With one, you configure once and later just bind the VAO. In the core profile a VAO must be bound to draw anything.
Parameters
nGLsizei
How many IDs to generate.
arraysGLuint *
Array receiving the new IDs.
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GL_INVALID_VALUE
- n is negative.
Example
example.cpp
1GLuint vao;
2glGenVertexArrays(1, &vao);
3glBindVertexArray(vao);