PDA

View Full Version : No depthtest with FBO



trier
04-09-2006, 03:35 PM
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,framebuff er);
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 :)

PfhorSlayer
04-09-2006, 04:02 PM
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.

yooyo
04-09-2006, 04:10 PM
glGenFramebuffersEXT(1, &framebuffer);
glBindRenderbufferEXT(GL_FRAMEBUFFER_EXT,framebuff er);You are create FRAMEBUFFER and bind name as RENDERBUFFER. This can't work.

trier
04-09-2006, 11:46 PM
Thanks guys!!
Dooh type-o, but nice to have some other eyes on it though :)