Vertex arraysGL 2.0
glEnableVertexAttribArray
Turns on reading a vertex attribute from its buffer.
Signature
void glEnableVertexAttribArray(GLuint index);
How it works
Attributes start disabled. A disabled attribute gives the shader a constant value (by default 0,0,0,1) instead of per-vertex data. Forgetting this call is one of the most common reasons for a black or invisible mesh.
The enabled/disabled state is stored in the bound VAO.
Parameters
indexGLuint
Attribute location to enable.
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GL_INVALID_OPERATION
- No VAO is bound.
- GL_INVALID_VALUE
- index ≥ GL_MAX_VERTEX_ATTRIBS.
Example
example.cpp
1glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
2glEnableVertexAttribArray(0);