6

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?

hlidotbe
  • 888
  • 2
  • 9
  • 17

1 Answers1

1

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

Mr. Berna
  • 10,525
  • 1
  • 39
  • 42