PDA

View Full Version : Hidden Line Removal



09-18-2000, 12:20 AM
I have two questions.

1. How can I implement the hidden line removal?

My code is following...

glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset((float)100,0.0);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glBegin(GL_POLYGON);
glVertex(....) // draw my model as polygons
glEnd();
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glBegin(GL_LINE_LOOP);
glColor3ub(set appreciate colors);
glVertex(....) // draw my model as edges
glEnd();
glFinish();

Execute Result is fault.

Some visible lines(horizontal lines) don't appear.

Why???

2. What do the parameters of glPolygonOffset() mean?

Maybe... the distance between the polygon model and the wireframe model.

Is it right?

So, Is the depth of drawing edge different from the depth of real egde(given model value) because of

glPolygonOffset()?

Relic
09-18-2000, 01:25 AM
The polygon offset works only for polygonal primitives, not for GL_POINTS or GL_LINE...
The factor you use is rather big.

The code should look like this:

// Draw the model as filled polygons in the z-buffer with polygon offset enabled
// so that it shifts the polygons to the zFar direction

glPolygonMode(GL_FRONT, GL_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset((1.0f,1.0f);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glBegin(GL_POLYGON);
glVertex(....) // draw my model as polygons
glEnd();
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glDisable(GL_POLYGON_OFFSET_FILL);

// Draw the model as polygons with GL_LINE mode
glPolygonMode(GL_FRONT, GL_LINE);
glBegin(GL_POLYGON);
glColor3ub(set appreciate colors);
glVertex(....) // draw my model as edges
glEnd();
glFinish();


The other way round would be

glDepthFunc(GL_LESS):
// Draw the model as filled polygons in the z-buffer as the correct depth
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glBegin(GL_POLYGON);
glVertex(....) // draw my model as polygons
glEnd();
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
// Draw the model as polygons with GL_LINE mode
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset((-1.0f,-1.0f);
glPolygonMode(GL_FRONT, GL_LINE);
glBegin(GL_POLYGON);
glColor3ub(set appreciate colors);
glVertex(....) // draw my model as edges
glEnd();
glFinish();