Information valid for cocos2d v0.99.4 and newer
The default color buffer is RGB565. It is a 16-bit buffer, without alpha. In order to use an RGBA8 color buffer, you need to create initialize the EAGLView with:
EAGLView *glView = [EAGLView viewWithFrame:[window bounds] pixelFormat:kEAGLColorFormatRGBA8];
By default, cocos2d doesn't use a depth buffer, but you can create one when you initialize the EAGLView with a 16-bit or 24-bit depth buffer.
eg:
EAGLView *glView = [EAGLView viewWithFrame:[window bounds] pixelFormat:kEAGLColorFormatRGBA8 depthFormat:GL_DEPTH_COMPONENT24_OES];
Since v0.99.4, the Director can set the color render buffer in High Res mode:
eg:
// Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices if ([UIScreen instancesRespondToSelector:@selector(scale)]) [director setContentScaleFactor:[[UIScreen mainScreen] scale]];
Since v0.99.5, the suggested way to enable Retina display is:
// Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices if( ! [director enableRetinaDisplay:YES] ) CCLOG(@"Retina Display Not supported");
How does it work:
Multi sampling works on all devices, but on MBX devices the performance impact is severe.
How to enable it:
Don't use the CC_DIRECTOR_INIT() macro, but use the code from the sample below.
Complete sample of how to setup cocos2d:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Init the window window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // must be called before any other call to the director [CCDirector setDirectorType:kCCDirectorTypeDisplayLink]; // before creating any layer, set the landscape mode CCDirector *director = [CCDirector sharedDirector]; // landscape orientation [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft]; // set FPS at 60 [director setAnimationInterval:1.0/60]; // Display FPS: yes [director setDisplayFPS:YES]; // Create an EAGLView with a RGB8 color buffer, and a depth buffer of 24-bits EAGLView *glView = [EAGLView viewWithFrame:[window bounds] pixelFormat:kEAGLColorFormatRGBA8 // RGBA8 color buffer depthFormat:GL_DEPTH_COMPONENT24_OES // 24-bit depth buffer preserveBackbuffer:NO sharegroup:nil //for sharing OpenGL contexts between threads multiSampling:NO //YES to enable it numberOfSamples:0 //can be 1 - 4 if multiSampling=YES ]; // attach the openglView to the director [director setOpenGLView:glView]; // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices if( ! [director enableRetinaDisplay:YES] ) CCLOG(@"Retina Display Not supported"); // make the OpenGLView a child of the main window [window addSubview:glView]; // make main window visible [window makeKeyAndVisible]; // Default texture format for PNG/BMP/TIFF/JPEG/GIF images // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565 // You can change anytime. [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888]; // create the main scene CCScene *scene = [...]; // and run it! [director runWithScene: scene]; return YES; }