CoreImage:EAGLContext 帧缓冲区或渲染缓冲区配置不正确
当我设置 GLKViewController/GLKView 来使用 CoreImage 进行绘图时,我有时会在标题中收到通知。
设置如下所示:
_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];
我在 GLKView 中有 UIKit 子视图,似乎当我添加/删除视图时,它会以某种方式暂时使上下文无效。 问题是(除了在极少数情况下我仍然需要角落)我可以毫无麻烦地在上下文中绘制下一个更新。
如果失败,我可以重试绘图,但我如何知道上下文无效?我该如何检测它或防止它失效?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GLKView 设置并管理渲染缓冲区。通过显式调用
glGenRenderBuffers()
和glBindRenderbuffer()
,您会混淆GLKView
的配置。A
GLKView
sets up and manages the render buffer. By explicitly callingglGenRenderBuffers()
andglBindRenderbuffer()
you are confusing theGLKView
's configuration.