PDA

View Full Version : Color of a G_QUAD



guju
06-04-2002, 11:48 PM
Hi!
I am defining for each vertex of Quad a color. If GL_SMOOTH is enabled the color distribution looks fine, but if i switch to GL_FLAT the color of the QUAD is strange. How does opengl decide, which color of the verteces of the quad is used to display??
Thanks
Juergen

Bob
06-05-2002, 01:02 AM
The color of the first vertex that builds the primitive will be used to shade the whole primitive.



glBegin(GL_QUADS)
glColor(red);
glVertex(v0);
glColor(green);
glVertex(v1);
glColor(blue);
glVertex(v2);
glColor(yellow);
glVertex(v3);

With smooth shading, the four colors should be interpolated over the quad. With flat shading, the whole quad should be red, cause thats the color of the fist vertex in the quad.

dorbie
06-05-2002, 01:12 AM
I think it will be yellow in your example, the last color before completion.

Bob
06-05-2002, 06:07 AM
Ah, yes, you are right. It's the last color, not the first, that defines the color of the primitive. Sorry.