Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created August 31, 2012 15:42
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/3554821 to your computer and use it in GitHub Desktop.
Save odrobnik/3554821 to your computer and use it in GitHub Desktop.
Is this correct?
- (void)drawCIImage:(CIImage *)image
{
CGRect rect = [image extent];
CIContext *coreImageContext;
EAGLContext *glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
[EAGLContext setCurrentContext:glContext];
// http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html
GLuint framebuffer;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
GLuint colorRenderbuffer;
glGenRenderbuffers(1, &colorRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8_OES, rect.size.width, rect.size.height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER) ;
if(status != GL_FRAMEBUFFER_COMPLETE) {
NSLog(@"failed to make complete framebuffer object %x", status);
}
coreImageContext = [CIContext contextWithEAGLContext: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