Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added leftToRight animation to Demo3Transition

  • Loading branch information...
commit 9c785709da135c70028b1a2f616d7cb56b29069a 1 parent f6346fa
Edward Patel authored July 20, 2012
1  DemoProject-iPad/Classes/MainViewController.m
@@ -61,6 +61,7 @@ - (IBAction)showInfo:(id)sender
61 61
 			break;
62 62
 		case 2:
63 63
 			transition = [[[Demo3Transition alloc] init] autorelease];
  64
+           ((Demo3Transition*)transition).leftToRight = YES;
64 65
 			break;
65 66
 	}
66 67
     
3  src/Demo3Transition.h
@@ -31,6 +31,9 @@
31 31
 @interface Demo3Transition : NSObject<EPGLTransitionViewDelegate> {
32 32
     float f;
33 33
     GLuint woodTexture;
  34
+    BOOL leftToRight;
34 35
 }
35 36
 
  37
+@property (assign) BOOL leftToRight;
  38
+
36 39
 @end
27  src/Demo3Transition.m
@@ -26,6 +26,8 @@ of this software and associated documentation files (the "Software"), to deal
26 26
 
27 27
 @implementation Demo3Transition
28 28
 
  29
+@synthesize leftToRight;
  30
+
29 31
 - (void)setupTransition
30 32
 {
31 33
     // Setup matrices
@@ -48,7 +50,11 @@ - (void)setupTransition
48 50
     glMatrixMode(GL_MODELVIEW);
49 51
     glLoadIdentity();    
50 52
     glEnable(GL_CULL_FACE);
51  
-    f = 0;
  53
+
  54
+    if (leftToRight)
  55
+        f = M_PI;
  56
+    else
  57
+        f = 0;
52 58
 
53 59
     CGImageRef woodImage;
54 60
     size_t width;
@@ -112,6 +118,9 @@ - (BOOL)drawTransitionFrameWithTextureFrom:(GLuint)textureFromView
112 118
         0.167, 1.0,
113 119
     };
114 120
     
  121
+    if (leftToRight)
  122
+    	glBindTexture(GL_TEXTURE_2D, textureToView);
  123
+
115 124
     glEnableClientState(GL_VERTEX_ARRAY);
116 125
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
117 126
 
@@ -137,15 +146,23 @@ - (BOOL)drawTransitionFrameWithTextureFrom:(GLuint)textureFromView
137 146
     glVertexPointer(2, GL_FLOAT, 0, vertices);
138 147
     glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
139 148
 
140  
-	glBindTexture(GL_TEXTURE_2D, textureToView);
  149
+    if (leftToRight)
  150
+        glBindTexture(GL_TEXTURE_2D, textureFromView);
  151
+    else
  152
+        glBindTexture(GL_TEXTURE_2D, textureToView);
  153
+    
141 154
     glTranslatef(0, 0, -0.5);
142 155
 	glRotatef(180, 0, 1, 0);
143 156
     glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw back
144 157
     glPopMatrix();
145 158
 
146  
-    f += M_PI/80.0;
147  
-    
148  
-    return f < M_PI;
  159
+    if (leftToRight) {
  160
+        f -= M_PI/80.0;
  161
+        return f > 0.0;
  162
+    } else {
  163
+        f += M_PI/80.0;   
  164
+        return f < M_PI;
  165
+    }
149 166
 }
150 167
 
151 168
 - (void)transitionEnded

0 notes on commit 9c78570

Please sign in to comment.
Something went wrong with that request. Please try again.