forked from tapsquare/GPUImage
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an OpenGL ES texture output class, and a sample application to …
…show this off.
- Loading branch information
1 parent
cb23fa0
commit e77fc9d
Showing
22 changed files
with
1,615 additions
and
18 deletions.
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
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 <UIKit/UIKit.h> | ||
|
||
@class EAGLView; | ||
|
||
@interface CubeExampleAppDelegate : NSObject <UIApplicationDelegate> { | ||
UIWindow *window; | ||
EAGLView *glView; | ||
} | ||
|
||
@property (nonatomic, retain) IBOutlet UIWindow *window; | ||
@property (nonatomic, retain) IBOutlet EAGLView *glView; | ||
|
||
@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,34 @@ | ||
#import "CubeExampleAppDelegate.h" | ||
#import "EAGLView.h" | ||
|
||
@implementation CubeExampleAppDelegate | ||
|
||
@synthesize window; | ||
@synthesize glView; | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
return YES; | ||
} | ||
|
||
- (void)applicationWillResignActive:(UIApplication *)application | ||
{ | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application | ||
{ | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application | ||
{ | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[window release]; | ||
[glView release]; | ||
|
||
[super dealloc]; | ||
} | ||
|
||
@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,16 @@ | ||
#import <UIKit/UIKit.h> | ||
#import <QuartzCore/QuartzCore.h> | ||
|
||
#import "ESRenderer.h" | ||
|
||
@interface EAGLView : UIView | ||
{ | ||
CGPoint lastMovementPosition; | ||
@private | ||
id <ESRenderer> renderer; | ||
|
||
} | ||
|
||
- (void)drawView:(id)sender; | ||
|
||
@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,92 @@ | ||
#import "EAGLView.h" | ||
|
||
#import "ES2Renderer.h" | ||
|
||
@implementation EAGLView | ||
|
||
// You must implement this method | ||
+ (Class)layerClass | ||
{ | ||
return [CAEAGLLayer class]; | ||
} | ||
|
||
//The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder: | ||
- (id)initWithCoder:(NSCoder*)coder | ||
{ | ||
if ((self = [super initWithCoder:coder])) | ||
{ | ||
// Set scaling to account for Retina display | ||
if ([self respondsToSelector:@selector(setContentScaleFactor:)]) | ||
{ | ||
self.contentScaleFactor = [[UIScreen mainScreen] scale]; | ||
} | ||
|
||
// Get the layer | ||
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; | ||
|
||
eaglLayer.opaque = TRUE; | ||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: | ||
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; | ||
|
||
renderer = [[ES2Renderer alloc] init]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[renderer release]; | ||
|
||
[super dealloc]; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark UIView layout methods | ||
|
||
- (void)drawView:(id)sender | ||
{ | ||
[renderer renderByRotatingAroundX:0 rotatingAroundY:0]; | ||
} | ||
|
||
- (void)layoutSubviews | ||
{ | ||
NSLog(@"Scale factor: %f", self.contentScaleFactor); | ||
[renderer resizeFromLayer:(CAEAGLLayer*)self.layer]; | ||
[self drawView:nil]; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Touch-handling methods | ||
|
||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event | ||
{ | ||
NSMutableSet *currentTouches = [[[event touchesForView:self] mutableCopy] autorelease]; | ||
[currentTouches minusSet:touches]; | ||
|
||
// New touches are not yet included in the current touches for the view | ||
lastMovementPosition = [[touches anyObject] locationInView:self]; | ||
} | ||
|
||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; | ||
{ | ||
CGPoint currentMovementPosition = [[touches anyObject] locationInView:self]; | ||
[renderer renderByRotatingAroundX:(lastMovementPosition.x - currentMovementPosition.x) rotatingAroundY:(lastMovementPosition.y - currentMovementPosition.y)]; | ||
lastMovementPosition = currentMovementPosition; | ||
} | ||
|
||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event | ||
{ | ||
NSMutableSet *remainingTouches = [[[event touchesForView:self] mutableCopy] autorelease]; | ||
[remainingTouches minusSet:touches]; | ||
|
||
lastMovementPosition = [[remainingTouches anyObject] locationInView:self]; | ||
} | ||
|
||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event | ||
{ | ||
// Handle touches canceled the same as as a touches ended event | ||
[self touchesEnded:touches withEvent:event]; | ||
} | ||
|
||
@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,39 @@ | ||
#import "ESRenderer.h" | ||
|
||
#import <OpenGLES/ES2/gl.h> | ||
#import <OpenGLES/ES2/glext.h> | ||
#import <QuartzCore/QuartzCore.h> | ||
#import "GPUImage.h" | ||
|
||
@class PVRTexture; | ||
|
||
@interface ES2Renderer : NSObject <ESRenderer, GPUImageTextureOutputDelegate> | ||
{ | ||
@private | ||
EAGLContext *context; | ||
|
||
GLuint textureForCubeFace; | ||
|
||
// The pixel dimensions of the CAEAGLLayer | ||
GLint backingWidth; | ||
GLint backingHeight; | ||
|
||
// The OpenGL ES names for the framebuffer and renderbuffer used to render to this view | ||
GLuint defaultFramebuffer, colorRenderbuffer, depthBuffer, msaaFramebuffer, msaaRenderbuffer, msaaDepthbuffer; | ||
|
||
CATransform3D currentCalculatedMatrix; | ||
|
||
GLuint program; | ||
|
||
GPUImageVideoCamera *videoCamera; | ||
GPUImageFilter *inputFilter, *outputFilter; | ||
GPUImageTextureOutput *textureOutput; | ||
|
||
} | ||
|
||
- (void)renderByRotatingAroundX:(float)xRotation rotatingAroundY:(float)yRotation; | ||
- (BOOL)resizeFromLayer:(CAEAGLLayer *)layer; | ||
- (void)convert3DTransform:(CATransform3D *)transform3D toMatrix:(GLfloat *)matrix; | ||
|
||
@end | ||
|
Oops, something went wrong.