diff --git a/examples/CubeExample/CubeExample-Info.plist b/examples/CubeExample/CubeExample-Info.plist index a45013de2..1b54a9b15 100644 --- a/examples/CubeExample/CubeExample-Info.plist +++ b/examples/CubeExample/CubeExample-Info.plist @@ -28,5 +28,22 @@ MainWindow UIStatusBarHidden + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + diff --git a/examples/CubeExample/CubeExample.xcodeproj/project.pbxproj b/examples/CubeExample/CubeExample.xcodeproj/project.pbxproj index 83772bfd1..69a61a407 100755 --- a/examples/CubeExample/CubeExample.xcodeproj/project.pbxproj +++ b/examples/CubeExample/CubeExample.xcodeproj/project.pbxproj @@ -330,6 +330,7 @@ HEADER_SEARCH_PATHS = "../../framework/**"; PREBINDING = NO; SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -346,6 +347,7 @@ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PREBINDING = NO; SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; diff --git a/examples/SimpleImageFilter/SimpleImageFilter/SimpleImageViewController.m b/examples/SimpleImageFilter/SimpleImageFilter/SimpleImageViewController.m index 05d55fc42..0f7adb700 100644 --- a/examples/SimpleImageFilter/SimpleImageFilter/SimpleImageViewController.m +++ b/examples/SimpleImageFilter/SimpleImageFilter/SimpleImageViewController.m @@ -62,7 +62,8 @@ - (void)setupImageFilteringToDisk; UIImage *inputImage = [UIImage imageNamed:@"Lambeau.jpg"]; GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage]; - GPUImageSepiaFilter *stillImageFilter = [[GPUImageSepiaFilter alloc] init]; +// GPUImageSepiaFilter *stillImageFilter = [[GPUImageSepiaFilter alloc] init]; + GPUImageSketchFilter *stillImageFilter = [[GPUImageSketchFilter alloc] init]; [stillImageSource addTarget:stillImageFilter]; [stillImageSource processImage]; @@ -70,7 +71,8 @@ - (void)setupImageFilteringToDisk; UIImage *currentFilteredVideoFrame = [stillImageFilter imageFromCurrentlyProcessedOutput]; // Do a simpler image filtering - GPUImageSepiaFilter *stillImageFilter2 = [[GPUImageSepiaFilter alloc] init]; +// GPUImageSepiaFilter *stillImageFilter2 = [[GPUImageSepiaFilter alloc] init]; + GPUImageSketchFilter *stillImageFilter2 = [[GPUImageSketchFilter alloc] init]; UIImage *quickFilteredImage = [stillImageFilter2 imageByFilteringImage:inputImage]; diff --git a/framework/Source/GPUImageFilter.h b/framework/Source/GPUImageFilter.h index 2815721e7..bb2557ab9 100644 --- a/framework/Source/GPUImageFilter.h +++ b/framework/Source/GPUImageFilter.h @@ -52,6 +52,7 @@ typedef struct GPUMatrix4x4 GPUMatrix4x4; - (void)createFilterFBOofSize:(CGSize)currentFBOSize; - (void)destroyFilterFBO; - (void)setFilterFBO; +- (void)setOutputFBO; // Rendering - (void)renderToTextureWithVertices:(const GLfloat *)vertices textureCoordinates:(const GLfloat *)textureCoordinates sourceTexture:(GLuint)sourceTexture; diff --git a/framework/Source/GPUImageFilter.m b/framework/Source/GPUImageFilter.m index 5408b9844..4c9fbf80b 100644 --- a/framework/Source/GPUImageFilter.m +++ b/framework/Source/GPUImageFilter.m @@ -112,7 +112,7 @@ void dataProviderReleaseCallback (void *info, const void *data, size_t size) - (UIImage *)imageFromCurrentlyProcessedOutput; { [GPUImageOpenGLESContext useImageProcessingContext]; - [self setFilterFBO]; + [self setOutputFBO]; CGSize currentFBOSize = [self sizeOfFBO]; @@ -205,6 +205,12 @@ - (void)setFilterFBO; glViewport(0, 0, (int)currentFBOSize.width, (int)currentFBOSize.height); } +- (void)setOutputFBO; +{ + // Override this for filters that have multiple framebuffers + [self setFilterFBO]; +} + #pragma mark - #pragma mark Rendering diff --git a/framework/Source/GPUImageRotationFilter.h b/framework/Source/GPUImageRotationFilter.h index 2319aa843..d5175b017 100644 --- a/framework/Source/GPUImageRotationFilter.h +++ b/framework/Source/GPUImageRotationFilter.h @@ -1,6 +1,6 @@ #import "GPUImageFilter.h" -typedef enum { kGPUImageRotateLeft, kGPUImageRotateRight, kGPUImageFlipVertical, kGPUImageFlipHorizonal} GPUImageRotationMode; +typedef enum { kGPUImageRotateLeft, kGPUImageRotateRight, kGPUImageFlipVertical, kGPUImageFlipHorizonal, kGPUImageRotateRightFlipVertical} GPUImageRotationMode; @interface GPUImageRotationFilter : GPUImageFilter { diff --git a/framework/Source/GPUImageRotationFilter.m b/framework/Source/GPUImageRotationFilter.m index ba56ee499..494a6dc3e 100644 --- a/framework/Source/GPUImageRotationFilter.m +++ b/framework/Source/GPUImageRotationFilter.m @@ -82,6 +82,14 @@ - (void)newFrameReady; 1.0f, 1.0f, 0.0f, 1.0f, }; + + static const GLfloat rotateRightVerticalFlipTextureCoordinates[] = { + 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + }; + switch (rotationMode) { @@ -89,6 +97,7 @@ - (void)newFrameReady; case kGPUImageRotateRight: [self renderToTextureWithVertices:rotationSquareVertices textureCoordinates:rotateRightTextureCoordinates sourceTexture:filterSourceTexture]; break; case kGPUImageFlipHorizonal: [self renderToTextureWithVertices:rotationSquareVertices textureCoordinates:verticalFlipTextureCoordinates sourceTexture:filterSourceTexture]; break; case kGPUImageFlipVertical: [self renderToTextureWithVertices:rotationSquareVertices textureCoordinates:horizontalFlipTextureCoordinates sourceTexture:filterSourceTexture]; break; + case kGPUImageRotateRightFlipVertical: [self renderToTextureWithVertices:rotationSquareVertices textureCoordinates:rotateRightVerticalFlipTextureCoordinates sourceTexture:filterSourceTexture]; break; } [self informTargetsAboutNewFrame]; } diff --git a/framework/Source/GPUImageSobelEdgeDetectionFilter.m b/framework/Source/GPUImageSobelEdgeDetectionFilter.m index 4c6fd2f8c..efd421eb1 100644 --- a/framework/Source/GPUImageSobelEdgeDetectionFilter.m +++ b/framework/Source/GPUImageSobelEdgeDetectionFilter.m @@ -25,8 +25,8 @@ void main() attribute vec4 position; attribute vec4 inputTextureCoordinate; - uniform mediump float imageWidthFactor; - uniform mediump float imageHeightFactor; + uniform highp float imageWidthFactor; + uniform highp float imageHeightFactor; varying vec2 textureCoordinate; varying vec2 leftTextureCoordinate; @@ -44,10 +44,10 @@ void main() { gl_Position = position; - mediump vec2 widthStep = vec2(imageWidthFactor, 0.0); - mediump vec2 heightStep = vec2(0.0, imageHeightFactor); - mediump vec2 widthHeightStep = vec2(imageWidthFactor, imageHeightFactor); - mediump vec2 widthNegativeHeightStep = vec2(imageWidthFactor, -imageHeightFactor); + vec2 widthStep = vec2(imageWidthFactor, 0.0); + vec2 heightStep = vec2(0.0, imageHeightFactor); + vec2 widthHeightStep = vec2(imageWidthFactor, imageHeightFactor); + vec2 widthNegativeHeightStep = vec2(imageWidthFactor, -imageHeightFactor); textureCoordinate = inputTextureCoordinate.xy; leftTextureCoordinate = inputTextureCoordinate.xy - widthStep; @@ -138,6 +138,7 @@ - (id)initWithFragmentShaderFromString:(NSString *)fragmentShaderString; - (void)setupFilterForSize:(CGSize)filterFrameSize; { + NSLog(@"Setting up Sobel filter for size: %f, %f", filterFrameSize.width, filterFrameSize.height); if (!hasOverriddenImageSizeFactor) { _imageWidthFactor = filterFrameSize.width; diff --git a/framework/Source/GPUImageTwoPassFilter.m b/framework/Source/GPUImageTwoPassFilter.m index d6b0c3f59..8cac8965d 100644 --- a/framework/Source/GPUImageTwoPassFilter.m +++ b/framework/Source/GPUImageTwoPassFilter.m @@ -132,6 +132,12 @@ - (void)setSecondFilterFBO; // glViewport(0, 0, (int)currentFBOSize.width, (int)currentFBOSize.height); } +- (void)setOutputFBO; +{ + // Override this for filters that have multiple framebuffers + [self setSecondFilterFBO]; +} + #pragma mark - #pragma mark Rendering