kCCTexture2DPixelFormat for BGRA ?

kCCTexture2DPixelFormat for BGRA ?
0.0 0



As far as I know cocos2dx doesn’t support BGRA picture format, so I have to use the RGBA format.
I’m trying to implement the camera picture stream as a texture.
The picture stream works fine, but because iOs supports just kCVPixelFormatType_32BGRA, I have to swap the colors red and blue.

Thx for help,


The enum CCTexture2DPixelFormat finally affects glTexImage2D function. You can read the source in CCTexture2D.cpp line 169. Also it’s the same in cocos2d-iphone/cocos2d/CCTexture2D.m.
As the result, only OpenGL ES acceptable PixelFormats & PixelTypes can be supported in cocos2d-x.

// in ES1/gl.h
/* PixelFormat */
#define GL_ALPHA                          0x1906
#define GL_RGB                            0x1907
#define GL_RGBA                           0x1908
#define GL_LUMINANCE                      0x1909
#define GL_LUMINANCE_ALPHA                0x190A

/* PixelType */
#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
#define GL_UNSIGNED_SHORT_5_6_5           0x8363

cocos2d-iphone can works a little more because it supports PVRTexture, which contents BGRA_8888 pixel format. Since most android devices aren’t using PowerVR chipset as their opengles hardware acceleration, cocos2d-x still have no plan to support PVR texture format yet.
So currently, swapping B&R bits manually is the best approach, no matter in your application logic source or in the engine internal