Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a "wood" texture for the side in the Flip transition.

Also tried using Xcode 4.
  • Loading branch information...
commit 21521d5b7a1e6c49cc5be84fc6fe1519a899e690 1 parent 98c0a00
@epatel authored
View
4 DemoProject-iPad/DemoProject.xcodeproj/project.pbxproj
@@ -27,6 +27,7 @@
3A0BB4D811A9EA7500C6C3D4 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3A0BB4D511A9EA7500C6C3D4 /* MainWindow.xib */; };
3A20F7BE12F87AD70015365E /* EPGLTransitionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A20F7BD12F87AD70015365E /* EPGLTransitionView.m */; };
3A4826D211D93FE10059B460 /* Demo3Transition.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A4826D111D93FE10059B460 /* Demo3Transition.m */; };
+ 3AB5FE98136DD59B004E62D6 /* table.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 3AB5FE97136DD59B004E62D6 /* table.jpg */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -61,6 +62,7 @@
3A4826D111D93FE10059B460 /* Demo3Transition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo3Transition.m; path = ../src/Demo3Transition.m; sourceTree = SOURCE_ROOT; };
3A7D0F6E117A423D00CFAD01 /* Demo2Transition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Demo2Transition.h; path = ../src/Demo2Transition.h; sourceTree = SOURCE_ROOT; };
3A7D0F6F117A423D00CFAD01 /* Demo2Transition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo2Transition.m; path = ../src/Demo2Transition.m; sourceTree = SOURCE_ROOT; };
+ 3AB5FE97136DD59B004E62D6 /* table.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = table.jpg; path = ../DemoProject/table.jpg; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* DemoProject-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "DemoProject-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -151,6 +153,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ 3AB5FE97136DD59B004E62D6 /* table.jpg */,
3A112DDF113A9345004D04A4 /* painting.jpg */,
8D1107310486CEB800E47090 /* DemoProject-Info.plist */,
);
@@ -247,6 +250,7 @@
3A0BB4D611A9EA7500C6C3D4 /* FlipsideView.xib in Resources */,
3A0BB4D711A9EA7500C6C3D4 /* MainView.xib in Resources */,
3A0BB4D811A9EA7500C6C3D4 /* MainWindow.xib in Resources */,
+ 3AB5FE98136DD59B004E62D6 /* table.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
4 DemoProject/DemoProject.xcodeproj/project.pbxproj
@@ -27,6 +27,7 @@
3A112DE0113A9345004D04A4 /* painting.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 3A112DDF113A9345004D04A4 /* painting.jpg */; };
3A7D0F70117A423D00CFAD01 /* Demo2Transition.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A7D0F6F117A423D00CFAD01 /* Demo2Transition.m */; };
3A81AF5E11D92E9F002C1EFB /* Demo3Transition.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A81AF5D11D92E9F002C1EFB /* Demo3Transition.m */; };
+ 3A87BA9E136DCD460017976E /* table.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 3A87BA9D136DCD460017976E /* table.jpg */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -61,6 +62,7 @@
3A7D0F6F117A423D00CFAD01 /* Demo2Transition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo2Transition.m; path = ../src/Demo2Transition.m; sourceTree = SOURCE_ROOT; };
3A81AF5C11D92E9F002C1EFB /* Demo3Transition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Demo3Transition.h; path = ../src/Demo3Transition.h; sourceTree = SOURCE_ROOT; };
3A81AF5D11D92E9F002C1EFB /* Demo3Transition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Demo3Transition.m; path = ../src/Demo3Transition.m; sourceTree = SOURCE_ROOT; };
+ 3A87BA9D136DCD460017976E /* table.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = table.jpg; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* DemoProject-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "DemoProject-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -150,6 +152,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ 3A87BA9D136DCD460017976E /* table.jpg */,
3A112DDF113A9345004D04A4 /* painting.jpg */,
280E754A0DD40C5E005A515E /* FlipsideView.xib */,
280E754B0DD40C5E005A515E /* MainView.xib */,
@@ -239,6 +242,7 @@
280E754F0DD40C5E005A515E /* MainWindow.xib in Resources */,
3A112DA9113A8EB2004D04A4 /* README.txt in Resources */,
3A112DE0113A9345004D04A4 /* painting.jpg in Resources */,
+ 3A87BA9E136DCD460017976E /* table.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
BIN  DemoProject/table.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  FlipReader-iPad/Classes/MyPDFView.m
@@ -51,7 +51,6 @@ - (void)drawRect:(CGRect)rect {
CGFloat nudge = ((frameRect.size.height/scaleFactorWidth) - pageRect.size.height) / 2.0;
CGContextRef context = UIGraphicsGetCurrentContext();
-
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(context, frameRect);
CGContextSaveGState(context);
@@ -77,7 +76,7 @@ - (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
- CGContextFillRect(context, frameRect);
+ //CGContextFillRect(context, frameRect);
CGContextSaveGState(context);
CGContextTranslateCTM(context, 0, rect.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
View
1  src/Demo3Transition.h
@@ -30,6 +30,7 @@
@interface Demo3Transition : NSObject<EPGLTransitionViewDelegate> {
float f;
+ GLuint woodTexture;
}
@end
View
61 src/Demo3Transition.m
@@ -36,6 +36,35 @@ - (void)setupTransition
glLoadIdentity();
glEnable(GL_CULL_FACE);
f = 0;
+
+ CGImageRef woodImage;
+ size_t width;
+ size_t height;
+
+ woodImage = [UIImage imageNamed:@"table.jpg"].CGImage;
+
+ width = CGImageGetWidth(woodImage);
+ height = CGImageGetHeight(woodImage);
+
+ if (woodImage) {
+ GLubyte *woodImageData = (GLubyte *)calloc(width * height * 4, sizeof(GLubyte));
+ CGContextRef imageContext = CGBitmapContextCreate(woodImageData,
+ width,
+ height,
+ 8,
+ width * 4,
+ CGImageGetColorSpace(woodImage),
+ kCGImageAlphaPremultipliedLast);
+ CGContextDrawImage(imageContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), woodImage);
+ CGContextRelease(imageContext);
+
+ glGenTextures(1, &woodTexture);
+ glBindTexture(GL_TEXTURE_2D, woodTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, woodImageData);
+ free(woodImageData);
+ }
}
// GL context is active and screen texture bound to be used
@@ -63,11 +92,19 @@ - (BOOL)drawTransitionFrameWithTextureFrom:(GLuint)textureFromView
1, 1.5, 0,
};
+ GLfloat texcoordsSide[] = {
+ 0.0, 0.0,
+ 0.0, 1.0,
+ 0.167, 0.0,
+ 0.167, 1.0,
+ };
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
glColor4f(1, 1, 1, 1);
glVertexPointer(2, GL_FLOAT, 0, vertices);
- glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
float v = -(-cos(f)+1.0)/2.0; // For a little ease-in-ease-out
@@ -75,29 +112,22 @@ - (BOOL)drawTransitionFrameWithTextureFrom:(GLuint)textureFromView
glTranslatef(0, 0, -4.25-sin(-v*M_PI));
glRotatef(v*180, 0, 1, 0);
glTranslatef(0, 0, 0.25);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw front
- glColor4f(0.2, 0.2, 0.2, 1);
- glDisable(GL_TEXTURE_2D);
-
- glVertexPointer(3, GL_FLOAT, 0, verticesSide);
- glEnableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glBindTexture(GL_TEXTURE_2D, woodTexture);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glVertexPointer(3, GL_FLOAT, 0, verticesSide);
+ glTexCoordPointer(2, GL_FLOAT, 0, texcoordsSide);
- glColor4f(1, 1, 1, 1);
- glEnable(GL_TEXTURE_2D);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw side
glVertexPointer(2, GL_FLOAT, 0, vertices);
- glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindTexture(GL_TEXTURE_2D, textureToView);
glTranslatef(0, 0, -0.5);
glRotatef(180, 0, 1, 0);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // Draw back
glPopMatrix();
f += M_PI/80.0;
@@ -107,6 +137,7 @@ - (BOOL)drawTransitionFrameWithTextureFrom:(GLuint)textureFromView
- (void)transitionEnded
{
+ glDeleteTextures(1, &woodTexture);
}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.