What exactly does glEnableVertexAttribArray do?

Opengl

Opengl Problem Overview


I was reading: Dissecting Display, Chapter 1. Hello, Triangle!.

What exactly does glEnableVertexAttribArray do? I think it enables the use of a given VBO, but I am not sure.

I thought that is what glEnableClientState(GL_VERTEX_ARRAY) did.

Opengl Solutions


Solution 1 - Opengl

> I have been reading: Dissecting Display, Chapter 1. Hello, Triangle!.

Then please read the next page; I explain exactly what it does there ;)

If I may quote myself:

> We assigned the attribute index of the position attribute to 0 in the vertex shader, so the call to glEnableVertexAttribArray(0) enables the attribute index for the position attribute. [...] If the attribute is not enabled, it will not be used during rendering.

Solution 2 - Opengl

It's similar to a vertex array but stores additional extra values for each point rather than it's coordinates. You might want to store a temperature, density, signal strength at each point in a modelling app for example, or perhaps a damage value for a game

Solution 3 - Opengl

There is another way to specify data for a vertex attribute, the non-array way:

khronos: glVertexAttrib

In this way, we specify data for only one vertex, this data will be replicated for all vertices.

To use non-array data, call glDisableVertexAttribArray.

To use array data, call glEnableVertexAttribArray.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLunchMarbleView Question on Stackoverflow
Solution 1 - OpenglNicol BolasView Answer on Stackoverflow
Solution 2 - OpenglMartin BeckettView Answer on Stackoverflow
Solution 3 - OpenglNghia BuiView Answer on Stackoverflow