title: How to use Apples Core Image with opengl es
body: <p>So I have a texture (in a framebuffer) in my opengl es game, and I have been wanting to blur it.  I have been trying many methods to see which one will get me the best FPS as this needs to happen real-time as the texture is constantly changing.</p>
  
  <p>How exactly could I take a opengles texture and send it to coreImage, then back to opengles for display?</p>
  
  <p>This is some code that basically you put in a UIImage and it returns a blurred one. Where I am stuck is getting that texture to a UIImage, and I am wondering if their is a better way then loading in the new UIImage each time.</p>
  
  <pre><code>- (UIImage *)blurredImageWithImage:(UIImage *)sourceImage{
  
      //  Create our blurred image
      CIContext *context = [CIContext contextWithOptions:nil];
      CIImage *inputImage = [CIImage imageWithCGImage:sourceImage.CGImage];
  
      //  Setting up Gaussian Blur
      CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
      [filter setValue:inputImage forKey:kCIInputImageKey];
      [filter setValue:[NSNumber numberWithFloat:15.0f] forKey:@"inputRadius"];
      CIImage *result = [filter valueForKey:kCIOutputImageKey];
  
      /*  CIGaussianBlur has a tendency to shrink the image a little, this ensures it matches 
       *  up exactly to the bounds of our original image */
      CGImageRef cgImage = [context createCGImage:result fromRect:[inputImage extent]];
  
      UIImage *retVal = [UIImage imageWithCGImage:cgImage];
      return retVal;
  }
  </code></pre>
  
  <p>As shown by this graph core image could potentially be even better then the most efficient methods.
  <a href="https://i.stack.imgur.com/koOYy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/koOYy.jpg" alt="enter image description here"></a></p>