Framebuffers

Hello,

I’m creating a frame buffer object, and I am trying to render what I render in the frame buffer to a texture. I am having issues with the depth buffer, the problem being there appears to be no depth buffer.
All my objects look like depth buffering is not turned on.


   //fb, depth_rb, img are all gluints.
   glGenFramebuffersEXT( 1, &fb );
   glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fb );


   glGenRenderbuffersEXT( 1, &depth_rb );

   glGenTextures( 1, &img );
   glBindTexture( GL_TEXTURE_2D, img );

  //set up texture params, texture stuff


   glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, img, 0 );

   //bind the render buffer
   glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, depth_rb );

   //create storage for the depth buffer/renderbuffer
   glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 800, 600 );

   //attach the frame buffer and the render buffer
   glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_COMPONENT24, GL_RENDERBUFFER_EXT, depth_rb );

   //leave the set up of fbo

   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
   //draw my scene
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

I query the number of depth bits using glGet and it returns 0. I also check the status of the frame buffer and my query returns that my frame buffer is complete.

Have I missed setting up the depth bits properly? I have all the proper enabling of depth functions, I know because I am rendering what I am looking at into this framebuffer. Does each framebuffer created have its own set of opengl state variables and I need to initialize the state for this frame buffer? (ie depthFunc, gluLookAt) or do these values persist when you move from frame buffer to frame buffer.

thanks,
Mitch

You should use

glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb )

Great, that worked perfectly…

Thanks,
Mitch