Problems with Depth Buffer

I’m drawing a large amount of Spheres on the screen, and when I draw them in my standard manner, (Display list for each type, then calls for each of the spheres) everything works great. However, when I cap the spheres for slicing I group each type into a display list, cap that, and then call those display lists for each type. Unfortunately, I require clearing the depth buffer for each of the draws in order to prevent the stencil buffer from drawing the clipped spheres. Is there a definitive way to save and load the depth buffer so that I can only save the depths that are actually drawn?



You might also want to look at
WGL_ARB_buffer_region if you’re on a windows platform.

With it you can save/restore certain parts of a buffer(color/depth/stencil) into video or system memory.