Jump to content
  • Advertisement
Sign in to follow this  
fahlen

FBO & single depth texture

This topic is 4834 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

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

Share this post


Link to post
Share on other sites
Advertisement
I'm not incredibly familiar with FBO's but is it possible you're getting an error because the framebuffer HAS NO depth attachment at the point that you're attaching it to the texture?

EDIT: im tired right now, i may be way off, just takin a stab at it :-) cheers

DOUBLE EDIT: i just read a bit more of the spec, it almost seems to suggest that having a renderbuffer attached and then trying to attach a texture would be dead wrong, again im tired, sorry, but i guess its worth a try?

hope that helps
-Dan

Share this post


Link to post
Share on other sites
Thanks for your reply. I'm not quite sure if I understand your suggestion though. The FBO only has one attachment, which is the texture and is a depth attachment. I've tried to allocate and attach a rendertarget, thinking that maybe a framebuffer object is incomplete having only a depth attachment, but I still get the same error.

/Markus

Share this post


Link to post
Share on other sites
It does seem one has to attach a color attachment for it to work. The code below gives me no errors:


glGenTextures(1, &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, &rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB8, 1024, 1024);

glGenFramebuffersEXT(1, &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.

Share this post


Link to post
Share on other sites
That shouldnt be the case, remove the glDrawBuffer() and glReadBuffer() calls, I bet they're resetting the error flag, and its really still erroring. Im fairly confident that its a problem with your glTexImage2D call. GL_INT isnt going to work well with GL_DEPTH_COMPONENT (i dont think, ive never created depth textures before) google for creating depth textures if you havent already (im going to for my own education, ill post a link if i find anything)

hope that helps/works
-Dan

Share this post


Link to post
Share on other sites
Here, i found one thing, http://www.paulsprojects.net/tutorials/smt/smt.html

about halfway down the page he creates a depth texture, both internal format ant format, however, are set to GL_DEPTH_COMPONENT like so:

Quote:

glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, shadowMapSize, shadowMapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);


hope that helps
-Dan

Share this post


Link to post
Share on other sites
Quote:
Original post by Ademan555
That shouldnt be the case, remove the glDrawBuffer() and glReadBuffer() calls, I bet they're resetting the error flag, and its really still erroring.


checkFramebufferStatus(); doent use glerror() to check for errors, it uses glCheckFramebufferStatusEXT() which does a proper check on the framebuffer currently bound as a target.
The glDrawBuffer() and glReadBuffer() calls are needed to stop the implimentation writing out colour infomation and are unrelated to a bad frame buffer setup.

I'm pretty sure you must have at least one colour attachment for a FBO to be valid, regardless of it you draw to it or not. I cant test this however as ATI doesnt have support for FBO as yet.

Infact, does anyone know if NV's linux drivers support FBO?

Share this post


Link to post
Share on other sites
Maybe im reading this wrong, but this doesnt seem to me, to suggest that you need to have a color attachment

Quote:

4.4.4.2 Framebuffer Completeness

In this subsection, each rule is followed by an error enum enclosed
in { brackets }. Sections 4.4.4.2 and 4.4.4.3 explains the
relevance of the error enums.

The framebuffer object <target> is said to be "framebuffer complete"
if it is the window-system-provided framebuffer, or if all the
following conditons are true:

* All framebuffer attachment points are "framebuffer attachment
complete".
{ FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT }

* There is at least one image attached to the framebuffer.
{ FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT }

* A single image is not attached more than once to the
framebuffer object.
{ FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT }

* All attached images have the same width and height.
{ FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT }

* All images attached to the attachment points
COLOR_ATTACHMENT0_EXT through COLOR_ATTACHMENTn_EXT must have
the same internal format.
{ FRAMEBUFFER_INCOMPLETE_FORMATS_EXT }

* The value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT must not be
NONE for any color attachment point(s) named by DRAW_BUFFERi.
{ FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT }

* The value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT must not be
NONE for any color attachment point named by READ_BUFFER.
{ FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT }

* The combination of internal formats of the attached
images does not violate an implementation-dependent set of
restrictions.
{ FRAMEBUFFER_UNSUPPORTED_EXT }


EDIT: And here is their definition of image:

Quote:

framebuffer-attachable image:
A 2D pixel image that can be attached to one of the logical
buffer attachment points of a framebuffer object. Texture
images and renderbuffer images are two examples of
framebuffer-attachable images.


DOUBLE EDIT: well actually, upon further reading, i believe their definition of image is simply "2d array of pixels" (not an actual quote) ... reading the first 3 or so paragraphs lead me to this belief

EDIT: For completeness' sake, the spec is located at: http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt and http://www.opengl.org/documentation/extensions/EXT_framebuffer_object.txt

(of course this doesnt rule out nvidia's beta implementation not being 100% loyal to the spec)

hope that helps
-Dan

[Edited by - Ademan555 on May 22, 2005 3:09:57 PM]

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!