Permalink
Browse files

Added leftToRight animation to Demo3Transition

  • Loading branch information...
1 parent f6346fa commit 9c785709da135c70028b1a2f616d7cb56b29069a @epatel committed Jul 20, 2012
Showing with 26 additions and 5 deletions.
  1. +1 −0 DemoProject-iPad/Classes/MainViewController.m
  2. +3 −0 src/Demo3Transition.h
  3. +22 −5 src/Demo3Transition.m
@@ -61,6 +61,7 @@ - (IBAction)showInfo:(id)sender
break;
case 2:
transition = [[[Demo3Transition alloc] init] autorelease];
+ ((Demo3Transition*)transition).leftToRight = YES;
break;
}
View
@@ -31,6 +31,9 @@
@interface Demo3Transition : NSObject<EPGLTransitionViewDelegate> {
float f;
GLuint woodTexture;
+ BOOL leftToRight;
}
+@property (assign) BOOL leftToRight;
+
@end
View
@@ -26,6 +26,8 @@ of this software and associated documentation files (the "Software"), to deal
@implementation Demo3Transition
+@synthesize leftToRight;
+
- (void)setupTransition
{
// Setup matrices
@@ -48,7 +50,11 @@ - (void)setupTransition
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_CULL_FACE);
- f = 0;
+
+ if (leftToRight)
+ f = M_PI;
+ else
+ f = 0;
CGImageRef woodImage;
size_t width;
@@ -112,6 +118,9 @@ - (BOOL)drawTransitionFrameWithTextureFrom:(GLuint)textureFromView
0.167, 1.0,
};
+ if (leftToRight)
+ glBindTexture(GL_TEXTURE_2D, textureToView);
+
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -137,15 +146,23 @@ - (BOOL)drawTransitionFrameWithTextureFrom:(GLuint)textureFromView
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
- glBindTexture(GL_TEXTURE_2D, textureToView);
+ if (leftToRight)
+ glBindTexture(GL_TEXTURE_2D, textureFromView);
+ else
+ glBindTexture(GL_TEXTURE_2D, textureToView);
+
glTranslatef(0, 0, -0.5);
glRotatef(180, 0, 1, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw back
glPopMatrix();
- f += M_PI/80.0;
-
- return f < M_PI;
+ if (leftToRight) {
+ f -= M_PI/80.0;
+ return f > 0.0;
+ } else {
+ f += M_PI/80.0;
+ return f < M_PI;
+ }
}
- (void)transitionEnded

0 comments on commit 9c78570

Please sign in to comment.