Depth Masking

I’ve been working with generating simulations with large numbers of spheres (3200) which are basically bogging down the the graphics refresh rate even with backface culling and hidden surface removal enabled. My solution to this problem would be since the spheres don’t change position to simply draw them once and then store them in the buffer as a back ground so that other graphics can be updated over them.
My reference manuals claim that this should be possible by drawing my sphere graphics and then disabling writing to the depth buffer using glDepthMask(GL_FALSE).
What’s happening is the window shows my image and then goes black after I disable the buffer or the graphics are never generated and the window just stays some random wacky color.

any thoughts?


You might check out the extension WGL_ARB_buffer_region – it’s designed to do the sort of thing you’re interested in, I think.


Try rendering into an offscreen bitmap, and then texturing some background quads with the background image in question.

If you need to draw other things interspersed with the spheres, try sticking the spheres in a display list.