Skip to content

Commit

Permalink
Fixed some memory-related issues from copying and pasting code from a…
Browse files Browse the repository at this point in the history
…n ARC-enabled project (thanks Scott).
  • Loading branch information
BradLarson committed Feb 15, 2012
1 parent 5b06cfd commit 0c34c11
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Exclude the build directory
build/*

# Exclude temp nibs and swap files
*~.nib
*.swp

# Exclude OS X folder attributes
.DS_Store

# Exclude user-specific XCode 3 and 4 files
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata
44 changes: 22 additions & 22 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,6 @@ Technical requirements
- Devices must have a camera to use camera-related functionality (obviously)
- Compatible with applications using either automatic or manual reference counting

Adding the framework to your iOS project
========================================

Once you have the latest source code for the framework, it's fairly straightforward to add it to your application. Start by dragging the GPUImage.xcodeproj file into your application's Xcode project to embed the framework in your project. Next, go to your application's target and add GPUImage as a Target Dependency. Finally, you'll want to drag the libGPUImage.a library from the GPUImage framework's Products folder to the Link Binary With Libraries build phase in your application's target.

GPUImage needs a few other frameworks to be linked into your application, so you'll need to add the following as linked libraries in your application target:

- CoreMedia
- CoreVideo
- OpenGLES
- AVFoundation
- QuartzCore

You'll also need to find the framework headers, so within your project's build settings set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the GPUImage source directory. Make this header search path recursive.

To use the GPUImage classes within your application, simply include the core framework header using the following:

#import "GPUImage.h"

As a note: if you run into the error "Unknown class GPUImageView in Interface Builder" or the like when trying to build an interface with Interface Builder, you may need to add -ObjC to your Other Linker Flags in your project's build settings.

General architecture
====================

Expand All @@ -73,6 +52,27 @@ A small number of filters are built in:

but you can easily write your own custom filters using the C-like OpenGL Shading Language, as described below.

Adding the framework to your iOS project
========================================

Once you have the latest source code for the framework, it's fairly straightforward to add it to your application. Start by dragging the GPUImage.xcodeproj file into your application's Xcode project to embed the framework in your project. Next, go to your application's target and add GPUImage as a Target Dependency. Finally, you'll want to drag the libGPUImage.a library from the GPUImage framework's Products folder to the Link Binary With Libraries build phase in your application's target.

GPUImage needs a few other frameworks to be linked into your application, so you'll need to add the following as linked libraries in your application target:

- CoreMedia
- CoreVideo
- OpenGLES
- AVFoundation
- QuartzCore

You'll also need to find the framework headers, so within your project's build settings set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the GPUImage source directory. Make this header search path recursive.

To use the GPUImage classes within your application, simply include the core framework header using the following:

#import "GPUImage.h"

As a note: if you run into the error "Unknown class GPUImageView in Interface Builder" or the like when trying to build an interface with Interface Builder, you may need to add -ObjC to your Other Linker Flags in your project's build settings.

Performing common tasks
=======================

Expand Down Expand Up @@ -149,7 +149,7 @@ void main()
gl_FragColor = outputColor;
}

For an image filter to be usable within the GPUImage framework, the first two lines that take in the textureCoordinate varying (for the current coordinate within the texture, normalized to 1.0) and the inputImageTexture varying (for the actual input image frame texture) are required.
For an image filter to be usable within the GPUImage framework, the first two lines that take in the textureCoordinate varying (for the current coordinate within the texture, normalized to 1.0) and the inputImageTexture uniform (for the actual input image frame texture) are required.

The remainder of the shader grabs the color of the pixel at this location in the passed-in texture, manipulates it in such a way as to produce a sepia tone, and writes that pixel color out to be used in the next stage of the processing pipeline.

Expand Down
2 changes: 2 additions & 0 deletions framework/GPUImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
SYMROOT = "$(PROJECT_DIR)/../build";
};
Expand All @@ -433,6 +434,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
SYMROOT = "$(PROJECT_DIR)/../build";
VALIDATE_PRODUCT = YES;
Expand Down
5 changes: 4 additions & 1 deletion framework/Source/GLProgram.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ - (NSString *)logForOpenGLObject:(GLuint)object
length:logLength
encoding:NSUTF8StringEncoding];
free(logBytes);
return log;
return [log autorelease];
}
// END:privatelog
// START:log
Expand Down Expand Up @@ -238,6 +238,8 @@ - (void)validate;
// START:dealloc
- (void)dealloc
{
[attributes release];
[uniforms release];

if (vertShader)
glDeleteShader(vertShader);
Expand All @@ -248,6 +250,7 @@ - (void)dealloc
if (program)
glDeleteProgram(program);

[super dealloc];
}
// END:dealloc
@end
1 change: 1 addition & 0 deletions framework/Source/GPUImageFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ - (UIImage *)imageByFilteringImage:(UIImage *)imageToFilter;
UIImage *processedImage = [self imageFromCurrentlyProcessedOutput];

[stillImageSource removeTarget:self];
[stillImageSource release];
return processedImage;
}

Expand Down

0 comments on commit 0c34c11

Please sign in to comment.