glPolygonOffset() has two parameters: factor and units, but i don’t know what they mean. Though i have read OpenGL FAQ in OpenGL.org, I still can’t understand it. I set the factor and units to 1.0 which is said to be a typical use in FAQ, but it doesn’t work. I draw the object with polygonal primitives(GL_TRIANGLES) and then i want to draw two lines on it. This is my code. I write them
with the help of FAQ. but it doesn’t work.
glPolygonMode (GL_FRONT_AND_BACK,GL_LINE);
glLineWidth(2.0);
glBegin(GL_LINES);
for(int i=0; i<4;i++) {
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glVertex3f(objx[i], objy[i], objz[i]);
}
glEnd(); //draw two lines
glPushAttrib (GL_ALL_ATTRIB_BITS);
glEnable (GL_POLYGON_OFFSET_FILL);
glPolygonOffset (1.0f, 1.0f);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
//here draw my object with GL_TRIANGLES
glPopAttrib ();
I have also tried the reversed way, namely i first draw the object and then draw the lines. It still doesn’t work. Can anyone tell me what is wrong? How can i correctly draw a line over polygons?
thanks a lot