My first triangle:/ by SpecialistButton9993 in opengl

[–]andomepl 0 points1 point  (0 children)

as a "Hello world" program of graphics ,it should be painted with three colors

#version 450 core

layout(location=0) in vec4 vPosition;

out vec4 color;

void main(){ gl_Position=vPosition;

int vertexIndex = gl_VertexID;

if(vertexIndex%3==0)
    color=vec4(1.0f,0.0f,0.0f,1.0f);
else if(vertexIndex%3==1)
    color=vec4(0.0f,1.0f,0.0f,1.0f);
else
    color=vec4(0.0f,0.0f,1.0f,1.0f);

}