Permalink
Browse files

fixes issue #1334

Projection fixed when iPad + RetinaDisplay
  • Loading branch information...
1 parent db4b82c commit 26ecd3d629271d835cb9670b1a6ae57949057ee2 @ricardoquesada ricardoquesada committed Mar 11, 2012
View
@@ -91,6 +91,9 @@ People/companies who were/are contributing code to cocos2d for iPhone (alphabeti
Tests: Shader tests center the fragment shader effects on Mac
Director: On Mac, CC_DIRECTOR_INIT() centers the main window
+* Spencer Ho (https://github.com/spencerho):
+ Fixed gl projection when iPad Retina Display is being used.
+
* Steve Kanter (https://github.com/SteveKanter):
Added support for iPad Retina Display suffix in CCFileUtils
View
@@ -1,4 +1,4 @@
-version 2.0-rc0 XX-Feb-2012
+version 2.0-rc0 XX-Mar-2012
. [NEW] v1.1 Forward-ported changes:
Actions: CCRepeat ends as expected (issue #1288)
ColorLayer: incorrect size in init method
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -273,20 +273,23 @@ -(void) setProjection:(ccDirectorProjection)projection
case kCCDirectorProjection3D:
{
+ float zeye = [self getZEye];
+
glViewport(offset.x, offset.y, widthAspect, heightAspect);
kmGLMatrixMode(KM_GL_PROJECTION);
kmGLLoadIdentity();
kmMat4 matrixPerspective, matrixLookup;
- kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)widthAspect/heightAspect, 0.1f, 1500.0f);
+ kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2 );
+
kmGLMultMatrix(&matrixPerspective);
kmGLMatrixMode(KM_GL_MODELVIEW);
kmGLLoadIdentity();
kmVec3 eye, center, up;
- float eyeZ = size.height * [self getZEye] / winSizeInPixels_.height;
+ float eyeZ = size.height * zeye / winSizeInPixels_.height;
kmVec3Fill( &eye, size.width/2, size.height/2, eyeZ );
kmVec3Fill( &center, size.width/2, size.height/2, 0 );
@@ -208,7 +208,9 @@ -(void) setProjection:(ccDirectorProjection)projection
kmGLMatrixMode(KM_GL_PROJECTION);
kmGLLoadIdentity();
- kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)sizePoint.width/sizePoint.height, 0.5f, 1500.0f );
+// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)sizePoint.width/sizePoint.height, 0.5f, 1500.0f );
+ kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)sizePoint.width/sizePoint.height, zeye-sizePoint.height/2, zeye+sizePoint.height/2 );
+
kmGLMultMatrix(&matrixPerspective);
kmGLMatrixMode(KM_GL_MODELVIEW);
View
@@ -207,10 +207,13 @@ DEPRECATED_ATTRIBUTE @interface MacView : CCGLView
#endif
@end
+#if __CC_PLATFORM_IOS
@interface CCFileUtils (Deprecated)
// new: setiPhoneRetinaDisplaySuffix
+(void) setRetinaDisplaySuffix:(NSString*)suffix DEPRECATED_ATTRIBUTE;
@end
+#endif
+
#endif // CC_ENABLE_DEPRECATED
View
@@ -304,13 +304,14 @@ -(UIImage *)getUIImageFromBuffer
#endif
@end
+#if __CC_PLATFORM_IOS
@implementation CCFileUtils (Deprecated)
+(void) setRetinaDisplaySuffix:(NSString*)suffix
{
return [self setiPhoneRetinaDisplaySuffix:suffix];
}
@end
-
+#endif
#if __CC_PLATFORM_IOS
@@ -80,6 +80,13 @@
<key>Path</key>
<string>Resources/fps_images-hd.png</string>
</dict>
+ <key>Resources/fps_images-ipadhd.png</key>
+ <dict>
+ <key>Group</key>
+ <string>Resources</string>
+ <key>Path</key>
+ <string>Resources/fps_images-ipadhd.png</string>
+ </dict>
<key>Resources/Icon-72.png</key>
<dict>
<key>Group</key>
@@ -144,6 +151,7 @@
<string>Resources/Default.png</string>
<string>Resources/fps_images.png</string>
<string>Resources/fps_images-hd.png</string>
+ <string>Resources/fps_images-ipadhd.png</string>
<string>Resources/Icon-72.png</string>
<string>Resources/Icon-Small-50.png</string>
<string>Resources/Icon-Small.png</string>
@@ -70,10 +70,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// You can change anytime.
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
- // When in iPad / RetinaDisplay mode, CCFileUtils will append the "-ipad" / "-hd" to all loaded files
- // If the -ipad / -hdfile is not found, it will load the non-suffixed version
- [CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
- [CCFileUtils setRetinaDisplaySuffix:@"-hd"]; // Default on RetinaDisplay is "-hd"
+ // When in iPhone RetinaDisplay, iPad, iPad RetinaDisplay mode, CCFileUtils will append the "-hd", "-ipad", "-ipadhd" to all loaded files
+ // If the -hd, -ipad, -ipadhd files are not found, it will load the non-suffixed version
+ [CCFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
+ [CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
+ [CCFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
// Assume that PVR images have premultiplied alpha
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
@@ -73,10 +73,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// You can change anytime.
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
- // When in iPad / RetinaDisplay mode, CCFileUtils will append the "-ipad" / "-hd" to all loaded files
- // If the -ipad / -hdfile is not found, it will load the non-suffixed version
- [CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
- [CCFileUtils setRetinaDisplaySuffix:@"-hd"]; // Default on RetinaDisplay is "-hd"
+ // When in iPhone RetinaDisplay, iPad, iPad RetinaDisplay mode, CCFileUtils will append the "-hd", "-ipad", "-ipadhd" to all loaded files
+ // If the -hd, -ipad, -ipadhd files are not found, it will load the non-suffixed version
+ [CCFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
+ [CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
+ [CCFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
// Assume that PVR images have premultiplied alpha
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
@@ -70,10 +70,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// You can change anytime.
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
- // When in iPad / RetinaDisplay mode, CCFileUtils will append the "-ipad" / "-hd" to all loaded files
- // If the -ipad / -hdfile is not found, it will load the non-suffixed version
- [CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
- [CCFileUtils setRetinaDisplaySuffix:@"-hd"]; // Default on RetinaDisplay is "-hd"
+ // When in iPhone RetinaDisplay, iPad, iPad RetinaDisplay mode, CCFileUtils will append the "-hd", "-ipad", "-ipadhd" to all loaded files
+ // If the -hd, -ipad, -ipadhd files are not found, it will load the non-suffixed version
+ [CCFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
+ [CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
+ [CCFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
// Assume that PVR images have premultiplied alpha
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
View
@@ -1427,7 +1427,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// If the -hd, -ipad, -ipadhd files are not found, it will load the non-suffixed version
[CCFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
[CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
- [CCFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
+ [CCFileUtils setiPadRetinaDisplaySuffix:@"-hd"]; // Default on iPad RetinaDisplay is "-ipadhd"
CCScene *scene = [CCScene node];
[scene addChild: [nextAction() node]];
@@ -1437,10 +1437,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}
--(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- return UIInterfaceOrientationIsLandscape(interfaceOrientation);
-}
+//-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+//{
+// return UIInterfaceOrientationIsLandscape(interfaceOrientation);
+//}
@end
#elif defined(__CC_PLATFORM_MAC)
View
@@ -4609,8 +4609,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// When in iPhone RetinaDisplay, iPad, iPad RetinaDisplay mode, CCFileUtils will append the "-hd", "-ipad", "-ipadhd" to all loaded files
// If the -hd, -ipad, -ipadhd files are not found, it will load the non-suffixed version
[CCFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
- [CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
- [CCFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
+ [CCFileUtils setiPadSuffix:@""]; // Default on iPad is "" (empty string)
+ [CCFileUtils setiPadRetinaDisplaySuffix:@"-hd"]; // Default on iPad RetinaDisplay is "-ipadhd"
// Assume that PVR images have premultiplied alpha
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
View
@@ -467,7 +467,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// If the -hd, -ipad, -ipadhd files are not found, it will load the non-suffixed version
[CCFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
[CCFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "" (empty string)
- [CCFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
+ [CCFileUtils setiPadRetinaDisplaySuffix:@"-hd"]; // Default on iPad RetinaDisplay is "-ipadhd"
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565

0 comments on commit 26ecd3d

Please sign in to comment.