Specifying the Vertices of our First Triangle (cont’d)

Centering the triangle

void main() {
    float vid = float(gl_VertexID);

    const float Pi = 3.14159265358979;
    const float DegreesToRadians = Pi / 180.0;
    
    float angle = vid * 120.0 /* Degrees */ * DegreesToRadians;
    
    vec2 v = vec2(cos(angle), sin(angle));
    v.x -= 0.25;
    
    gl_Position = vec4(v, 0.0, 1.0);
}