Sign in to follow this  
browny

rendering depth values usng FBO

Recommended Posts

browny    139
i got the FBO working fine in my system.. now i want to render the depth value on a texture. But this doesn't seem to be working.. cuz when i use that texture on a quad and render .. everything appears BLACK.. it should be sortof greyish..right ?. Basically i am setting the "InternalFormat" and "Format" of the texture to GL_DEPTH_COMPONENT (infact i tried almost all combinations of GL_DEPTH_COMPONENTx_ARB and etc) and "Attaching" the texture to the GL_EXT_DEPTH_ATTACHMENT of the FBO. Am i doing anything wrong here?

Share this post


Link to post
Share on other sites
Optus    422
Just off the top of my head, you cannot only attach a depth buffer to an FBO, currently this is unsupported. You'll have to attach a color AND depth buffer to it, and just ignore the color buffer.

Share this post


Link to post
Share on other sites
JavaCoolDude    670
Off the top of my head, I think you're forgettin to set the Read and DrawBuffer to NONE


/***************************************************************************************/
/* */
/*Create a frame buffer object and attach our depth texture to it. */
/* */
/***************************************************************************************/
void createFrameBufferObject()
{
//Prevent the accidental creation of the FBO more than once
if(frameBufferObject)
return;

//Verify that the FBO extension is supported in the driver, if not, produce an error message
if(!glh_init_extensions("GL_EXT_framebuffer_object "))
{
cerr << "GL_EXT_framebuffer_object not supported!" << endl;
GUIComboBox *cb = (GUIComboBox*)guiMainPanel.getWidgetByCallbackString("currTechnique");
if(cb) cb->setActive(false);
return;
}

//Generate the frame buffer object
glGenFramebuffersEXT(1, &frameBufferObject);
//Activate the frame buffer object
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferObject);
//Attach our depth texture to the frame buffer object
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_2D,
light_view_depth.texture,
0);

//You must set DrawBuffer and ReadBuffer to none since we're rendering to depth only
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

//Check the completeness of our frame buffer object, with depth textures, there is no need for stencil
//and depth attachment for a FBO to be considered as complete
checkFrameBufferStatus();

//Turn off our frame buffer object
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this