Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoreImage: EAGLContext framebuffer or renderbuffer incorrectly configured

When I setup a GLKViewController/GLKView for drawing with CoreImage I sometimes get the notice in the title.

The setup looks like this:

_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

self.view.context = _context;
self.view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
self.view.backgroundColor = UIColor.blackColor;
self.view.contentScaleFactor = UIScreen.mainScreen.scale;

glGenRenderbuffers(1, &_render_buffer);
glBindRenderbuffer(GL_RENDERBUFFER, _render_buffer);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);

_core_image_context = [CIContext contextWithEAGLContext: _context];

[EAGLContext setCurrentContext:_context];

I have UIKit subviews in the GLKView and it seems that when I add/remove views it somehow invalidate the context temporarily. The thing is (except in some rare cases I still need to corner) the next update I can draw in the context without troubles.

I'm ok to retry drawing if it fails but how can I know that the context is invalid? How am I supposed to detect it or prevent it from being invalidated?

like image 271
hlidotbe Avatar asked Feb 15 '12 10:02

hlidotbe


1 Answers

A GLKView sets up and manages the render buffer. By explicitly calling glGenRenderBuffers() and glBindRenderbuffer() you are confusing the GLKView's configuration.

like image 69
Mr. Berna Avatar answered Sep 22 '22 15:09

Mr. Berna