當試圖呈現由CIFilter在GLKView中過濾的CIImage時,總會收到一條錯誤消息。錯誤是「CoreImage:EAGLContext framebuffer或renderbuffer配置不正確! 無效的着色器程序,可能是由於超出硬件資源而導致無法加載內核!」在GLKView中使用CIFilter後顯示CIImage
下面的代碼我使用以顯示圖像:
- (void)viewDidLoad
{
[super viewDidLoad];
EAcontext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (!EAcontext) {
NSLog(@"Failed to create ES context");
}
GLKView *view = (GLKView *)self.view;
view.context = self.EAcontext;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
glGenRenderbuffers(1, &_renderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffer);
glGenRenderbuffers(1, &_colorBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _colorBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8_OES, 768, 1024);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorBuffer);
coreImageContext = [CIContext contextWithEAGLContext:self.EAcontext];
[self updateView];
}
- (void)updateView
{
UIImage *myimage = [UIImage imageNamed:@"Moskau1.jpg"];
CIImage *outputImage = [[CIImage alloc] initWithImage:myimage];
[coreImageContext drawImage:outputImage inRect:self.view.bounds fromRect:[outputImage extent]];
[EAcontext presentRenderbuffer:GL_RENDERBUFFER_OES];
}
的視圖控制器是一個GLKViewcontroller
。 EAContext是CIContext類型的。
這可能是什麼原因造成的?