color

Im am drawing 3d shapes and and wanting to set different sides to different colors to represent different things.

When I draw a 3d triangle, I do it by drawing the four faces, (front, back, right, and left). Each side then has the three vertices, each with its own color… (gl.glColor(1.0f, 0.0f, 0.0f).

Say I want to set the front side of the triangle to black and then the back side to be red. When I try to implement this because the top point of my triangle is used by all sides as there top point there is shading running through into all sides of my triangle. How can I make each side disticnt from the other, so that there is no color merging?

Thanks.

duplicate the top-vertex. There’s no other way except maybe using texture-mapping, but doesn’t sound better.

Jan

Duplicate the vertices so that no faces share a vertex of a different color.

Or look up a face color and use this before drawing the triangle vertices. Example:


// first set face color'
glColor3f(1, 0, 0);

// then draw face without setting a new color
glVertex3f(...) // vertex one
glVertex3f(...) // vertex two
glVertex3f(...) // vertex three

This way only one color is used on the whole triangle and there will be no gourad shading.