我对FrameBuffers有点困惑。 目前,为了在屏幕上绘制,我使用此代码为GL_COLOR_ATTACHMENT0
生成了一个带有渲染缓冲区的帧缓冲区。OpenGL ES 2.0和iOS中的默认FrameBuffer
-(void)initializeBuffers{
//Build the main FrameBuffer
glGenFramebuffers(1, &frameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
//Build the color Buffer
glGenRenderbuffers(1, &colorBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorBuffer);
//setup the color buffer with the EAGLLayer (it automatically defines width and height of the buffer)
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:EAGLLayer];
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &bufferWidth);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &bufferHeight);
//Attach the colorbuffer to the framebuffer
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorBuffer);
//Check the Framebuffer status
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
NSAssert(status == GL_FRAMEBUFFER_COMPLETE, ERROR_FRAMEBUFFER_FAIL);
}
我显示了使用
[context presentRenderbuffer:GL_RENDERBUFFER];
阅读this question缓冲区的内容,我看到Arttu Peltonen的谁说注释:
默认帧缓冲区是你默认渲染,你没有 做任何事情来获得。 Framebuffer对象是您可以渲染到的东西,而这被称为“离屏渲染”。 如果你这样做,你最终得到的是你的图像纹理,而不是 默认帧缓冲区(显示在屏幕上)。您可以将 图像从该纹理复制到默认帧缓冲区(屏幕上),即 通常使用blitting完成(但它仅在OpenGL ES 3.0中提供)。 但是,如果你只是想在屏幕上显示图像,你可能 首先不会使用FBO。
所以我不知道我的方法是否只是用于离屏渲染。 在那种情况下,我必须做什么才能在默认缓冲区上呈现?! (注意,我不想使用GLKView ...)