forked from BradLarson/GPUImage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/BradLarson/GPUImage
- Loading branch information
Showing
9 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Exclude the build directory | ||
build/* | ||
examples/FilterShowcase/build* | ||
|
||
# Exclude temp nibs and swap files | ||
*~.nib | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import "GPUImageFilter.h" | ||
|
||
@interface GPUImageRGBFilter : GPUImageFilter | ||
{ | ||
GLint redUniform; | ||
GLint greenUniform; | ||
GLint blueUniform; | ||
} | ||
|
||
@property (readwrite, nonatomic) CGFloat red; | ||
@property (readwrite, nonatomic) CGFloat green; | ||
@property (readwrite, nonatomic) CGFloat blue; | ||
|
||
@end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#import "GPUImageRGBFilter.h" | ||
|
||
NSString *const kGPUImageRGBFragmentShaderString = SHADER_STRING | ||
( | ||
varying highp vec2 textureCoordinate; | ||
|
||
uniform sampler2D inputImageTexture; | ||
uniform highp float red; | ||
uniform highp float green; | ||
uniform highp float blue; | ||
|
||
void main() | ||
{ | ||
highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); | ||
|
||
gl_FragColor = vec4(textureColor.r * red, textureColor.g * green, textureColor.b * blue, 1.0); | ||
} | ||
); | ||
|
||
@implementation GPUImageRGBFilter | ||
|
||
@synthesize red = _red, blue = _blue, green = _green; | ||
|
||
#pragma mark - | ||
#pragma mark Initialization and teardown | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [super initWithFragmentShaderFromString:kGPUImageRGBFragmentShaderString])) | ||
{ | ||
return nil; | ||
} | ||
|
||
redUniform = [filterProgram uniformIndex:@"red"]; | ||
self.red = 1.0; | ||
|
||
greenUniform = [filterProgram uniformIndex:@"green"]; | ||
self.green = 1.0; | ||
|
||
blueUniform = [filterProgram uniformIndex:@"blue"]; | ||
self.blue = 1.0; | ||
|
||
return self; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Accessors | ||
|
||
- (void)setRed:(CGFloat)newValue; | ||
{ | ||
_red = newValue; | ||
|
||
[GPUImageOpenGLESContext useImageProcessingContext]; | ||
[filterProgram use]; | ||
glUniform1f(redUniform, _red); | ||
} | ||
|
||
- (void)setGreen:(CGFloat)newValue; | ||
{ | ||
_green = newValue; | ||
|
||
[GPUImageOpenGLESContext useImageProcessingContext]; | ||
[filterProgram use]; | ||
glUniform1f(greenUniform, _green); | ||
} | ||
|
||
|
||
- (void)setBlue:(CGFloat)newValue; | ||
{ | ||
_blue = newValue; | ||
|
||
[GPUImageOpenGLESContext useImageProcessingContext]; | ||
[filterProgram use]; | ||
glUniform1f(blueUniform, _blue); | ||
} | ||
|
||
@end |