Hi,
I am trying to a fbo with only a depth buffer attachment to work. I read the spec and the document in the new ATI SDK, both have examples for it. This is what I have so far:
// generate fbo object
glGenFramebuffersEXT(1, &m_FBO);
CheckFrameBufferStatus(__LINE__);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBO);
CheckFrameBufferStatus(__LINE__);
// generate depth attachment
glGenTextures(1, &m_DepthAttachment);
glBindTexture(GL_TEXTURE_2D, m_DepthAttachment);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
// attach depth texture
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_DepthAttachment, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
CheckFrameBufferStatus(__LINE__);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
This is the initalisation code. It gives me no errors. New the render code:
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBO);
glClear(GL_DEPTH_BUFFER_BIT);
// Render some geometry here...
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
Later on, I try to use m_DepthAttachment as GL_TEXTURE_2D object, but this doesnt work. The quad is always white
Do you have any ideas?
Thanks in advance, Enrico