当我将这些代码添加到我的项目中时,我从 Brad Larson 的 Github 教程开始。
- (void)viewDidLoad
{
[super viewDidLoad];
GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
GPUImageFilter *customFilter = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:@"CustomShader"];
GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:filteredVideoView];
[videoCamera addTarget:customFilter];
[customFilter addTarget:filteredVideoView];
[videoCamera startCameraCapture];
}
我在方法中遇到了崩溃 - (id)initWithVertexShaderFromString:(NSString *)vertexShaderString fragmentShaderFromString:(NSString *)fragmentShaderString;
日志输出如下:
013-08-04 17:17:37.567 ViewPack[36088:907] Failed to load vertex shader
2013-08-04 17:17:37.570 ViewPack[36088:907] Failed to compile fragment shader
2013-08-04 17:17:37.572 ViewPack[36088:907] Program link log: ERROR: OpenGL ES 2.0 requires exactly one vertex and one fragment shader to validly link.
2013-08-04 17:17:37.573 ViewPack[36088:907] Fragment shader compile log: (null)
2013-08-04 17:17:37.574 ViewPack[36088:907] Vertex shader compile log: (null)
2013-08-04 17:17:37.576 ViewPack[36088:907] *** Assertion failure in -[GPUImageFilter initWithVertexShaderFromString:fragmentShaderFromString:], /Users/dachang/Desktop/Files/Libs/GPUImage-master/framework/Source/GPUImageFilter.m:97
我想我已经正确地将 GPIImage 添加到我的项目中,因为我可以导入所有这些标题。我不知道“OpenGL ES 2.0 需要一个顶点和一个片段着色器才能有效链接。” 意思是。(我找不到 CustomShader.fsh 文件)
有人可以帮忙吗。。非常感谢。。