Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created August 31, 2012 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odrobnik/3554385 to your computer and use it in GitHub Desktop.
Save odrobnik/3554385 to your computer and use it in GitHub Desktop.
CoreImage: EAGLContext framebuffer or renderbuffer incorrectly configured!
- (void)drawCIImage:(CIImage *)image
{
CGRect rect = [image extent];
// http://stackoverflow.com/questions/8778117/video-filtering-in-iphone-is-slow
GLuint _renderBuffer;
CGContextRef cgContext;
CIContext *coreImageContext;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSUInteger bytesPerPixel = 4;
NSUInteger bytesPerRow = bytesPerPixel * rect.size.width;
NSUInteger bitsPerComponent = 8;
cgContext = CGBitmapContextCreate(NULL, rect.size.width, rect.size.height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(colorSpace);
EAGLContext *glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
coreImageContext = [CIContext contextWithEAGLContext:glContext];
glGenRenderbuffers(1, &_renderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, _renderBuffer);
[EAGLContext setCurrentContext:glContext];
[coreImageContext drawImage:image atPoint:CGPointZero fromRect:rect];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment