I'm having some problem understanding one line in the most basic (flat) shader example while reading OpenGL SuperBible.
In chapter 6, Listing 6.4 and 6.5 it introduces the following two very basic shaders.
6.4 Vertex Shader:
6.5 Fragment Shader:Code :// Flat Shader // Vertex Shader // Richard S. Wright Jr. // OpenGL SuperBible #version 130 // Transformation Matrix uniform mat4 mvpMatrix; // Incoming per vertex in vec4 vVertex; void main(void) { // This is pretty much it, transform the geometry gl_Position = mvpMatrix * vVertex; }
Code :// Flat Shader // Fragment Shader // Richard S. Wright Jr. // OpenGL SuperBible #version 130 // Make geometry solid uniform vec4 vColorValue; // Output fragment color out vec4 vFragColor; void main(void) { [B]gl_FragColor [/B]= vColorValue; }
My confusion is that it says vFragColor in the out declaration while saying gl_FragColor in main().
On the other hand, in code from the website, it has been corrected to 'vFragColor = vColorValue;' in the main loop.
What my question is that other then being a typo in the book, what is the rule for naming out values of shaders? Do they have to follow specific names?
On OpenGL.org I've found that gl_Position is required for the out of the vertex shader. Is there any such thing for the fragment shader? Or it is just that if there is only one output, then it will be the color in the buffer?
What happens when there is more then one out of a fragment shader? How does the GLSL compiler know which one to use in the buffer?




