你的位置:首页 > 软件开发 > 操作系统 > GPUImage API 文档之GPUImageFilter类

GPUImage API 文档之GPUImageFilter类

发布时间:2015-11-17 01:00:41
GPUImageFilter类  方法  - (id)initWithVertexShaderFromString:(NSString *)vertexShaderString fragmentShaderFromString:(NSString *)fragmentShader ...

GPUImageFilter类

  方法

  - (id)initWithVertexShaderFromString:(NSString *)vertexShaderString fragmentShaderFromString:(NSString *)fragmentShaderString

  说明:使用顶点和片段着色字符串来初始化GPUImageFilter

 

    - (id)initWithFragmentShaderFromFile:(NSString *)fragmentShaderFilename

  说明:使用片段着色文件来初始化GPUImageFilter

 

  - (void)initializeAttributes

  说明:向GLProgram中添加position和inputTextureCoordinate属性 

 

  - (CGSize)rotatedSize:(CGSize)sizeToRotate forIndex:(NSInteger)textureIndex

  - (CGPoint)rotatedPoint:(CGPoint)pointToRotate forRotation:(GPUImageRotationMode)rotation

  - (CGSize)sizeOfFBO

  说明:设置输出帧缓冲区的尺寸

 

  + (const GLfloat *)textureCoordinatesForRotation:(GPUImageRotationMode)rotationMode

  说明:旋转时的纹理坐标

 

  - (void)renderToTextureWithVertices:(const GLfloat *)vertices textureCoordinates:(const GLfloat *)textureCoordinates

  说明:使用顶点数据和纹理坐标进行图像渲染

 

  - (void)informTargetsAboutNewFrameAtTime:(CMTime)frameTime

  说明:通知target操作帧

 

   - (void)setBackgroundColorRed:(GLfloat)redComponent green:(GLfloat)greenComponent blue:(GLfloat)blueComponent alpha:(GLfloat)alphaComponent

  说明:使用设置RGBA背景色

 

  - (void)setInteger:(GLint)newInteger forUniformName:(NSString *)uniformName

  说明:使用整型数据初始化Uniform变量

 

  - (void)setFloat:(GLfloat)newFloat forUniformName:(NSString *)uniformName

  说明:使用浮点型数据初始化Uniform变量

 

  - (void)setSize:(CGSize)newSize forUniformName:(NSString *)uniformName

  说明:使用CGSize数据初始化Uniform变量

 

  - (void)setPoint:(CGPoint)newPoint forUniformName:(NSString *)uniformName

  说明:使用CGPoint数据初始化Uniform变量

 

  - (void)setFloatVec3:(GPUVector3)newVec3 forUniformName:(NSString *)uniformName

  说明:使用GPUVector3数据初始化Uniform变量

 

  - (void)setFloatVec4:(GPUVector4)newVec4 forUniform:(NSString *)uniformName

  说明:使用GPUVector4数据初始化Uniform变量

 

  - (void)setFloatArray:(GLfloat *)array length:(GLsizei)count forUniform:(NSString*)uniformName

   说明:使用GLfloat数组初始化Uniform变量,长度为count

 

  - (void)setAndExecuteUniformStateCallbackAtIndex:(GLint)uniform forProgram:(GLProgram *)shaderProgram toBlock:(dispatch_block_t)uniformStateBlock

  说明:设置并执行完Uniform时回调操作

 

  - (void)setUniformsForProgramAtIndex:(NSUInteger)programIndex

  说明:向GLProgram的programIndex处添加Uniform变量

 

完整代码

