PDA

View Full Version : FBO & attached depth texture



fahlen
05-19-2005, 11:54 PM
Hi,
I'm working with a GeForce 6800 GT card and the installed drivers are Forceware 76.44. I'm having a problem using an FBO with a single depth texture attached. It gives me the error GL_FRAMEBUFFER_UNSUPPORTED_EXT. To initialize the FBO, I use the code below:


glGenFramebuffersEXT(1, &fb);
glGenTextures(1, &texture);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);

glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_INT, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texture, 0);

checkFramebufferStatus();Does anyone have any idea as to what I may be doing wrong? Any help would be greatly appreciated.

/Markus

Relic
05-20-2005, 04:22 AM
One idea would be that you have not set the minification filter to not use mipmaps (default is GL_LINEAR_MIPMAP_NEAREST) and the texture is inconsistent.

fahlen
05-20-2005, 05:03 AM
Thanks for the reply. I tried setting the minification filter to GL_NEAREST, but I still get the same error.

/Markus

Relic
05-20-2005, 05:21 AM
What about the example from the spec?

(7) Render to depth texture with no color attachments

// Given: depth_tex - TEXTURE_2D depth texture object
// fb - framebuffer object

// Enable render-to-texture
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);

// Set up depth_tex for render-to-texture
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_2D, depth_tex, 0);

// No color buffer to draw to or read from
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

CHECK_FRAMEBUFFER_STATUS();

<draw something>

// Re-enable rendering to the window
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

glBindTexture(GL_TEXTURE_2D, depth_tex);
<draw to the window, reading from the depth_tex>Looks like you're missing the glDrawBuffer and glReadBuffer calls.
For clarity I would separate the texture initialization and FBO settings in your code.

fahlen
05-20-2005, 05:45 AM
Thanks again for your reply. I've tried to insert glDrawBuffer(GL_NONE) and glReadBuffer(GL_NONE) as in the example from the specification, but still no luck. I'm starting to question whether or not it's my beta drivers (76.44) that aren't behaving well... but then again, it's probably more likely that I'm the one doing something wrong ;)

/Markus

Relic
05-20-2005, 06:30 AM
Hehe, slowly running out of ideas.
What happens if you unbind the depth texture before attaching it to the FBO?

glGenTextures(1, &amp;texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_INT, NULL);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, 0);

glGenFramebuffersEXT(1, &amp;fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texture, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

checkFramebufferStatus();

fahlen
05-20-2005, 07:06 AM
I've upgraded to Forceware 76.45 drivers and tried to unbind the texture before attaching it to the framebuffer object, but glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) still gives me GL_FRAMEBUFFER_UNSUPPORTED_EXT.

I'm dying to find out what I'm doing wrong... especially since it was so easy to set up an FBO with 3 renderbuffers and use them as MRTs. Somehow I though setting up an FBO with a single depth texture for shadow mapping would be easier.

fahlen
05-20-2005, 07:52 AM
As someone just told me, one has to attach a color attachment for it to work. The code below gives me no errors:


glGenTextures(1, &amp;texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_INT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

glGenRenderbuffersEXT(1, &amp;rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB8, 1024, 1024);

glGenFramebuffersEXT(1, &amp;fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, rb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texture, 0);

glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

checkFramebufferStatus();Thanks.

Zengar
05-20-2005, 11:52 AM
The drivers you use are still beta and lots of people are said to have problems with depth targets.

Most mature FBO implementation is in the current beta 76.91 driver

splat
05-20-2005, 12:07 PM
Are you already shure that the depthmap generated is valid? I had the same problem and did the following different:
-i have another dummy color texture created and attached to the FBO
-i don't have a color renderbuffer like you, but a depth renderbuffer
-calling glDraw/ReadBuffer with GL_NONE won't work

-> No error, but I don't know wether it will work as it should (shadow mapping isn't working, but it could be another mistake too in the shader or so...)
So if your method works, I would prefer it (no dummy texture creation)

But I thought there has to be an attached depth buffer? Can there be a depth test if no depth renderbuffer is bound? This is important for me because there might be more objects behind each other and the depth of the nearest is important...

fahlen
05-24-2005, 10:06 PM
To Zengar,
I would install the 76.91 drivers if I had access to them ;) Being a registered developer with nVIDIA isn't a privilege granted to anyone... and I'm just doing a master thesis, so my chances of being accepted are slim to say the least...

splat
05-26-2005, 08:57 AM
Why didn't you answer my last post? Wasn't it understandable? Then I am sorry, but a little feedback would be nice.

I really would like to have working solution soon.

stanlylee
05-26-2005, 04:45 PM
I had post a same question last month. and already solved the problem , here is my source code.

http://xreal.51.net/Download/glslfbo.test.rar