PDA

View Full Version : How to copy depth buffer to a texture



pango
06-06-2007, 01:42 AM
We know we can copy color buffer to a texture using "glTexSubImage2D()",but is it possible to copy depth buffer to a texture?

Olivier B.
06-06-2007, 02:31 AM
Try to put GL_DEPTH_COMPONENT in format glTexSubImage2D param.

Nighthawk
06-08-2007, 09:45 AM
Init the texture with:
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, shadowX, shadowY, 0, GL_DEPTH_COMPONENT, GL_BYTE, 0);

Copy the zBuffer of the framebuffer to Texture with:
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, shadowX, shadowY);

Or do you mean the a depth buffer from system memory?