无法制作完整的帧缓冲对象8cd6(iOS,以编程方式创建的OpenGL视图)

时间:2012-01-24 16:53:52

标签: iphone ios opengl-es

我在编程创建OpenGL视图时遇到问题,无法在某些iOS版本/设备上运行。它似乎在Jailbroken设备上最常见,但也会在普通设备上发生。它似乎只是v4.1或4.2.1失败了。

我拥有的设备是越狱的(它不是我的,当然不是我越狱的选择!)并且有iOS的v4.1(8B117)。

错误是8cd6,这意味着它无法附加帧缓冲区(或沿着这些行的东西)。

我搜索过并搜索过,但我发现的其他解决方案都没有帮助。他们中的大多数人也使用深度缓冲,但我的纯粹是2D,没有深度缓冲。

以下是我创建缓冲区的方法:

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

其他设置值:

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;
}

它是"无法制作完整的帧缓冲对象"使用错误代码8cd6调用它。

4 个答案:

答案 0 :(得分:4)

感谢上面的两位用户,我帮他实现了一些目标。

我将缓冲区的创建移出了类的init函数,并创建了两个新函数:

-(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);
}

然后我在resizeFromLayer函数的开头添加了对这些的调用:

[self destroyFrameBuffer];
[self createFrameBuffer];

答案 1 :(得分:2)

我在我正在进行的项目中遇到了同样的问题

打印错误是:

  

无法将EAGLDrawable绑定到GL_RENDERBUFFER 1

     

无法制作完整的帧缓冲对象8cd6

要解决此问题,我必须确保仅标记重绘视图,而其self.window不是nil

我正在使用 strPath = HttpContext.Current.Server.MapPath("~/Reports/") + RptName + ".rpt"; rptDoc.Load(strPath); DataSet DS = new DataSet(); DS = objCommon.FillDataSetMTG(SqlConn, "USP_Report_ExecProcs", Convert.ToInt32(ViewState["Id"]), "JobEntryId"); rptDoc.SetDataSource(DS); 和我自己的GLKView

答案 2 :(得分:0)

我正在使用Cocos2d v2.x 我使用上面的解决方案来创建我的解决方案,解决了我的问题:

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

    if (_colorRenderbuffer)
    {
       glDeleteRenderbuffers(1, &_colorRenderbuffer);
       _colorRenderbuffer = 0;
    }


 }

 -(void) createFrameBuffer
 {
    // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer
    glGenFramebuffers(1, &_defaultFramebuffer);
    NSAssert( _defaultFramebuffer, @"Can't create default frame buffer");

    glGenRenderbuffers(1, &_colorRenderbuffer);
    NSAssert( _colorRenderbuffer, @"Can't create default render buffer");

    glBindFramebuffer(GL_FRAMEBUFFER, _defaultFramebuffer);
    glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderbuffer);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderbuffer);

}

- (BOOL)resizeFromLayer:(CAEAGLLayer *)layer
{

    [self destroyFrameBuffer];
    [self createFrameBuffer];
    etc.....

答案 3 :(得分:0)

花了很多时间后我找到了解决方案"无法制作完整的帧缓冲对象"我正在使用CCSprite上的掩码,但在初始化使掩盖成为可能的opengl方法之前我在视图中添加精灵,在添加之前你必须添加1秒的调度程序并在该调度程序中在视图中添加你的ccsprite。

干杯!