我在使用 opengles 创建帧缓冲区时遇到了一些问题。对于我的应用程序,我像这样创建主帧缓冲区:
glGenFramebuffers( 1, &viewFramebuffer );
glGenRenderbuffers( 1, &viewRenderbuffer );
glBindFramebuffer( GL_FRAMEBUFFER, viewFramebuffer );
glBindRenderbuffer( GL_RENDERBUFFER, viewRenderbuffer );
[ Context renderbufferStorage : GL_RENDERBUFFER fromDrawable : ( CAEAGLLayer* )self.layer ];
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, viewRenderbuffer );
glGetRenderbufferParameteriv( GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth );
glGetRenderbufferParameteriv( GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight );
if ( itUsesDepthBuffer )
{
glGenRenderbuffers( 1, &depthRenderbuffer );
glBindRenderbuffer( GL_RENDERBUFFER, depthRenderbuffer );
glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, backingWidth, backingHeight );
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer );
}
if ( glCheckFramebufferStatus( GL_FRAMEBUFFER ) != GL_FRAMEBUFFER_COMPLETE )
{
NSLog( @"failed to make complete framebuffer object %x", glCheckFramebufferStatus( GL_FRAMEBUFFER ) );
[ self destroyFramebuffer ];
return NO;
}
但是函数 glGetRenderbufferParameteriv 为 GL_RENDERBUFFER_WIDTH 和 GL_RENDERBUFFER_HEIGHT 返回 0,最终 glCheckFramebufferStatus 返回错误,因为帧缓冲区附件不完整。
你知道为什么会这样吗?
先感谢您。