PDA

View Full Version : hidden line removal (by lines, not polygon)



10-25-2000, 07:58 AM
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!!

Dodger
10-25-2000, 08:18 AM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif

Eric
10-25-2000, 08:24 AM
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

Blaze
10-25-2000, 08:52 AM
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?