I create a shader program without defining VBO in Qt with OpenGL, because I define the vertex values in the vextex shader and it did work. Now I have a question, I know the vertex shader will process evert vertex value, but the main function in my vertex shader, it only process one vertex, So how did the main function process six vertices? what mechanism call the main function 6 times?
floor.vert
#version 420
uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
vec3 gridPlane[6] = vec3[](
vec3(1, 1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0),
vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0)
);
void main()
{
vec3 p = gridPlane[gl_VertexID].xyz;
gl_Position = vec4(p, 1.0);
}
floor.frag
#version 420 core
out vec4 outColor;
void main()
{
outColor = vec4(1.0, 0.0, 0.0, 1.0);
}
I want to know the machanism of vertex shader about processing every vertex.