I am trying to create a simple shader. Can you tell me why gl_FragData[2] = vec4(1,0,0,0) works as expected, but gl_FragData[2] = gl_Color don't. When using gl_Color nothing(except objects rendered whit another shader program ) shows up on the screen.

Thanks
How do I write the glColor I am currently rendering with to the fragment shader?

gl_FrontColor = gl_Color;

This will give gl_FrontColor the value of gl_Color not the other way around?

void main() {
// Set the front color to the color passed through with glColor*f
gl_FrontColor = gl_Color;
// Set the position of the current vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

Edit: Well gl_FrontColor = gl_Color; works but how?

kyle_

08-08-2010, 03:29 AM

gl_Color is atrtibute name in vertex shader.
gl_FrontColor and gl_BackColor are varying names in vertex shader.
gl_Color is varying name in fragment shader (its computed based on frontface status of your triangle and gl_FrontColor & gl_BackColor).