Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2096926

Browse files
committed
Add example of constraint on layout(location = x) qualifier
1 parent 869635a commit 2096926

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

04_Vertex_buffers/00_Vertex_input_description.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ properties that are specified per-vertex in the vertex buffer, just like we
3636
manually specified a position and color per vertex using the two arrays. Make
3737
sure to recompile the vertex shader!
3838

39+
Just like `fragColor`, the `layout(location = x)` annotations assign indices to
40+
the inputs that we can later use to reference them. It is important to know that
41+
some types, like `dvec3` 64 bit vectors, use multiple *slots*. That means that
42+
the index after it must be at least 2 higher:
43+
44+
```glsl
45+
layout(location = 0) in dvec3 inPosition;
46+
layout(location = 2) in vec3 inColor;
47+
```
48+
49+
You can find more info about the layout qualifier in the [OpenGL wiki](https://www.khronos.org/opengl/wiki/Layout_Qualifier_(GLSL)).
50+
3951
## Vertex data
4052

4153
We're moving the vertex data from the shader code to an array in the code of our
@@ -215,4 +227,4 @@ the vertex data to it so the GPU is able to access it.
215227

216228
[C++ code](/code/17_vertex_input.cpp) /
217229
[Vertex shader](/code/17_shader_vertexbuffer.vert) /
218-
[Fragment shader](/code/17_shader_vertexbuffer.frag)
230+
[Fragment shader](/code/17_shader_vertexbuffer.frag)

0 commit comments

Comments
 (0)