Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 50e62a97c8a079fda3793c5114590178e3a771aa @jamesu committed Mar 31, 2009
@@ -0,0 +1,11 @@
+# xcode noise
+build/*
+*.pbxuser
+*.mode1v3
+
+# old skool
+.svn
+
+# osx noise
+.DS_Store
+profile
@@ -0,0 +1,24 @@
+Copyright (C) 2009 James S Urquhart
+
+test.gif sourced from http://www.webreference.com/dev/gifanim/art/frame_lzw_sg104.gif
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
+# glgif
+
+## What is it?
+
+glgif is a fast and comprehensive library for playing back .gif animations on the iPhone using OpenGLES.
+
+## Sounds great, how do i use it?
+
+At the core, glgif merely uploads frames from a gif animation to an OpenGLES texture. So all you need to do is the following:
+
+ // Load the gif
+ FILE *fp = fopen("test.gif", "r");
+ VideoSource *src = VideoSource_init(fp, VIDEOSOURCE_FILE);
+
+ // Init video using VideoSource
+ GifVideo *vid = [[GifVideo alloc] initWithSource:src inContext:[yourGLESContext]];
+ VideoSource_release(src);
+
+ // Start playing the video
+ [vid play:YES];
+
+ // Then every frame...
+ [vid getFrame]; // grab new frame data
+ glBindTexture(GL_TEXTURE_2D, vid.tex->tex); // bind the video texture!
+
+## Whoah, that is so complicated. Is there an easier way?
+
+Why yes, indeed there is! An example project has been included which implements a nice OpenGLES view to display a test .gif. So all you need to do once you make a GifVideo* is:
+
+ [playerView startAnimation:vid];
+
+## Do any cool iPhone applications use this code?
+
+The only app at the moment is "anim8gif":http://www.itunes.com/app/anim8gif .
@@ -0,0 +1,48 @@
+/*
+
+ glgif
+
+ GLGifExampleAppDelegate - example app delegate.
+
+ Copyright (C) 2009 James S Urquhart
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#import <UIKit/UIKit.h>
+
+@class GLGifExampleViewController;
+
+@interface GLGifExampleAppDelegate : NSObject <UIApplicationDelegate> {
+ UIWindow *window;
+ GLGifExampleViewController *viewController;
+
+ CGSize orientFrame;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet GLGifExampleViewController *viewController;
+
+@property (nonatomic, assign) CGSize orientFrame;
+
+@end
+
@@ -0,0 +1,57 @@
+/*
+
+ glgif
+
+ Copyright (C) 2009 James S Urquhart
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#import "GLGifExampleAppDelegate.h"
+#import "GLGifExampleViewController.h"
+
+@implementation GLGifExampleAppDelegate
+
+@synthesize window;
+@synthesize viewController;
+@synthesize orientFrame;
+
+
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
+ orientFrame = [UIScreen mainScreen].bounds.size;
+
+ // Override point for customization after app launch
+ [window addSubview:viewController.view];
+ [window makeKeyAndVisible];
+
+ viewController.okToRotate = YES;
+}
+
+
+- (void)dealloc {
+ [viewController release];
+ [window release];
+ [super dealloc];
+}
+
+
+@end
@@ -0,0 +1,41 @@
+/*
+
+ glgif
+
+ GLGifExampleViewController - example view controller.
+
+ Copyright (C) 2009 James S Urquhart
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#import <UIKit/UIKit.h>
+
+@interface GLGifExampleViewController : UIViewController {
+ bool okToRotate;
+
+}
+
+@property(assign) bool okToRotate;
+
+@end
+
@@ -0,0 +1,106 @@
+/*
+
+ glgif
+
+ Copyright (C) 2009 James S Urquhart
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#import "GLGifExampleViewController.h"
+#import "GifVideo.h"
+#import "VideoSource.h"
+#import "PlayerView.h"
+
+@implementation GLGifExampleViewController
+
+@synthesize okToRotate;
+
+
+// The designated initializer. Override to perform setup that is required before the view is loaded.
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
+ if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
+ // Custom initialization
+ okToRotate = false;
+ }
+ return self;
+}
+
+
+/*
+// Implement loadView to create a view hierarchy programmatically, without using a nib.
+- (void)loadView {
+}
+*/
+
+
+
+// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ PlayerView *plView = (PlayerView*)self.view;
+
+ // Load test.gif VideoSource
+ NSString *str = [[NSBundle mainBundle] pathForResource:@"test.gif" ofType:nil];
+ FILE *fp = fopen([str UTF8String], "r");
+ VideoSource *src = VideoSource_init(fp, VIDEOSOURCE_FILE);
+ src->writeable = false;
+
+ // Init video using VideoSource
+ Video *vid = [[GifVideo alloc] initWithSource:src inContext:[plView context]];
+ VideoSource_release(src);
+
+ // Start if loaded
+ if (vid) {
+ [plView startAnimation:vid];
+ [vid release];
+ return;
+ }
+
+ // Cleanup if failed
+ fclose(fp);
+ return;
+}
+
+
+
+
+// Override to allow orientations other than the default portrait orientation.
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ // Return YES for supported orientations
+ if (okToRotate)
+ [(PlayerView*)self.view setTargetOrient:interfaceOrientation];
+ return interfaceOrientation == UIInterfaceOrientationPortrait;
+}
+
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
+ // Release anything that's not essential, such as cached data
+}
+
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+@end
Oops, something went wrong. Retry.

0 comments on commit 50e62a9

Please sign in to comment.