PDA

View Full Version : front and back color



05-28-2003, 05:31 AM
How to make different colors on front and back faces of a Cylinder or polygon?

yaro_dup1
05-28-2003, 01:00 PM
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

05-29-2003, 03:38 AM
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.

yaro_dup1
05-30-2003, 12:12 PM
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

Mazy
05-30-2003, 03:31 PM
if you have lighting on you have a different story..

glMaterial have front and back properties.