Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting error code GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT when creating framebuffer on Mac (using glCheckFramebufferStatus).

I am using same code for rendering on Mac and iOS both. Maybe problem is in the buffers initialization. On iOS I am doing it this way:

    CAEAGLLayer* eaglLayer = (CAEAGLLayer*) super.layer;
    eaglLayer.opaque = YES;

    EAGLRenderingAPI api = kEAGLRenderingAPIOpenGLES2;
    m_context = [[EAGLContext alloc] initWithAPI:api];

    if (!m_context) {
        [self release];
        return nil;

    if (!m_context || ![EAGLContext setCurrentContext:m_context]) {
        [self release];
        return nil;

    [self layoutIfNeeded];

    NSLog(@"Using OpenGL ES 2.0");

        fromDrawable: eaglLayer];

Variable m_context is object EAGLContext

On the Mac this way:

NSOpenGLPixelFormat *nsglFormat;

NSOpenGLPixelFormatAttribute attr[] = 
    NSOpenGLPFAColorSize, m_colorBits, //16
    NSOpenGLPFADepthSize, m_depthBits, //16

[self setPostsFrameChangedNotifications: YES];

///< Next, initialize the NSOpenGLPixelFormat itself
nsglFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];

///< Check for errors in the creation of the NSOpenGLPixelFormat
if(!nsglFormat) { 
    NSLog(@"Invalid format... terminating."); 
    return nil; 

///< Now create the the CocoaGL instance, using initial frame and the NSOpenGLPixelFormat
self = [super initWithFrame:frame pixelFormat:nsglFormat];
[nsglFormat release];

///< If there was an error, we again should probably send an error message to the user
if(!self) { 
    NSLog(@"Self not created... terminating."); 
    return nil; 

///< Now  set this context to the current context

[[self openGLContext] makeCurrentContext];

Maybe I am doing anything wrong when I initialize NSOpenGLContext. Can you see any error? Thankyou UPDATE: Initialization of the OpenGL I am doing this way:

int m_width, m_height;

                             GL_RENDERBUFFER_WIDTH, &m_width);
                             GL_RENDERBUFFER_HEIGHT, &m_height);

// Create the depth buffer.
glGenRenderbuffers(1, &m_depthRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, m_depthRenderbuffer);

// Create the framebuffer object; attach the depth and color buffers.
glGenFramebuffers(1, &m_framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);

// Bind the color buffer for rendering.
glBindRenderbuffer(GL_RENDERBUFFER, m_colorRenderbuffer);

// Set up some GL state.
glViewport(0, 0, 640, 480);
share|improve this question
Could you please post your corrected code ? I tried to delete the code related to the RenderBuffer but I still get an error. – user8551 Jul 12 '11 at 9:50

I had the exact same problem when I tried adding a depth buffer to the sample code generated by XCode. You should add code to check for framebuffer completion:

    NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
// also check glGetError() here

I'm not a Mac expert, but I do remember that the position of the following call is very important:

[m_context renderbufferStorage:GL_RENDERBUFFER fromDrawable: eaglLayer];

On iOS it needs to be before creating the color and depth components of the framebuffer.

Here is my working iOS code:

[EAGLContext setCurrentContext:context];

glGenFramebuffers(1, &frameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);

glGenRenderbuffers(1, &colorRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderBuffer);

glGenRenderbuffers(1, &depthRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer);

    NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));

share|improve this answer
I have got GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error. What could that mean? – martin pilch Apr 25 '11 at 13:25
The problem is on the Mac not on iOS. – martin pilch Apr 25 '11 at 13:32
and glGetRenderbufferParameteriv return width of framebuffer 0 and height 1072693248. This could be problem – martin pilch Apr 25 '11 at 13:38
You are retrieveing the render buffer width and height before you create it. – Meh Apr 25 '11 at 15:40
My bad... But this does not cause the error – martin pilch Apr 25 '11 at 16:54
up vote 0 down vote accepted

Finally I have found the solution. It is necessary NOT to use renderbuffer. So I have to DELETE code to init renderbuffer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.