how to change color

Hi,

I insert the following piece code into a big program. The triangle is always black on one face (it’s ok to me that the other face is invisible). If I enable the lighting, the triangle is grey and won’t change color no matter how I adjust the color setting below. Do you know why? I want to be able to change its color. Thanks.

Tony

glDisable (GL_LIGHTING);
glBegin(GL_POLYGON);
glColor3d(.0, .0, .0);
glVertex3f(.0, 0., 0.);
glColor3d(1., .5, .0);
glVertex3f(1., 1., 1.);
glColor3d(.0, 1., .3);
glVertex3f(-1., -1., 1.);
glEnd();

When you use lighting you have to also include normals with your vertex.

Go to nehe.gamedev.net and look at the tutor on how to do normals.

Originally posted by jyoung77:
[b]Hi,

I insert the following piece code into a big program. The triangle is always black on one face (it’s ok to me that the other face is invisible). If I enable the lighting, the triangle is grey and won’t change color no matter how I adjust the color setting below. Do you know why? I want to be able to change its color. Thanks.

Tony

glDisable (GL_LIGHTING);
glBegin(GL_POLYGON);
glColor3d(.0, .0, .0);
glVertex3f(.0, 0., 0.);
glColor3d(1., .5, .0);
glVertex3f(1., 1., 1.);
glColor3d(.0, 1., .3);
glVertex3f(-1., -1., 1.);
glEnd();[/b]

try adding this in your init :

glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);

cb