如何使用GLKView的帧缓冲区避免使用逻辑缓冲区存储?

时间:2015-08-10 02:28:10

标签: ios opengl-es glkit

在一个非常简单的应用程序上运行Xcode的OpenGL ES诊断,该应用程序切换到第二个帧缓冲区并返回(适当使用glClear和glInvalidateFramebuffer),在切换到第二个帧缓冲区时显示有关逻辑缓冲区存储的警告:

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    // At this point, GLKView's framebuffer is bound

    // Clear (to avoid logical buffer load)
    glClear(GL_COLOR_BUFFER_BIT);

    // Invalidate (to avoid logical buffer store)
    glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 });

    // Switch to our own framebuffer, and attach a texture as the color attachment
    // At this point, Xcode's OpenGL ES tool warns:
    //  "For best performance keep logical buffer store operations to a minimum."
    glBindFramebuffer(GL_FRAMEBUFFER, _framebuffer);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture, 0);

    // Clear (to avoid logical buffer load)
    glClear(GL_COLOR_BUFFER_BIT);

    // Invalidate (to avoid logical buffer store)
    glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 });

    // Might want to switch back to GLKView's drawable here, and do more rendering
}

任何人都有任何想法为什么无效的人没有抓住?请注意,在此示例中,GLKView仅具有颜色缓冲附件:

    view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;  
    view.drawableStencilFormat = GLKViewDrawableStencilFormatNone;  
    view.drawableDepthFormat = GLKViewDrawableDepthFormatNone;  
    view.drawableMultisample = GLKViewDrawableMultisampleNone; 

https://dl.dropboxusercontent.com/u/6956432/test.zip

测试应用程序

干杯!

0 个答案:

没有答案