I'm trying to get an video from camera and render it using CoreImage and OpenGL. When I'm running it I see my picture on screen as I expect and then I get EXEC_BAD_ACCESS. I'm using ARC. iOS6 Beta1. Please help me to fix it.
Update: it works in 5.1 but crashes in 6.0. I've raised All Exception Breakpoint but I only see that EXEC_BAD_ACESS happens in presentRendedBuffer > gpus_ReturnGuiltyForHardwareRestart
Update2: I've removed camera-related code and it's still crashes.
Update 3: When I commented out glClearColor & glClear commands my app stopped crashing. But I still want to know how to use OpenGL together with Core Image simultaneously.
my new code as simple as:
@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];
}
This code works on iPhone & iPad 6.0 simulator; crashes with EXEC_BAD_ACCESS on iPad2 iOS 6.0 Beta2; and it gives me just green screen on iPad 1 & iPhone 4S iOS 5.1.1 with messages in the console:
Invalid shader program, probably due to exceeding hardware resourcesCould not load the kernel!Could not load the kernel! ...
What can be wrong?