Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to make complete framebuffer object 8cd6 (iOS, programmatically created OpenGL view)

I've been having a problem getting my programmatically created OpenGL view to work on certain iOS versions/devices. It seem to be most common on Jailbroken devices, but does also happen on normal devices. It appears to only be v4.1 or 4.2.1 that it fails on.

The device I have is jailbroken (it's not mine and certainly not my choice to jailbreak it!) and has v4.1 (8B117) of iOS on it.

The error is 8cd6, which means that it failed to attach the framebuffer (or something along those lines).

I've searched and searched, but none of the other solutions I've found have helped. Most of them are using a depth buffer too, but mine is purely 2D and has no depth buffer.

Here's how I create the buffers:

glGenFramebuffersOES(1, &defaultFramebuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);

glGenRenderbuffersOES(1, &colorRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);

glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);

Other setup values:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, rect.size.width, 0, rect.size.height, -1, 1);
glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, rect.size.width, rect.size.height);

glDisable(GL_DEPTH_TEST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND_SRC);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

int* mts = calloc(1, sizeof(int));
glGetIntegerv(GL_MAX_TEXTURE_SIZE, mts);

resizeFromLayer:

-(BOOL) resizeFromLayer: (CAEAGLLayer*) _layer
{
    // Allocate color buffer backing based on the current layer size
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);

    NSLog(@"Layer Bounds: %f x %f", _layer.bounds.size.width, _layer.bounds.size.height);
    NSLog(@"Layer Position: %f x %f", _layer.bounds.origin.x, _layer.bounds.origin.y);
    if(![context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable: _layer])
    {
        NSLog(@"renderBufferStorage failed!");
    }

    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
    NSLog(@"Backing: %d x %d", backingWidth, backingHeight);

    if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
    {
        NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
        return NO;
    }

    return YES;
}

It's the line "Failed to make complete framebuffer object" that gets called with the error code 8cd6.

like image 668
AnonymousReality Avatar asked Jan 24 '12 16:01

AnonymousReality


2 Answers

I have it sorted thanks to the two users above, who helped me realise something.

I moved the creation of the buffers out of the init function of the class and created two new functions:

-(void) destroyFrameBuffer
{
    // Tear down GL
    if (defaultFramebuffer)
    {
        glDeleteFramebuffersOES(1, &defaultFramebuffer);
        defaultFramebuffer = 0;
    }

    if (colorRenderbuffer)
    {
        glDeleteRenderbuffersOES(1, &colorRenderbuffer);
        colorRenderbuffer = 0;
    }
}

-(void) createFrameBuffer
{
    // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer
    glGenFramebuffersOES(1, &defaultFramebuffer);
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);

    glGenRenderbuffersOES(1, &colorRenderbuffer);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);

    glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);
}

I then added calls to these at the beginning of the resizeFromLayer function:

[self destroyFrameBuffer];
[self createFrameBuffer];
like image 73
AnonymousReality Avatar answered Nov 03 '22 10:11

AnonymousReality


I've just had the same problem on a project I'm working on

The error printed is:

Failed to bind EAGLDrawable: to GL_RENDERBUFFER 1

Failed to make complete framebuffer object 8cd6

To fix this I had to make sure I only mark the view for redraw while its self.window is not nil.

I am using a GLKView with my own CADisplayLink

like image 41
SomeGuy Avatar answered Nov 03 '22 09:11

SomeGuy