PDA

View Full Version : Polygon offset with Polylines



jknxxl
02-19-2011, 05:53 AM
I've got several non closed polylines in 3D that partially overlap in 3D so I need to specify a 'display priority' for them.

Basically what I need is a glPolygonOffset that works with polylines.

glPolygonMode(GL_LINE) is almost perfect, but it does not allow for non closed polygons. If tried using it and defined the color for the last to first vertex (I added a duplicate first vertex) to be transparent but the 'closing' edge still seems to be somewhat visible.

Currently I'm calculating a 3D Z-offset in the model space that moves the lines towards the viewer to simulate Z-offset. This works nicely because I'm using an orthogonal projection so any movement in the viewer direction does not change the projected coordinates of the lines.

But obviously I would like theZ-offset to be as small as possible because there are other objects in the scene and I don't want to alter the Z-order in relation to those. So my question is really, assuming there is no simpler way to get a priority for polylines, how do I calculate the minimum Z-distance that allows distinction in the Z-buffer?

br Kusti