我在使用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返回错误,因为framebuffer附件不完整。
你知道为什么会这样吗?
提前谢谢。
答案 0 :(得分:0)
好的我修好了,它无法呈现缓冲区存储:
[ Context renderbufferStorage : GL_RENDERBUFFER fromDrawable : ( CAEAGLLayer* )self.layer ];
出于某种原因,我的“self.layer”没有返回正确的。