PDA

View Full Version : OpenGL polygon fill How??



BozoClown
02-18-2001, 12:50 PM
Hi

I have a bunch of polygons. I want to display them in hidden line mode and I want to fill color to be
different than the edge color. In the simple case I want white fill and black edges. How do I specify
different colors for fill and edge? I can't find it...

Thanks!

Dave P

glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Background color

glColor3f(0.0f, 0.0f, 0.0f); // Polygon color

// Hidden line removal

glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Set the mode

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

for (i = 0; i < total_elements; i++)
{
glBegin(GL_POLYGON);
glEdgeFlag(TRUE);
glVertex3f(xyz[elem[i].n1 - 1].x, xyz[elem[i].n1 - 1].y, xyz[elem[i].n1 - 1].z);
glVertex3f(xyz[elem[i].n2 - 1].x, xyz[elem[i].n2 - 1].y, xyz[elem[i].n2 - 1].z);
glVertex3f(xyz[elem[i].n3 - 1].x, xyz[elem[i].n3 - 1].y, xyz[elem[i].n3 - 1].z);
glVertex3f(xyz[elem[i].n4 - 1].x, xyz[elem[i].n4 - 1].y, xyz[elem[i].n4 - 1].z);
glEnd();
}

Michael Steinberg
02-18-2001, 12:56 PM
Why don't you just draw the scene twice, once with GL_FILL and afterwards with wireframe?

02-19-2001, 11:55 AM
The function you want is:
void glPolygonOffset(GLfloat factor, GLfloat units); It's in the Redbook if you want an explaination.