Direct State AccessGL 4.5

glEnableVertexArrayAttrib

Enables an attribute of a specific VAO, without binding it.

Signature

void glEnableVertexArrayAttrib(GLuint vaobj, GLuint index);

How it works

Attributes start disabled. A disabled attribute is not read from any buffer: the shader input gets a constant value instead (0, 0, 0, 1 by default), which is why a forgotten enable shows up as every vertex collapsing to the same point or colour. Enable each attribute the shader reads, once, when setting up the VAO.

Parameters

vaobjGLuint

The VAO.

indexGLuint

Attribute location to enable.

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
Official Khronos documentation