Dash line in wireframe after fill polygon

Hi,
After fill polygons, I use GL_LINE_LOOP to draw a wireframe on these polygons. Some of the lines in the wireframe will be dashed, but other lines are still solid. If don’t fill polygons, all the lines in the wireframe will be solid. If turn on GL_LINE_SMOOTH flag or just set line width to 2.f, then all lines in the wireframe will be solid, no matter whether fill polygons or not. But a wireframe with wider line width looks not good.
Can anybody help me with this issue? Thank you very much.

What you are seeing is depth fighting. The lines are trying to go exactly where the surface is.

Try this:

draw solid polygons...

glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(-1,-1);

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
draw the same polygons again.
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

glDisable(GL_POLYGON_OFFSET_LINE);

You can skip the polygon mode stuff and just draw line segments, as you are doing now. Have a look at the Polygon Offset section of the Red Book.

Yeah, of course we can help :slight_smile:

Looks like you should use glPolygonOffset (I think it is, if not, its glPolyOffset…) Anyways, you offset your polygon by a positive value, and your lines will stand out nicely.

The above suggestion works nicely if you don’t mind drawing your lines as a polygon, and not as GL_LINE_LOOP.