View Full Version : Writing directly to the Z-buffer?

01-23-2002, 05:47 AM
Is it possible to write information directly into the Z-buffer and/or stencil buffer? I need to copy some color values from one imgaes into the Z-buffer as Z-buffer values. Then I need to draw another picture doing depth-tests with these values. It seems that functions like glCopyPixels and glReadPixels can read Z-buffer data and then convert them into colors but not the other way around. Can this be done?

Any help is appreciated

01-23-2002, 06:02 AM
Use glDrawPixels with GL_DEPTH_COMPONENT or GL_STENCIL_INDEX. Just remember that it does not draw directly into the depth/stencil buffer, but generates fragments. You might want to disable drawing to the color buffer, and set depth function to GL_ALWAYS. Not sure what you need to do with the stencil function, but I guess it's something similar.