OpenGL: layout qualifier?

You’re right, the vertex shader is executed for each vertex.

A vertex is composed by of or several attributes (positions, normals, texture coordinates etc.).

On the CPU side when you create your VAO, you describe each attribute by saying “this data in this buffer will be attribute 0, the data next to it will be attribute 1 etc.”. Note that the VAO only stores this information of where’s who. The actual vertex data is stored in VBOs.

In the vertex shader, the line with layout and position is just saying “get the attribute 0 and put it in a variable called position” (the location represents the number of the attribute).

If the two steps are done correctly, you should end up with a position in the variable named position 🙂 Is it clearer?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)