Drawing outside depth buffer

I have a model that includes many polygons in a small defined area, but also includes a few lines that run a long way outside the area. I don’t want to compromise the accuracy of the depth buffer by extending the near and far planes, because all my polygons are in a confined space, but when spinning the object around, and particularly when zooming in close, I don’t want the lines to be clipped.

As they are lines, I was wondering if there was any way to turn off the depth clipping, such that pixels are still compared against the depth buffer for clipping, but anything behind the far plane is drawn as if it was on the far plane, and anything in front of the near plane was drawn as if it were on the near plane. Is this possible?

My program implements ortho and perspective views, so even if it’s only possible in one of these, that would be OK.

There is the GL_NV_depth_clamp extension for nvidia cards, which just does that. :slight_smile:

Perfect. Pity it’s NVidea only though, but I will implement it anyway. So how do you use this… glEnable(GL_NV_depth_clamp)?

The only value I can find on the net for GL_NV_depth_clamp is 1. What should it really be?

You need this:

#define GL_DEPTH_CLAMP_NV 0x864F

Then you can call glEnable/glDisable (GL_DEPTH_CLAMP_NV).

What if you read the specs of this extension ?