# OpenGL Framebuffer Object issue

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.

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.");

}

• Have you check this page to see if your framebuffer is complete? – Soapy Mar 26 '15 at 16:22
• Check errors after every glCall... I suspect one of them may be failing. – david van brink Mar 26 '15 at 18:06

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!