3
\$\begingroup\$

I am struggling with implementing a proper Framebuffer Object .

glCheckFramebufferStatus is returning me: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT (36054).

What am i missing?

GLuint fbo, rboColor, rboDepth;

// Color renderbuffer.
glGenRenderbuffers(1,&rboColor);
glBindRenderbuffer(GL_RENDERBUFFER,rboColor);
// Set storage for currently bound renderbuffer.
glRenderbufferStorage(GL_RENDERBUFFER, GL_BGRA, _w, _h);

// Depth renderbuffer
glGenRenderbuffers(1,&rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER,rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, _w, _h);

// Framebuffer
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER,fbo);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,     GL_RENDERBUFFER, rboColor);
// Set renderbuffers for currently bound framebuffer
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,GL_RENDERBUFFER,rboDepth);

 // Set to write to the framebuffer.
glBindFramebuffer(GL_FRAMEBUFFER,fbo);

// Tell glReadPixels where to read from.
glReadBuffer(GL_COLOR_ATTACHMENT0);

GLenum e = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);//glCheckFramebufferStatus: check the completeness status of a framebuffer
if (e != GL_FRAMEBUFFER_COMPLETE) {
printf("\nThere is a problem with the FBO.");

}
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Have you check this page to see if your framebuffer is complete? \$\endgroup\$
    – Soapy
    Commented Mar 26, 2015 at 16:22
  • 1
    \$\begingroup\$ Check errors after every glCall... I suspect one of them may be failing. \$\endgroup\$ Commented Mar 26, 2015 at 18:06

1 Answer 1

4
\$\begingroup\$

First thing I would do is to figure out if any previous call to glCheckFramebufferStatus has failed. You are not calling glGetError at any point, which means you are probably missing a previous error that could help you figure out the problem. Make sure to add an error check after every previous GL call and log any error encountered. That will narrow down your search to the offending function.

That said, it is very likely that your renderbuffer allocations are failing. Probably the formats GL_BGRA or GL_DEPTH_COMPONENT24 are not supported in the platform. If this is OpenGL-ES code, look in here to see the supported color and depth formats. This is kind of obvious, but also make sure the width and height are > 0!

GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT is generated when:

Not all framebuffer attachment points are framebuffer attachment complete. This means that at least one attachment point with a renderbuffer or texture attached has its attached object no longer in existence or has an attached image with a width or height of zero, or the color attachment point has a non-color-renderable image attached, or the depth attachment point has a non-depth-renderable image attached, or the stencil attachment point has a non-stencil-renderable image attached.

(source)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I'm also wondering what version of OpenGL you are using. If it is -ES, then the target would be GL_FRAMEBUFFER (not GL_DRAW_FRAMEBUFFER), according to khronos.org/opengles/sdk/docs/man/xhtml/…. Yes, check errors. \$\endgroup\$ Commented Mar 26, 2015 at 18:09
  • \$\begingroup\$ The fault was with the GL_BGRA. Thanks guys. \$\endgroup\$ Commented Mar 27, 2015 at 0:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .