No depthtest with FBO

Hi ive looked im trying to render my scene to a floating point fbo, for hdr lighting. But i cant get the attached renderbuffer “z-buffer” to work?
any suggestions? im running on geforce 6600
Heres some code for ya!

 
// init the frame and render buffers
	glGenFramebuffersEXT(1, &framebuffer);
	glBindRenderbufferEXT(GL_FRAMEBUFFER_EXT,framebuffer);
	GET_GLERROR();
	glGenTextures(1, &color_attachment0);
	glBindTexture(GL_TEXTURE_2D, color_attachment0);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_FLOAT, NULL);
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color_attachment0, 0);
	GET_GLERROR(0);

	glGenRenderbuffersEXT(1, &renderbuffer);
	glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbuffer);
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, TEXSIZE, TEXSIZE);
	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, renderbuffer);
 

and when i render i attach like this

  
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbuffer);
	glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, framebuffer);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color_attachment0, 0);

Thanks in advance :slight_smile:

You shouldn’t have to bind the renderbuffer when drawing, nor should you have to set the framebuffer color attachment texture again when drawing.

You may also need to bind renderbuffer 0 after setting everything up, but I’m not sure.

Basically, your init code should look the same, except you should have a glBindRenderbufferEXT(blah, 0); and glBindFramebufferEXT(blah, 0) at the end, and for drawing, simply bind the framebuffer, and when you’re done drawing to it, bind framebuffer 0 to go back to the regular backbuffer.

	
glGenFramebuffersEXT(1, &framebuffer);
glBindRenderbufferEXT(GL_FRAMEBUFFER_EXT,framebuffer);

You are create FRAMEBUFFER and bind name as RENDERBUFFER. This can’t work.

Thanks guys!!
Dooh type-o, but nice to have some other eyes on it though :slight_smile: