iphone - GLKView 给出 'Failed to make complete framebuffer object 8cd6' 错误

标签 iphone objective-c opengl-es glkview

我试图将 GLKView 添加到 ScrollView 但没有成功。

目前,我的绘图代码只是将背景着色为红色,但在它开始这样做之前它会抛出错误“无法制作完整的帧缓冲区对象 8cd6”错误。通过将 OpenGL 绘制到标准 UIView 中,我设法使完全相同的事情正常工作,但是一旦将其切换为 GLKView,它总是会引发错误。

以下是我的 ScrollView 在 AppDelegate.m 中的初始化方式:

ScrollView *scroll = [[ScrollView alloc] init];
[[self window] setRootViewController:scroll];

然后在我的 ScrollView.m 本身中有以下内容:

CGRect screenRect;

float screenWidth = 1920;   
float screenHeight = 1280;

UIScrollView *scrollView;
GLKView *glkView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self)
    {
        // Custom initialization
    }

    return self;
}

-(void)loadView
{
    // initialise the view's size parameters
    screenRect.size.width = screenWidth;
    screenRect.size.height = screenHeight;

    // init the scrollview with the new screen rect
    scrollView = [[UIScrollView alloc] initWithFrame:screenRect];

    // set the delegate as itself
    [scrollView setDelegate:self];

    // make the scrollview our main view
    [self setView:scrollView];

    // now create the GLKView and context
    EAGLContext * context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
    glkView = [[GLKView alloc] initWithFrame:screenRect];
    glkView.context = context;
    glkView.delegate = self;

    // add the GLKView to the scrollView
    [scrollView addSubview:glkView];

    /* old code, which works fine */
    // OpenGLView openGLView = [[OpenGLView alloc] initWithFrame: screenRect];    
    // openGLView.delegate = self;
    // openGLView.opaque = NO;    
    // [scrollView addSubview:openGLView];
    /* end of old code */

    // and finally tell the scrollview the size of it's content
    [scrollView setContentSize:screenRect.size];
}

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    // ** THROWS THE ERROR BEFORE HERE ** //
    // set the background colour to red
    glClearColor(1.0, 0.0, 0.0, 1.0);

    // and now clear it    
    glClear(GL_COLOR_BUFFER_BIT);
}

这段代码会导致这种情况发生的原因是什么?

最佳答案

从主线程实例化 View 时,我会发生此错误。

FWIW,错误消息中的 8cd6 是 GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 的 OpenGL 错误代码,这意味着有关 OpenGL 帧缓冲区的某些内容未完全配置。

关于iphone - GLKView 给出 'Failed to make complete framebuffer object 8cd6' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17910413/

相关文章:

ios - MGSplitViewController 不是根用户

ios - Swift OpenGL 未解析标识符 kCGImageAlphaPremultipliedLast

ios - 使用 GLKit 在 OpenGL ES 2.0 中出现奇怪的混合效果

iphone - 在IOS中检测到拍手

android - OpenUDID 的工作原理

ios - 无法设置 AFNetworking (2.0) JSON 请求

ios - 同一数据源的 UITableView 和 MapView 之间切换

android - 如何在 OpenGL ES 2.0 着色器中处理 NaN 或 inf

iphone - iphone os 使用的是什么版本的 safari? (截至 2009 年 12 月 14 日)

ios - 延迟iOS中的http重试请求任务