There are 2 layouts in my vertex shader
layout (location = 1) in vec3 aColor;
layout (location = 0) in vec3 aPos;
I set them by func glVertexAttrib3f();
glVertexAttrib3f(1, 0, 1, 0); // color
glBegin(GL_TRIANGLES); // vertexes
glVertexAttrib3f(0, 0, 0, 0);
glVertexAttrib3f(0, 1, 0, 0);
glVertexAttrib3f(0, 1, 1, 0);
glEnd();
In this situation, everything is ok, I have my green triangle in a window. But if I swap my aPos layout and aColor (set 1 to aPos and 0 to aColor)
layout (location = 0) in vec3 aColor;
layout (location = 1) in vec3 aPos;
and also dont forgot to swap them in my cpp file
glVertexAttrib3f(0, 0, 1, 0); // color
glBegin(GL_TRIANGLES); // vertexes
glVertexAttrib3f(1, 0, 0, 0);
glVertexAttrib3f(1, 1, 0, 0);
glVertexAttrib3f(1, 1, 1, 0);
glEnd();
nothing dont work and my window is empty (it must draw green triangle) Why it works so?