我正在制作一个绘画应用程序。 我想更改延音以添加重做和撤消功能。 但是在渲染之后我无法制作完整的帧缓冲区。
CAEAGLLayer* pGLLayer = ( CAEAGLLayer* )self.layer;
pGLLayer.opaque = YES;
pGLLayer.drawableProperties = [ NSDictionary dictionaryWithObjectsAndKeys:[ NSNumber numberWithBool:YES ],
kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat,
nil ];
mpGLContext = [ [EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 ];
[ EAGLContext setCurrentContext:mpGLContext ];
glGenFramebuffers( 1, &FrameBuffer );
glBindFramebuffer( GL_FRAMEBUFFER, FrameBuffer );
glGenRenderbuffers( 1, &firstColorBuffer );
glBindRenderbuffer( GL_RENDERBUFFER, firstColorBuffer );
[ mpGLContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:( CAEAGLLayer* )self.layer ];
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, firstColorBuffer );
glOrthof( 0.0f, 320.0f, 480.0f, 0.0f, 0.5f, -0.5f );
glViewport( 0, 0, 320, 480 );
// here status is GL_FRAMEBUFFER_COMPLETE
GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
/** render function **/
glGenRenderbuffers( 1, &secondColorBuffer );
glBindRenderbuffer( GL_RENDERBUFFER, secondColorBuffer );
[ mpGLContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:( CAEAGLLayer* )self.layer ];
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, firstColorBuffer );
// here status is GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES
GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
glCheckFramebufferStatus返回GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES。 但我绑定renderbuffer。 所以帧缓冲有一个附件。 我应该在此代码中修复什么来制作完整的帧缓冲区。
答案 0 :(得分:0)
尝试在/** render function **/
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, firstColorBuffer );
与
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, secondColorBuffer );
您要附加firstColorBuffer
两次并根据docummentation最后附上一个损坏的附件:
之前对附件逻辑缓冲区的任何附件 当前绑定的framebuffer对象已损坏。