// Guess what?!?!?! We have changes here.. Finally :) // Here we are going to change the color of our output // render to a color of our choice.. My choice is going // to be blue. Just because I can :) // In GLSL we have different types of variables we can // use. The most used types (IMO) are the vec types. // They consist of vec1, vec2, vec3, vec4, the vec // standing for vector, even though it is generally // used to hold multiple part floats and integers. // Now the gl_FragColor that we have to set, takes // a vec4 type variable. The correct way to use this is // like so: // DO: vec4(1,2,3,4) // DO NOT: vec4 1,2,3,4 or (vec4)1,2,3,4 // Now for colours, you would have entered in 3 numbers // one for Red, one for Green and one for Blue for the // glColor3f calls. This is the same, only it also takes // an alpha value as well just like glColor4f. GLSL also // uses the same order for colours, so the first is Red // the second is Green, the third is Blue and the fourth // is Alpha. // To get the colour blue, we therefore need: // vec4(r,g,b,a) which would come to vec4(0,0,1,1). // This can either be written straight out, or we can // store this in a variable, // eg: vec4 Blue = vec4(0,0,1,1); // and then call gl_FragColor = Blue. // But in this tutorial I am going to call the line: // gl_FragColor = vec4(0,0,1,1); // And that is all there is to it. We now have a blue // cube. // Also keep in mind, that any color set in GLSL will // overwrite the color set by glColor, unless you call // gl_Color in the shader as in the previous tutorial. void main(void) { // Set the output color of our current pixel gl_FragColor = vec4(0,0,1,1); }