For Initializing the EAGLView the followings are required

Color Buffer

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];

    kEAGLColorFormatRGBA8: Creates an RGBA8 color buffer (32-bit)
    kEAGLColorFormatRGB565: Creates an RGB565 color buffer (16-bit). Faster, but without alpha (default)

Depth Buffer

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]

    GL_DEPTH_COMPONENT24_OES: 24-bit depth buffer
    GL_DEPTH_COMPONENT16_OES: 16-bit depth buffer
    0: No depth buffer will be created

High Res

Since v0.99.4, the Director can set the color render buffer in High Res mode:


// 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:

If you have an iPhone4, the screen resolution will be 960×640

MultiSampling, or Full Screen Anti-Aliasing

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.

Incoming search terms:

  • created a EAGLView