Changing Depth Buffer while Rendering

I have been working on a model editor for the last 4 months and have OpenGL doing all of my rendering. I have used a 16-bit depth buffer because it runs considerably faster than a 24 or 32 bit depth buffer. I have made the zNear, zFar clipping planes equivalent to 2x the Models radius on either side of the model with zNear never going under 1.0 and zFar never getting closer than 10.0 + zNear. Here is my problem.

When rendering rather large models. Radius of over 100 units, I’m seeing the swimming effects on touching polygons. I realize why this happens and I have searched on a way to alleviate this, but most suggestions seem to hint that the only way to solve the problem would be to make zNear,zFar as close to the model is possible(done that), and that setting your Depth Buffer to a higher bit depth(would make a considerable performance hit), so I got to checking out various ways of setting the zNear,zFar clipping planes and came across this function-

void glDepthRange(GLclampd znear,GLclampd zfar)

Is this simply a quick and dirty method of changing the zNear,zFar clipping region? or something else entirely.

If someone knows if this or another way of changing the zNear,zFar clipping planes that is quick(i.e., not using a glPerspective call) and can be done while rendering, then I thought I could draw each Sub-Model(part of the model) seperately enclosing it in a zNear,zFar clipping region the size of the Sub-Model, thus increasing the Z buffer accuracy without hindering performance.

this is how Ive aproached the problem in the past.

		{//near clipping
		glFrustum(-50.0F, 50.0F, -50.0F, 50.0F, 100.0F, 300.0F);
		{//far clipping
		glFrustum(-50.0F, 50.0F, -50.0F, 50.0F, 100.0F, 600.0F);

however Ifve neverneeded to consider it for speed like you have…

If I was in your position I would brobably pre compute several projection matrices with diferent clipping values save them all to to local memory and simply load tem with glLoadMatrix() every time I needed to change.

Would this change what has already been drawn or clear it out so to speak?

When I tried using the glDepthRange, I was able to get some weird effects, but nothing usable. I realize that this is probably a really odd question, but I’m really don’t like the wavies, and 24/32 bit depth buffer runs sooo slow. I suppose I could do Depth sorting myself, however that would also mean depth sorting the faces as well which could be overly complicated for an editor.


I thought Clip Planes were used mainly to clip some object within them. Do they improve the accuracy of the Depth Buffer?

Well, well. If you sort the objects by depth, you can draw with different depth ranges. Just remember to clear the zbuffer upon a depth range change.