Http://bbs.tairan.com/thread-807-1-1.html
Director Buffer Information support for COCOS2D v0.99.4 and newer versions Color buffer This default buffer is RGB565. It is a 16-bit buffer with no alpha (it should be a CPU architecture). In order to change Chogn with RGBA8 color, you need to create and initialize Eaglview Eaglview *glview = [Eaglview viewwithframe:[window bounds] PIXELFORMAT:KEAGLCOLORFORMATRGBA8]; KEAGLColorFormatRGBA8: Create a RGBA8 color buffer (32-bit) kEAGLColorFormatRGB565: Creates a RGB565 color buffer (16 bits). Faster, but with no alpha
Depth buffer By default, cocos2d does not use depth buffering, but you can create one when you initialize Eaglview with a 16-bit or 24-bit depth buffer Eaglview *glview = [Eaglview viewwithframe:[window bounds] Pixelformat:keaglcolorformatrgba8 Depthformat:gl_depth_component24_oes]; Gl_depth_component24_oes:24 bit Depth Buffer Gl_depth_component16_oes:16 bit Depth Buffer 0: No depth buffer was created
High Resource Since v0.99.4, the director has been able to set the color to present in the buffer and high resource model: Enables high res mode (Retina Display) on the IPhone 4 and maintains low Res on all other devices if ([UIScreen instancesrespondtoselector: @selector (scale)]) [director Setcontentscalefactor:[[uiscreen Mainscreen] scale]]; Starting from v0.99.5, support for Retina screen display: Enables high res mode (Retina Display) on the IPhone 4 and maintains low Res on all other devices if (! [director Enableretinadisplay:yes]) Cclog (@ "Retina Display not supported"); How it works: If you have a iphon4, the display scheme is 960*640
Multi-point sampling, or full-screen anti_aliasing Multi-point sampling can be performed on all devices, but the impact is more dramatic in MBX devices How to use it Do not use Cc_director_init () macro. You can use the following example as a simple model -(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions { Init the window window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds];
Must be called before no 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 the 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; } |
|
|
Cocos2d Programming Guide Translator (12)