Jump to content
  • Advertisement
Sign in to follow this  
browny

rendering depth values usng FBO

This topic is 4766 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!