Created
August 31, 2012 15:42
-
-
Save odrobnik/3554821 to your computer and use it in GitHub Desktop.
Is this correct?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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