2012-02-15 55 views
6

當我爲CoreImage設置GLKViewController/GLKView進行繪圖時,我有時會在標題中看到通知。CoreImage:EAGLContext framebuffer或renderbuffer配置不正確

的設置是這樣的:

_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的子視圖,似乎當我添加/刪除視圖它在某種程度上暫時無效的情況下。 事情是(除了在一些罕見的情況下,我仍然需要轉角)我可以在沒有麻煩的情況下繪製下一個更新。

我可以重試繪圖,如果它失敗,但我怎麼能知道上下文無效?我該如何檢測它或防止它失效?

回答

1

A GLKView設置和管理渲染緩衝區。通過明確地呼叫glGenRenderBuffers()glBindRenderbuffer(),您很難理解GLKView的配置。