GLKView:带有核心动画层的屏外RenderBuffer出现问题

时间:2017-08-15 06:46:13

标签: ios swift opengl-es

我正在尝试按照Apples指南Here附加一个渲染缓冲区。

我的问题是,如果尝试以这种方式创建FBO,则会发生以下两种情况:

a)如果我在self.bindDrawable()之前绘制任何内容或致电renderbufferStorage(_:_:)renderbufferStorage将返回false,那么整件事就会失败

b)如果我在调用bindDrawable或绘制任何内容之前运行下面的两个函数,则会成功创建渲染缓冲区,但是当我尝试绘制时会出现此错误:

  

无法将EAGLDrawable绑定到GL_RENDERBUFFER 2   无法制作完整的帧缓冲对象8cd6

private func initFrameBuffer() -> GLuint {
    var framebuffer_id: GLuint = 0
    glGenFramebuffers(1, &framebuffer_id)
    glBindFramebuffer(GLenum(GL_FRAMEBUFFER), framebuffer_id)
    return framebuffer_id
}

private func initRenderBuffer() -> GLuint {
    var renderBuffer_id: GLuint = 0
    glGenRenderbuffers(1, &renderBuffer_id);
    glBindRenderbuffer(GLenum(GL_RENDERBUFFER), renderBuffer_id);
    let status = context.renderbufferStorage(Int(GL_RENDERBUFFER), from: layer as! CAEAGLLayer)
    glFramebufferRenderbuffer(GLenum(GL_FRAMEBUFFER), GLenum(GL_COLOR_ATTACHMENT0), GLenum(GL_RENDERBUFFER), renderBuffer_id)
    return renderBuffer_id
}

我这样坐下了我的GLKView:

    context               = EAGLContext(api: .openGLES3)
    drawableColorFormat   = .RGBA8888

0 个答案:

没有答案