front and back color

How to make different colors on front and back faces of a Cylinder or polygon?

You can’t specify the diffrent colors for two sides of polygon. One way to go around it is to draw the polygon two times. First with front and next with back cull facing.

cheers,
yaro

I try but the back face (inside cylinder) is black.
glEnable glcLighting
glEnable glcCullFace
glFrontFace ffCCW
glColor3f 1, 0#, 0#
obj = gluNewQuadric
gluCylinder obj, 5,5,2,64,18

            glFrontFace ffCW 
            glColor3f 0#, 1, 0#
            gluCylinder obj,5,5,2,64,18
        glDisable glcCullFace
        gluDeleteQuadric obj
    glDisable glcLighting

Thanks.

The code should look like that:

glFrontFace (GL_CCW);

glColor (…); // first color
RenderPolygon ();

glEnable (GL_CULL_FACE);
glCullFace (GL_FRONT);
glFrontFace (GL_CW);

glColor (…); // second color
RenderPolygon ();

Thus, there is no black color and all works fine.

cheers,
yaro

if you have lighting on you have a different story…

glMaterial have front and back properties.