issue #1310: modify some format

This commit is contained in:
minggo 2012-06-13 11:23:43 +08:00
parent b282d52a65
commit ec4a21eaf4
1 changed files with 35 additions and 37 deletions

View File

@ -55,46 +55,44 @@ enum {
static char gPVRTexIdentifier[5] = "PVR!"; static char gPVRTexIdentifier[5] = "PVR!";
/*
List of formats in pvr container
*/
enum enum
{ {
kPVRTextureFlagTypeRGBA_4444= 0x10, kPVRTexturePixelTypeRGBA_4444= 0x10,
kPVRTextureFlagTypeRGBA_5551, kPVRTexturePixelTypeRGBA_5551,
kPVRTextureFlagTypeRGBA_8888, kPVRTexturePixelTypeRGBA_8888,
kPVRTextureFlagTypeRGB_565, kPVRTexturePixelTypeRGB_565,
kPVRTextureFlagTypeRGB_555, // unsupported kPVRTexturePixelTypeRGB_555, // unsupported
kPVRTextureFlagTypeRGB_888, kPVRTexturePixelTypeRGB_888,
kPVRTextureFlagTypeI_8, kPVRTexturePixelTypeI_8,
kPVRTextureFlagTypeAI_88, kPVRTexturePixelTypeAI_88,
kPVRTextureFlagTypePVRTC_2, kPVRTexturePixelTypePVRTC_2,
kPVRTextureFlagTypePVRTC_4, kPVRTexturePixelTypePVRTC_4,
kPVRTextureFlagTypeBGRA_8888, kPVRTexturePixelTypeBGRA_8888,
kPVRTextureFlagTypeA_8, kPVRTexturePixelTypeA_8,
}; };
static const unsigned int tableFormats[][7] = { static const unsigned int tableFormats[][7] = {
// - PVR texture format // - PVR texture format
// - OpenGL internal format // - OpenGL internal format
// - OpenGL format // - OpenGL format
// - OpenGL type // - OpenGL type
// - bpp // - bpp
// - compressed // - compressed
// - Cocos2d texture format constant // - Cocos2d texture format constant
{kPVRTextureFlagTypeRGBA_4444, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, kCCTexture2DPixelFormat_RGBA4444}, { kPVRTexturePixelTypeRGBA_4444, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, kCCTexture2DPixelFormat_RGBA4444 },
{kPVRTextureFlagTypeRGBA_5551, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, kCCTexture2DPixelFormat_RGB5A1}, { kPVRTexturePixelTypeRGBA_5551, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, kCCTexture2DPixelFormat_RGB5A1 },
{kPVRTextureFlagTypeRGBA_8888, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888}, { kPVRTexturePixelTypeRGBA_8888, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 },
{kPVRTextureFlagTypeRGB_565, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, kCCTexture2DPixelFormat_RGB565}, { kPVRTexturePixelTypeRGB_565, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, kCCTexture2DPixelFormat_RGB565 },
{kPVRTextureFlagTypeA_8, GL_ALPHA, GL_ALPHA,GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_A8}, { kPVRTexturePixelTypeRGB_888, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, kCCTexture2DPixelFormat_RGB888 },
{kPVRTextureFlagTypeI_8, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_I8 }, { kPVRTexturePixelTypeA_8, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_A8 },
{kPVRTextureFlagTypeAI_88, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, kCCTexture2DPixelFormat_AI88 }, { kPVRTexturePixelTypeI_8, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_I8 },
{ kPVRTexturePixelTypeAI_88, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,16, false, kCCTexture2DPixelFormat_AI88 },
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
{kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 }, { kPVRTexturePixelTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 },
{kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 }, { kPVRTexturePixelTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 },
{kPVRTextureFlagTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, #endif // iphone only
#endif { kPVRTexturePixelTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 },
}; };
//Tells How large is tableFormats //Tells How large is tableFormats
@ -234,17 +232,17 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len)
while (dataOffset < dataLength) while (dataOffset < dataLength)
{ {
switch (formatFlags) { switch (formatFlags) {
case kPVRTextureFlagTypePVRTC_2: case kPVRTexturePixelTypePVRTC_2:
blockSize = 8 * 4; // Pixel by pixel block size for 2bpp blockSize = 8 * 4; // Pixel by pixel block size for 2bpp
widthBlocks = width / 8; widthBlocks = width / 8;
heightBlocks = height / 4; heightBlocks = height / 4;
break; break;
case kPVRTextureFlagTypePVRTC_4: case kPVRTexturePixelTypePVRTC_4:
blockSize = 4 * 4; // Pixel by pixel block size for 4bpp blockSize = 4 * 4; // Pixel by pixel block size for 4bpp
widthBlocks = width / 4; widthBlocks = width / 4;
heightBlocks = height / 4; heightBlocks = height / 4;
break; break;
case kPVRTextureFlagTypeBGRA_8888: case kPVRTexturePixelTypeBGRA_8888:
if (CCConfiguration::sharedConfiguration()->isSupportsBGRA8888() == false) if (CCConfiguration::sharedConfiguration()->isSupportsBGRA8888() == false)
{ {
CCLOG("cocos2d: TexturePVR. BGRA8888 not supported on this device"); CCLOG("cocos2d: TexturePVR. BGRA8888 not supported on this device");