Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplify drawNextFrame and update the README

  • Loading branch information...
commit 2dafa973608a06b0ec1539da24cba0ec68218d00 1 parent 333be3c
@jamesu authored
View
34 README.markdown
@@ -2,7 +2,7 @@
## What is it?
-glgif is a fast and comprehensive library for playing back .gif animations on the iPhone using OpenGLES.
+glgif is a comprehensive library for playing back .gif animations on the iPhone using OpenGLES.
## Sounds great, how do i use it?
@@ -15,19 +15,37 @@ At the core, glgif merely uploads frames from a gif animation to an OpenGLES tex
// Init video using VideoSource
GifVideo *vid = [[GifVideo alloc] initWithSource:src inContext:[yourGLESContext]];
VideoSource_release(src);
-
- // Start playing the video
- [vid play:YES];
-
+
+ // Set up the disposal texture
+ [vid setupRenderTexture];
+
+ // Setup our OpenGL context (viewFramebuffer is the frame buffer, backingWidth & backingHeight is the framebuffer size)
+ GLfloat projectionMatrix[16];
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrthof(0, backingWidth, 0, backingHeight, -1, 1);
+ glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix);
+
+ // Tell the gif renderer where we are rendering to
+ vid.viewRenderInfo = TargetRenderInfoMake(viewFramebuffer, GIFRectMake(0, 0, backingWidth, backingHeight), projectionMatrix);
+
// Then every frame...
- [vid getFrame]; // grab new frame data
- glBindTexture(GL_TEXTURE_2D, vid.tex->tex); // bind the video texture!
+ [vid drawNextFrame:1.0f/60.0f]; // draw in the current opengl context
## 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];
+ [playerView startAnimation:vid];
+
+## Why is there a modified version of lungif?
+
+Normally lungif will keep around decoded versions of frames. Currently glgif does not use these frames - rather it decodes frames on the fly - so there is a hack which turns off the storage of these images via generateSavedImages.
+
+If you want to use a normal version of lungif simply uncomment the following in GifVideo.m:
+
+ if (gifinfo)
+ gifinfo->generateSavedImages = false;
## Do any cool iPhone applications use this code?
View
2  example/Classes/PlayerView.m
@@ -283,7 +283,7 @@ - (void)drawView {
glTranslatef(-(frameSize.width*0.5), -(frameSize.height*0.5), 0);
// Draw next frame
- drawn = [video drawNextFrame:animationInterval toView:self withBackingSize:CGSizeMake(backingWidth, backingHeight)];
+ drawn = [video drawNextFrame:animationInterval];
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
View
2  glgif/Video.h
@@ -146,7 +146,7 @@ void TargetRenderInfoSet(TargetRenderInfo info);
- (void)frameClipScale:(float*)scale;
- (CGSize)frameSize;
- (CGSize)backingSize;
-- (bool)drawNextFrame:(float)dt toView:(PlayerView*)view withBackingSize:(CGSize)size;
+- (bool)drawNextFrame:(float)dt;
- (bool)drawFrame:(VideoWorkerFrame_t*)frame andDisposal:(bool)updateDisposal;
- (void)drawPreviousFrame:(GIFRect)frameRect;
View
2  glgif/Video.m
@@ -132,7 +132,7 @@ - (void)drawPreviousFrame:(GIFRect)frameRect
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
-- (bool)drawNextFrame:(float)dt toView:(PlayerView*)view withBackingSize:(CGSize)size
+- (bool)drawNextFrame:(float)dt
{
GLfloat squareVertices[8];
GLfloat squareTexcoords[8];
Please sign in to comment.
Something went wrong with that request. Please try again.