hidden line removal (by lines, not polygon)

I knew how to execute the hidden line removal by polygon mode.

namely…

written by Relic…

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();

But…

I want to execute the hidden line removal by lines

so…

The part I want to correct

glBegin(GL_POLYGON);
glColor3ub(set appreciate colors);
glVertex(…) // draw my model as edges
glEnd();
glFinish();

--------->

for{
glBegin(GL_LINES);

glVertex(the one vertex of two, consisted in one edge);
glVertex(another vertex);
glEnd();
}

Relic said…

The polygon offset works only for polygonal primitives, not for GL_POINTS or GL_LINE…

So…Can’t I implement the hidden line removal by lines’ DB?

Please help me!!

If I understand the polygonal code right, it fills the polygons with the background color, so the hidden lines are overdrawn.

To do this with only lines, you would have to intersect any line you draw with any polygon (triangle) to find out which parts of which lines are hidden…
seems like an awful lot of computing to me, although it would be possible

The other solution is to draw all the lines before drawing the polygons !

Then, when you draw the polygons, the zbuffer will automatically show/hide your lines…

Regards.

Eric

I dont know if the polygone offset only works on polygons, but if thats true, then why dont you just push back the polygons in stead of pushing the lines forward?