简体   繁体   English

在GLKView中使用CIFilter后显示CIImage

[英]Displaying CIImage after using CIFilter in GLKView

I always get an error message when trying to present an CIImage filtered by CIFilter inside of an GLKView. 尝试在GLKView中呈现由CIFilter过滤的CIImage时,我总是收到错误消息。 The Error is "CoreImage: EAGLContext framebuffer or renderbuffer incorrectly configured! Invalid shader program, probably due to exceeding hardware resourcesCould not load the kernel!" 错误是“CoreImage:EAGLContext帧缓冲或渲染缓冲区配置错误!无效的着色器程序,可能是因为超出了硬件资源而无法加载内核!”

The following code I use to display the Image : 我用以下代码来显示Image:

- (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];
}

The Viewcontroller is a GLKViewcontroller . Viewcontroller是一个GLKViewcontroller EAContext is of type CIContext. EAContext的类型为CIContext。

What could be causing this? 可能是什么导致了这个?

The "Invalid shader program, probably due to exceeding hardware resources" and "Could not load the kernel!" “无效的着色器程序,可能是由于超出了硬件资源”和“无法加载内核!” are actually distinct error, but the former seems to lack a linebreak. 实际上是明显的错误,但前者似乎缺乏一个换行符。 I got this problem yesterday, and it seems there are a few sources of this problem: 我昨天遇到了这个问题,似乎有这个问题的一些来源:

  • Check the frame buffer status to ensure it is complete - glCheckFramebufferStatus(GL_FRAMEBUFFER) should return GL_FRAMEBUFFER_COMPLETE - see the OpenGL ES programming guide for an example. 检查帧缓冲区状态以确保它已完成 - glCheckFramebufferStatus(GL_FRAMEBUFFER)应返回GL_FRAMEBUFFER_COMPLETE - 有关GL_FRAMEBUFFER_COMPLETE ,请参阅OpenGL ES编程指南

  • In my case, I had added a depth buffer to the framebuffer used by Core Image. 在我的例子中,我为Core Image使用的帧缓冲添加了一个深度缓冲区。 Core image evidently didn't like this - once I removed the depth buffer renderbuffer, the both error messages went away, and Core Image did its thing. 核心图像显然不喜欢这样 - 一旦我删除了深度缓冲区渲染缓冲区,两个错误消息都消失了,Core Image做了它的事情。

我遇到了同样的问题,删除深度缓冲区删除了错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM