UIImage *showImage = [UIImage imageNamed:@"demo.jpg"];
CGRect rect = CGRectMake(0, 0, showImage.size.width, showImage.size.height);
//获取OpenGLES需然然的上下文
EAGLContext *eagContext = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES2];
//创建出渲染的buffer
_glkView = [[GLKView alloc]initWithFrame:rect context:eagContext];
[_glkView bindDrawable];//绑定绘制
[self.view addSubview:_glkView];
//创建出CoreImage用的上下文
_ciContext = [CIContext contextWithEAGLContext:eagContext options:@{kCIContextWorkingColorSpace:[NSNull null]}];
//CoreImage相关设置
_ciImage = [[CIImage alloc]initWithImage:showImage];
_filter = [CIFilter filterWithName:@"CISepiaTone"];
[_filter setValue:_ciImage forKey:kCIInputImageKey];
[_filter setValue:@(0) forKey:kCIInputIntensityKey];
//开始渲染
[_ciContext drawImage:[_filter outputImage] inRect:CGRectMake(0, 0, _glkView.drawableWidth, _glkView.drawableHeight) fromRect:[_ciImage extent]];
[_glkView display];//显示出来
- (IBAction)sliderIsChange:(UISlider *)sender {
[_filter setValue:_ciImage forKey:kCIInputImageKey];
[_filter setValue:@(sender.value) forKey:kCIInputIntensityKey];
//开始渲染
[_ciContext drawImage:[_filter outputImage] inRect:CGRectMake(0, 0, _glkView.drawableWidth, _glkView.drawableHeight) fromRect:[_ciImage extent]];
[_glkView display];
}