gpt4 book ai didi

ios - cicontext 绘制图像 :inRect:fromRect crashes in ios6

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:34 26 4
gpt4 key购买 nike

我正在尝试从相机获取视频并使用 CoreImage 和 OpenGL 渲染它。当我运行它时,我在屏幕上看到了我期望的图片,然后我得到了 EXEC_BAD_ACCESS。我正在使用 ARC。 iOS6 Beta1。请帮助我修复它。

更新:它在 5.1 中工作,但在 6.0 中崩溃。我提出了所有异常断点,但我只看到 EXEC_BAD_ACESS 发生在 presentRendedBuffer > gpus_ReturnGuiltyForHardwareRestart

更新 2:我删除了与相机相关的代码,但它仍然崩溃。

更新 3:当我注释掉 glClearColor 和 glClear 命令时,我的应用程序停止崩溃。但我仍然想知道如何同时使用 OpenGL 和 Core Image。

我的新代码很简单:

@interface MGViewController () {
...
}
@property (strong, nonatomic) EAGLContext *glcontext;
@property (strong, nonatomic) CIContext *cicontext;
@property (strong, nonatomic) CIImage *ciimage;

- (void)viewDidLoad
{
[super viewDidLoad];

self.glcontext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

if (!self.glcontext) {
NSLog(@"Failed to create ES context");
} else {
self.cicontext = [CIContext contextWithEAGLContext:self.glcontext];

if (!self.cicontext){
NSLog(@"Failed to create CI context");
}
}

GLKView *view = (GLKView *)self.view;
view.context = self.glcontext;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;

self.ciimage = [[CIImage alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"roomphoto" withExtension:@"png"]];
}

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{

glClearColor(0.0, 0.5, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);

[self.cicontext drawImage:self.ciimage
inRect:self.ciimage.extent
fromRect:self.ciimage.extent];
}

此代码适用于 iPhone & iPad 6.0 模拟器;在 iPad2 iOS 6.0 Beta2 上因 EXEC_BAD_ACCESS 而崩溃;它只在 iPad 1 和 iPhone 4S iOS 5.1.1 上显示绿屏,并在控制台中显示消息:

Invalid shader program, probably due to exceeding hardware resourcesCould not load the kernel!Could not load the kernel! ...

有什么问题吗?

最佳答案

我终于设法阻止了应用程序崩溃。我刚刚在 gl 命令和 [cicontext drawImage...] 命令之间添加了 glFlush()

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{

glClearColor(0.0, 0.5, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);

glFlush();

[self.cicontext drawImage:self.ciimage
inRect:self.ciimage.extent
fromRect:self.ciimage.extent];
}

结果并不完美:我可以看到一些抖动等,但至少它有效。不过,如果能详细回答原因,我将不胜感激。

关于ios - cicontext 绘制图像 :inRect:fromRect crashes in ios6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11235493/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com