PDA

View Full Version : Problems with polygon colouring



04-07-2001, 04:13 AM
I'm working on a program which reads polygons from file which have a colour attribute associated with it.

I am displaying the polygons like:
for each polygon
//Set Colour
glColor3f(Polygons[poly_num]->colour[1],
Polygons[poly_num]->colour[2],
Polygons[poly_num]->colour[3]);
//colour[x] is a float between 0.0 and 1.0
glBegin(GL_POLYGON);
for(each point in structure)
{
glVertex3f([0],[1],[2]); // set vertex
}
glEnd();

The polygons appear on screen but they are all the same colour....

Other initialization stuff i'm using

glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);

glMaterialfv(GL_FRONT,GL_SPECULAR,light_spectrum);
glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess) ;
glLightfv(GL_LIGHT0, GL_POSITION, light_origin);

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);

Perhaps it has something to do with the model view??

I'm a newbie and i'm stumped

Carl

Sancho
04-07-2001, 06:45 AM
Hi,

You must define the color material to track the diffuse color and you must enable the GL_COLOR_MATERIAL capability.

David