Original Post
Hey guys, I want to read the depth buffer of my FBO in one of my shaders so I can run some DOF equation. I am having trouble reading the buffer however. I setup the depth texture with GL_DEPTH_STENCIL_EXT so I have the stencil value to play with too, but thats another issue for another day. I don't how I access just the depth component of the texture from a shader (if it is possible at all?). Can I pass the the depth texture as a sampler? If anyone can help, then thanks.
glBindTexture(GL_TEXTURE_2D, textures[depth]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT, wWidth, wHeight, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 0);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
then..
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, textures[depth], 0);