zbuffer problem - terrain not showing up on globe

Hello Everyone,

I’m currently working on an openGL library for rendering terrain.

I also have a seperate globe application that is using my library to display terrain on the surface of the earth.

My problem is that if I disable the depth test, then my terrain appears with slight artifacts.

With depth testing enabled my terrain does not show up.

If I first clear the depth buffer, then draw with depth testing enabled that terrain shows up perfectly rendered. However this clobbering of the depth buffer affects the operation of the globe.

I was wondering if there is another way I can get the terrain to render well without using the depth buffer? And also without sorting the polygons…

Is there a quick way I can save and then restore the depth buffer, as to not affect the operation of the globe?

Any help is aprecaited…


There is really no efficient way to save and restore the depth buffer, as far as I know.

Can you go through all of the steps in your rendering pipeline that affect the depth buffer? Include any disables of depth test and depth write, any clearing of the depth buffer, and all drawing commands. (“draw globe” is sufficient - I dont need to see all of your calls to glBegin/glEnd or glDrawElements)

There might be a way to use the stencil buffer to fix your problem, but I cant know for sure without knowing the exact steps in your pipeline.

Thanks you for answering!

I am going to look into the stencil buffer… I will post again after alittle bit of research