polygon offset

I don’t think I understand the concept of this function, why doesn’t it just subtract a bit from the depth value when writing to the depth buffer?

The polygons I’m trying to outline are at a steep angle, over 45 degrees. I don’t see any difference with the offset enabled, the outlines I’m drawing are stitching like you’d expect without the offset.

drawSectorPolys();
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1,1);
drawSectorLines();
glDisable(GL_POLYGON_OFFSET_FILL);

Just subtracting a bit to the z value is not sufficient to solve the problem. The precision varies with depth and derivatives and the zbuffer errors change in magnitude with the depth and slope of the fragments.

In addition the amount that needs to be added depends on the hardware precsions.

So, one of the terms is the depth amount you are talking about but corrects for hardware where 1.0 is the equivalent of the minimum offset required. The other is an ammount which varied with the polygon slope and is basically the pixel to pixel delts z.

Your values of 1,1 are good choices but you should use 1.0f, 1.0f since it is clear then that this function takes floats.

Your problem seems to be that you are using polygon offset but apparently drawing lines. This is bogus, offset applies to polygon fill only. Try enabling GL_POLYGON_OFFSET_LINE but again this depends on exactly how you are drawing the lines.

A better approach may be an negative signed offset the other way when you draw the original filled polygons.

Thanks, that was it. I was drawing with GL_LINES and not polys in line mode.

drawSectors();
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glPolygonOffset(-1.0f,1.0f);
drawSectors();
glDisable(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);