// The fragment shader needs a main function, just as the // vertex shader does. But unlike a vertex shader, this is // called for every pixel on the screen. // All fragment shaders must end with the line // gl_FragColor = *something*; // because the fragment shader is setting the current color // drawn on the screen. // In this fragment shader, gl_FragColor must end up being // the color that we want to display on the screen. In // this case we are setting that to gl_Color. gl_Color // will take the current color set in OpenGL using // glColor3f(r,g,b) or any other glColor call and then // use this color. So the fragment shader will be outputting // the same colour that would be shown, even if we had not // called this shader. // And that is all there is to shaders (for now). // If you have followed through this far, well done. Give // yourself a pat on the back :) void main() { // Set the output color of our current pixel gl_FragColor = gl_Color; }