#import "GPUImageOutput.h"#define STRINGIZE(x) #x#define STRINGIZE2(x) STRINGIZE(x)#define SHADER_STRING(text) @ STRINGIZE2(text)#define GPUImageHashIdentifier ##define GPUImageWrappedLabel(x) x#define GPUImageEscapedHashIdentifier(a) GPUImageWrappedLabel(GPUImageHashIdentifier)aextern NSString *const kGPUImageVertexShaderString;extern NSString *const kGPUImagePassthroughFragmentShaderString;struct GPUVector4 {  GLfloat one;  GLfloat two;  GLfloat three;  GLfloat four;};typedef struct GPUVector4 GPUVector4;struct GPUVector3 {  GLfloat one;  GLfloat two;  GLfloat three;};typedef struct GPUVector3 GPUVector3;struct GPUMatrix4x4 {  GPUVector4 one;  GPUVector4 two;  GPUVector4 three;  GPUVector4 four;};typedef struct GPUMatrix4x4 GPUMatrix4x4;struct GPUMatrix3x3 {  GPUVector3 one;  GPUVector3 two;  GPUVector3 three;};typedef struct GPUMatrix3x3 GPUMatrix3x3;/** GPUImage's base filter class Filters and other subsequent elements in the chain conform to the GPUImageInput protocol, which lets them take in the supplied or processed texture from the previous link in the chain and do something with it. Objects one step further down the chain are considered targets, and processing can be branched by adding multiple targets to a single output or filter. */@interface GPUImageFilter : GPUImageOutput <GPUImageInput>{  GPUImageFramebuffer *firstInputFramebuffer;    GLProgram *filterProgram;  GLint filterPositionAttribute, filterTextureCoordinateAttribute;  GLint filterInputTextureUniform;  GLfloat backgroundColorRed, backgroundColorGreen, backgroundColorBlue, backgroundColorAlpha;    BOOL isEndProcessing;  CGSize currentFilterSize;  GPUImageRotationMode inputRotation;    BOOL currentlyReceivingMonochromeInput;    NSMutableDictionary *uniformStateRestorationBlocks;  dispatch_semaphore_t imageCaptureSemaphore;}@property(readonly) CVPixelBufferRef renderTarget;@property(readwrite, nonatomic) BOOL preventRendering;@property(readwrite, nonatomic) BOOL currentlyReceivingMonochromeInput;/// @name Initialization and teardown/** Initialize with vertex and fragment shaders You make take advantage of the SHADER_STRING macro to write your shaders in-line. @param vertexShaderString Source code of the vertex shader to use @param fragmentShaderString Source code of the fragment shader to use */- (id)initWithVertexShaderFromString:(NSString *)vertexShaderString fragmentShaderFromString:(NSString *)fragmentShaderString;/** Initialize with a fragment shader You may take advantage of the SHADER_STRING macro to write your shader in-line. @param fragmentShaderString Source code of fragment shader to use */- (id)initWithFragmentShaderFromString:(NSString *)fragmentShaderString;/** Initialize with a fragment shader @param fragmentShaderFilename Filename of fragment shader to load */- (id)initWithFragmentShaderFromFile:(NSString *)fragmentShaderFilename;- (void)initializeAttributes;- (void)setupFilterForSize:(CGSize)filterFrameSize;- (CGSize)rotatedSize:(CGSize)sizeToRotate forIndex:(NSInteger)textureIndex;- (CGPoint)rotatedPoint:(CGPoint)pointToRotate forRotation:(GPUImageRotationMode)rotation;/// @name Managing the display FBOs/** Size of the frame buffer object */- (CGSize)sizeOfFBO;/// @name Rendering+ (const GLfloat *)textureCoordinatesForRotation:(GPUImageRotationMode)rotationMode;- (void)renderToTextureWithVertices:(const GLfloat *)vertices textureCoordinates:(const GLfloat *)textureCoordinates;- (void)informTargetsAboutNewFrameAtTime:(CMTime)frameTime;- (CGSize)outputFrameSize;/// @name Input parameters- (void)setBackgroundColorRed:(GLfloat)redComponent green:(GLfloat)greenComponent blue:(GLfloat)blueComponent alpha:(GLfloat)alphaComponent;- (void)setInteger:(GLint)newInteger forUniformName:(NSString *)uniformName;- (void)setFloat:(GLfloat)newFloat forUniformName:(NSString *)uniformName;- (void)setSize:(CGSize)newSize forUniformName:(NSString *)uniformName;- (void)setPoint:(CGPoint)newPoint forUniformName:(NSString *)uniformName;- (void)setFloatVec3:(GPUVector3)newVec3 forUniformName:(NSString *)uniformName;- (void)setFloatVec4:(GPUVector4)newVec4 forUniform:(NSString *)uniformName;- (void)setFloatArray:(GLfloat *)array length:(GLsizei)count forUniform:(NSString*)uniformName;- (void)setMatrix3f:(GPUMatrix3x3)matrix forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setMatrix4f:(GPUMatrix4x4)matrix forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setFloat:(GLfloat)floatValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setPoint:(CGPoint)pointValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setSize:(CGSize)sizeValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setVec3:(GPUVector3)vectorValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setVec4:(GPUVector4)vectorValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setFloatArray:(GLfloat *)arrayValue length:(GLsizei)arrayLength forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setInteger:(GLint)intValue forUniform:(GLint)uniform program:(GLProgram *)shaderProgram;- (void)setAndExecuteUniformStateCallbackAtIndex:(GLint)uniform forProgram:(GLProgram *)shaderProgram toBlock:(dispatch_block_t)uniformStateBlock;- (void)setUniformsForProgramAtIndex:(NSUInteger)programIndex;@end

原标题:GPUImage API 文档之GPUImageFilter类

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录