mirror of https://github.com/axmolengine/axmol.git
issue #2533:add ATITC compressed texture support
soft decode test in Win32, ios, Mac. device decode test in HTC G14 Adreno 220 GPU.
This commit is contained in:
parent
a9a9c29e4a
commit
e8809b2b15
|
@ -1 +1 @@
|
||||||
1feddf59d7fbc2b063a496bbf4a4770d0ac4435e
|
846fbc5706592dfcb9b01212873d1f438558e992
|
|
@ -131,6 +131,7 @@ textures/CCTextureAtlas.cpp \
|
||||||
textures/CCTextureCache.cpp \
|
textures/CCTextureCache.cpp \
|
||||||
platform/third_party/common/etc/etc1.cpp\
|
platform/third_party/common/etc/etc1.cpp\
|
||||||
platform/third_party/common/s3tc/s3tc.cpp\
|
platform/third_party/common/s3tc/s3tc.cpp\
|
||||||
|
platform/third_party/common/atitc/atitc.cpp\
|
||||||
tilemap_parallax_nodes/CCParallaxNode.cpp \
|
tilemap_parallax_nodes/CCParallaxNode.cpp \
|
||||||
tilemap_parallax_nodes/CCTMXLayer.cpp \
|
tilemap_parallax_nodes/CCTMXLayer.cpp \
|
||||||
tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
||||||
|
@ -146,14 +147,16 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
|
||||||
$(LOCAL_PATH)/kazmath/include \
|
$(LOCAL_PATH)/kazmath/include \
|
||||||
$(LOCAL_PATH)/platform/android \
|
$(LOCAL_PATH)/platform/android \
|
||||||
$(LOCAL_PATH)/platform/third_party/common/etc\
|
$(LOCAL_PATH)/platform/third_party/common/etc\
|
||||||
$(LOCAL_PATH)/platform/third_party/common/s3tc
|
$(LOCAL_PATH)/platform/third_party/common/s3tc\
|
||||||
|
$(LOCAL_PATH)/platform/third_party/common/atitc
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
||||||
$(LOCAL_PATH)/include \
|
$(LOCAL_PATH)/include \
|
||||||
$(LOCAL_PATH)/kazmath/include \
|
$(LOCAL_PATH)/kazmath/include \
|
||||||
$(LOCAL_PATH)/platform/android \
|
$(LOCAL_PATH)/platform/android \
|
||||||
$(LOCAL_PATH)/platform/third_party/common/etc\
|
$(LOCAL_PATH)/platform/third_party/common/etc\
|
||||||
$(LOCAL_PATH)/platform/third_party/common/s3tc
|
$(LOCAL_PATH)/platform/third_party/common/s3tc\
|
||||||
|
$(LOCAL_PATH)/platform/third_party/common/atitc
|
||||||
|
|
||||||
|
|
||||||
LOCAL_LDLIBS := -lGLESv2 \
|
LOCAL_LDLIBS := -lGLESv2 \
|
||||||
|
|
|
@ -46,6 +46,7 @@ Configuration::Configuration()
|
||||||
, _supportsPVRTC(false)
|
, _supportsPVRTC(false)
|
||||||
, _supportsETC(false)
|
, _supportsETC(false)
|
||||||
, _supportsS3TC(false)
|
, _supportsS3TC(false)
|
||||||
|
, _supportsATITC(false)
|
||||||
, _supportsNPOT(false)
|
, _supportsNPOT(false)
|
||||||
, _supportsBGRA8888(false)
|
, _supportsBGRA8888(false)
|
||||||
, _supportsDiscardFramebuffer(false)
|
, _supportsDiscardFramebuffer(false)
|
||||||
|
@ -131,7 +132,10 @@ void Configuration::gatherGPUInfo()
|
||||||
_valueDict->setObject(Bool::create(_supportsETC), "gl.supports_ETC");
|
_valueDict->setObject(Bool::create(_supportsETC), "gl.supports_ETC");
|
||||||
|
|
||||||
_supportsS3TC = checkForGLExtension("GL_EXT_texture_compression_s3tc");
|
_supportsS3TC = checkForGLExtension("GL_EXT_texture_compression_s3tc");
|
||||||
_valueDict->setObject( Bool::create(_supportsS3TC), "gl.supports_S3TC");
|
_valueDict->setObject(Bool::create(_supportsS3TC), "gl.supports_S3TC");
|
||||||
|
|
||||||
|
_supportsATITC = checkForGLExtension("GL_AMD_compressed_ATC_texture");
|
||||||
|
_valueDict->setObject(Bool::create(_supportsATITC), "gl.supports_ATITC");
|
||||||
|
|
||||||
_supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
|
_supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
|
||||||
_valueDict->setObject(Bool::create(_supportsPVRTC), "gl.supports_PVRTC");
|
_valueDict->setObject(Bool::create(_supportsPVRTC), "gl.supports_PVRTC");
|
||||||
|
@ -238,6 +242,11 @@ bool Configuration::supportsS3TC() const
|
||||||
return _supportsS3TC;
|
return _supportsS3TC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configuration::supportsATITC() const
|
||||||
|
{
|
||||||
|
return _supportsATITC;
|
||||||
|
}
|
||||||
|
|
||||||
bool Configuration::supportsBGRA8888() const
|
bool Configuration::supportsBGRA8888() const
|
||||||
{
|
{
|
||||||
return _supportsBGRA8888;
|
return _supportsBGRA8888;
|
||||||
|
|
|
@ -88,7 +88,10 @@ public:
|
||||||
bool supportsETC() const;
|
bool supportsETC() const;
|
||||||
|
|
||||||
/** Whether or not S3TC Texture Compressed is supported */
|
/** Whether or not S3TC Texture Compressed is supported */
|
||||||
bool supportsS3TC(void ) const;
|
bool supportsS3TC() const;
|
||||||
|
|
||||||
|
/** Whether or not ATITC Texture Compressed is supported */
|
||||||
|
bool supportsATITC() const;
|
||||||
|
|
||||||
/** Whether or not BGRA8888 textures are supported.
|
/** Whether or not BGRA8888 textures are supported.
|
||||||
@since v0.99.2
|
@since v0.99.2
|
||||||
|
@ -148,6 +151,7 @@ protected:
|
||||||
bool _supportsPVRTC;
|
bool _supportsPVRTC;
|
||||||
bool _supportsETC;
|
bool _supportsETC;
|
||||||
bool _supportsS3TC;
|
bool _supportsS3TC;
|
||||||
|
bool _supportsATITC;
|
||||||
bool _supportsNPOT;
|
bool _supportsNPOT;
|
||||||
bool _supportsBGRA8888;
|
bool _supportsBGRA8888;
|
||||||
bool _supportsDiscardFramebuffer;
|
bool _supportsDiscardFramebuffer;
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
ETC,
|
ETC,
|
||||||
//! S3TC
|
//! S3TC
|
||||||
S3TC,
|
S3TC,
|
||||||
|
//! ATITC
|
||||||
|
ATITC,
|
||||||
//! Raw Data
|
//! Raw Data
|
||||||
RAW_DATA,
|
RAW_DATA,
|
||||||
//! Unknown format
|
//! Unknown format
|
||||||
|
@ -194,6 +196,7 @@ protected:
|
||||||
bool initWithPVRv3Data(const void *data, int dataLen);
|
bool initWithPVRv3Data(const void *data, int dataLen);
|
||||||
bool initWithETCData(const void *data, int dataLen);
|
bool initWithETCData(const void *data, int dataLen);
|
||||||
bool initWithS3TCData(const void *data, int dataLen);
|
bool initWithS3TCData(const void *data, int dataLen);
|
||||||
|
bool initWithATITCData(const void *data, int dataLen);
|
||||||
|
|
||||||
bool saveImageToPNG(const char *filePath, bool isToRGB = true);
|
bool saveImageToPNG(const char *filePath, bool isToRGB = true);
|
||||||
bool saveImageToJPG(const char *filePath);
|
bool saveImageToJPG(const char *filePath);
|
||||||
|
@ -238,7 +241,8 @@ private:
|
||||||
bool isWebp(const void *data, int dataLen);
|
bool isWebp(const void *data, int dataLen);
|
||||||
bool isPvr(const void *data, int dataLen);
|
bool isPvr(const void *data, int dataLen);
|
||||||
bool isEtc(const void *data, int dataLen);
|
bool isEtc(const void *data, int dataLen);
|
||||||
bool isS3TC(const void *data,int dataLen);
|
bool isS3TC(const void *data, int dataLen);
|
||||||
|
bool isATITC(const void *data, int dataLen);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ extern "C"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
}
|
}
|
||||||
#include "third_party/common/s3tc/s3tc.h"
|
#include "third_party/common/s3tc/s3tc.h"
|
||||||
|
#include "third_party/common/atitc/atitc.h"
|
||||||
#if defined(__native_client__) || defined(EMSCRIPTEN)
|
#if defined(__native_client__) || defined(EMSCRIPTEN)
|
||||||
// TODO(sbc): I'm pretty sure all platforms should be including
|
// TODO(sbc): I'm pretty sure all platforms should be including
|
||||||
// webph headers in this way.
|
// webph headers in this way.
|
||||||
|
@ -56,6 +57,7 @@ extern "C"
|
||||||
#include "CCConfiguration.h"
|
#include "CCConfiguration.h"
|
||||||
#include "support/ccUtils.h"
|
#include "support/ccUtils.h"
|
||||||
#include "support/zip_support/ZipUtils.h"
|
#include "support/zip_support/ZipUtils.h"
|
||||||
|
#include "CCGL.h"
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
#include "platform/android/CCFileUtilsAndroid.h"
|
#include "platform/android/CCFileUtilsAndroid.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -313,7 +315,33 @@ namespace
|
||||||
}
|
}
|
||||||
//s3tc struct end
|
//s3tc struct end
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//struct and data for atitc(ktx) struct
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct ATITCTexHeader
|
||||||
|
{
|
||||||
|
//HEADER
|
||||||
|
char identifier[12];
|
||||||
|
uint32_t endianness;
|
||||||
|
uint32_t glType;
|
||||||
|
uint32_t glTypeSize;
|
||||||
|
uint32_t glFormat;
|
||||||
|
uint32_t glInternalFormat;
|
||||||
|
uint32_t glBaseInternalFormat;
|
||||||
|
uint32_t pixelWidth;
|
||||||
|
uint32_t pixelHeight;
|
||||||
|
uint32_t pixelDepth;
|
||||||
|
uint32_t numberOfArrayElements;
|
||||||
|
uint32_t numberOfFaces;
|
||||||
|
uint32_t numberOfMipmapLevels;
|
||||||
|
uint32_t bytesOfKeyValueData;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
//atittc struct end
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -457,6 +485,8 @@ bool Image::initWithImageData(const void * data, int dataLen)
|
||||||
return initWithETCData(data, dataLen);
|
return initWithETCData(data, dataLen);
|
||||||
case Format::S3TC:
|
case Format::S3TC:
|
||||||
return initWithS3TCData(data, dataLen);
|
return initWithS3TCData(data, dataLen);
|
||||||
|
case Format::ATITC:
|
||||||
|
return initWithATITCData(data, dataLen);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
CCAssert(false, "unsupport image format!");
|
CCAssert(false, "unsupport image format!");
|
||||||
|
@ -491,7 +521,7 @@ bool Image::isS3TC(const void *data, int dataLen)
|
||||||
|
|
||||||
S3TCTexHeader *header = (S3TCTexHeader *)data;
|
S3TCTexHeader *header = (S3TCTexHeader *)data;
|
||||||
|
|
||||||
if (strncmp(header->fileCode, "DDS", 3)!= 0)
|
if (strncmp(header->fileCode, "DDS", 3) != 0)
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: the file is not a dds file!");
|
CCLOG("cocos2d: the file is not a dds file!");
|
||||||
return false;
|
return false;
|
||||||
|
@ -499,6 +529,18 @@ bool Image::isS3TC(const void *data, int dataLen)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Image::isATITC(const void *data, int dataLen)
|
||||||
|
{
|
||||||
|
ATITCTexHeader *header = (ATITCTexHeader *)data;
|
||||||
|
|
||||||
|
if (strncmp(&header->identifier[1], "KTX", 3) != 0)
|
||||||
|
{
|
||||||
|
CCLOG("cocos3d: the file is not a ktx file!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Image::isJpg(const void *data, int dataLen)
|
bool Image::isJpg(const void *data, int dataLen)
|
||||||
{
|
{
|
||||||
if (dataLen <= 4)
|
if (dataLen <= 4)
|
||||||
|
@ -576,6 +618,9 @@ Image::Format Image::detectFormat(const void* data, int dataLen)
|
||||||
}else if (isS3TC(data, dataLen))
|
}else if (isS3TC(data, dataLen))
|
||||||
{
|
{
|
||||||
return Format::S3TC;
|
return Format::S3TC;
|
||||||
|
}else if (isATITC(data, dataLen))
|
||||||
|
{
|
||||||
|
return Format::ATITC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1513,6 +1558,139 @@ bool Image::initWithS3TCData(const void *data, int dataLen)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
#define GL_ATC_RGB_AMD 0x8C92
|
||||||
|
#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
|
||||||
|
#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
|
||||||
|
|
||||||
|
bool Image::initWithATITCData(const void *data, int dataLen)
|
||||||
|
{
|
||||||
|
/* load the .ktx file */
|
||||||
|
ATITCTexHeader *header = (ATITCTexHeader *)data;
|
||||||
|
_width = header->pixelWidth;
|
||||||
|
_height = header->pixelHeight;
|
||||||
|
_numberOfMipmaps = header->numberOfMipmapLevels;
|
||||||
|
|
||||||
|
int blockSize = 0;
|
||||||
|
switch (header->glInternalFormat)
|
||||||
|
{
|
||||||
|
case GL_ATC_RGB_AMD:
|
||||||
|
blockSize = 8;
|
||||||
|
break;
|
||||||
|
case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
|
||||||
|
blockSize = 16;
|
||||||
|
break;
|
||||||
|
case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
|
||||||
|
blockSize = 16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pixelData point to the compressed data address */
|
||||||
|
unsigned char *pixelData = (unsigned char *)data + sizeof(ATITCTexHeader) + header->bytesOfKeyValueData + 4;
|
||||||
|
|
||||||
|
/* caculate the dataLen */
|
||||||
|
int width = _width;
|
||||||
|
int height = _height;
|
||||||
|
|
||||||
|
if (Configuration::getInstance()->supportsATITC()) //compressed data length
|
||||||
|
{
|
||||||
|
_dataLen = dataLen - sizeof(ATITCTexHeader) - header->bytesOfKeyValueData - 4;
|
||||||
|
_data = new unsigned char [_dataLen];
|
||||||
|
memcpy((void *)_data,(void *)pixelData , _dataLen);
|
||||||
|
}
|
||||||
|
else //decompressed data length
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < _numberOfMipmaps && (width || height); ++i)
|
||||||
|
{
|
||||||
|
if (width == 0) width = 1;
|
||||||
|
if (height == 0) height = 1;
|
||||||
|
|
||||||
|
_dataLen += (height * width *4);
|
||||||
|
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
|
}
|
||||||
|
_data = new unsigned char [_dataLen];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* load the mipmaps */
|
||||||
|
int encodeOffset = 0;
|
||||||
|
int decodeOffset = 0;
|
||||||
|
width = _width; height = _height;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < _numberOfMipmaps && (width || height); ++i)
|
||||||
|
{
|
||||||
|
if (width == 0) width = 1;
|
||||||
|
if (height == 0) height = 1;
|
||||||
|
|
||||||
|
int size = ((width+3)/4)*((height+3)/4)*blockSize;
|
||||||
|
|
||||||
|
if (Configuration::getInstance()->supportsATITC())
|
||||||
|
{
|
||||||
|
/* decode texture throught hardware */
|
||||||
|
|
||||||
|
CCLOG("this is atitc H decode");
|
||||||
|
|
||||||
|
switch (header->glInternalFormat)
|
||||||
|
{
|
||||||
|
case GL_ATC_RGB_AMD:
|
||||||
|
_renderFormat = Texture2D::PixelFormat::ATC_RGB;
|
||||||
|
break;
|
||||||
|
case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
|
||||||
|
_renderFormat = Texture2D::PixelFormat::ATC_EXPLICIT_ALPHA;
|
||||||
|
break;
|
||||||
|
case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
|
||||||
|
_renderFormat = Texture2D::PixelFormat::ATC_INTERPOLATED_ALPHA;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_mipmaps[i].address = (unsigned char *)_data + encodeOffset;
|
||||||
|
_mipmaps[i].len = size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* if it is not gles or device do not support ATITC, decode texture by software */
|
||||||
|
|
||||||
|
int bytePerPixel = 4;
|
||||||
|
unsigned int stride = width * bytePerPixel;
|
||||||
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
|
std::vector<unsigned char> decodeImageData(stride * height);
|
||||||
|
switch (header->glInternalFormat)
|
||||||
|
{
|
||||||
|
case GL_ATC_RGB_AMD:
|
||||||
|
atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_RGB);
|
||||||
|
break;
|
||||||
|
case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD:
|
||||||
|
atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_EXPLICIT_ALPHA);
|
||||||
|
break;
|
||||||
|
case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
|
||||||
|
atitc_decode(pixelData + encodeOffset, &decodeImageData[0], width, height, ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_mipmaps[i].address = (unsigned char *)_data + decodeOffset;
|
||||||
|
_mipmaps[i].len = (stride * height);
|
||||||
|
memcpy((void *)_mipmaps[i].address, (void *)&decodeImageData[0], _mipmaps[i].len);
|
||||||
|
decodeOffset += stride * height;
|
||||||
|
}
|
||||||
|
|
||||||
|
encodeOffset += (size + 4);
|
||||||
|
width >>= 1;
|
||||||
|
height >>= 1;
|
||||||
|
}
|
||||||
|
/* end load the mipmaps */
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Image::initWithPVRData(const void *data, int dataLen)
|
bool Image::initWithPVRData(const void *data, int dataLen)
|
||||||
{
|
{
|
||||||
return initWithPVRv2Data(data, dataLen) || initWithPVRv3Data(data, dataLen);
|
return initWithPVRv2Data(data, dataLen) || initWithPVRv3Data(data, dataLen);
|
||||||
|
|
|
@ -0,0 +1,195 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "atitc.h"
|
||||||
|
|
||||||
|
//Decode ATITC encode block to 4x4 RGB32 pixels
|
||||||
|
static void atitc_decode_block(uint8_t **blockData,
|
||||||
|
uint32_t *decodeBlockData,
|
||||||
|
unsigned int stride,
|
||||||
|
bool oneBitAlphaFlag,
|
||||||
|
uint64_t alpha,
|
||||||
|
ATITCDecodeFlag decodeFlag)
|
||||||
|
{
|
||||||
|
unsigned int colorValue0 = 0 , colorValue1 = 0, initAlpha = (!oneBitAlphaFlag * 255u) << 24;
|
||||||
|
unsigned int rb0 = 0, rb1 = 0, rb2 = 0, rb3 = 0, g0 = 0, g1 = 0, g2 = 0, g3 = 0;
|
||||||
|
bool msb = 0;
|
||||||
|
|
||||||
|
uint32_t colors[4], pixelsIndex = 0;
|
||||||
|
|
||||||
|
/* load the two color values*/
|
||||||
|
memcpy((void *)&colorValue0, *blockData, 2);
|
||||||
|
(*blockData) += 2;
|
||||||
|
|
||||||
|
memcpy((void *)&colorValue1, *blockData, 2);
|
||||||
|
(*blockData) += 2;
|
||||||
|
|
||||||
|
//extract the msb flag
|
||||||
|
msb = (colorValue0 & 0x8000);
|
||||||
|
|
||||||
|
/* the channel is r5g6b5 , 16 bits */
|
||||||
|
rb0 = (colorValue0 << 3 | colorValue0 << 9) & 0xf800f8;
|
||||||
|
rb1 = (colorValue1 << 3 | colorValue1 << 8) & 0xf800f8;
|
||||||
|
g0 = (colorValue0 << 6) & 0x00fc00;
|
||||||
|
g1 = (colorValue1 << 5) & 0x00fc00;
|
||||||
|
g0 += (g0 >> 6) & 0x000300;
|
||||||
|
g1 += (g1 >> 6) & 0x000300;
|
||||||
|
|
||||||
|
/* interpolate the other two color values */
|
||||||
|
if (!msb)
|
||||||
|
{
|
||||||
|
colors[0] = rb0 + g0 + initAlpha;
|
||||||
|
colors[3] = rb1 + g1 + initAlpha;
|
||||||
|
|
||||||
|
rb2 = (((2*rb0 + rb1) * 21) >> 6) & 0xff00ff;
|
||||||
|
rb3 = (((2*rb1 + rb0) * 21) >> 6) & 0xff00ff;
|
||||||
|
g2 = (((2*g0 + g1 ) * 21) >> 6) & 0x00ff00;
|
||||||
|
g3 = (((2*g1 + g0 ) * 21) >> 6) & 0x00ff00;
|
||||||
|
|
||||||
|
colors[2] = rb3 + g3 + initAlpha;
|
||||||
|
colors[1] = rb2 + g2 + initAlpha;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colors[2] = rb0 + g0 + initAlpha;
|
||||||
|
colors[3] = rb1 + g1 + initAlpha;
|
||||||
|
|
||||||
|
rb2 = (rb0 - (rb1 >> 2)) & 0xff00ff;
|
||||||
|
g2 = (g0 - (g1 >> 2)) & 0x00ff00;
|
||||||
|
colors[0] = 0 ;
|
||||||
|
|
||||||
|
colors[1] = rb2 + g2 + initAlpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*read the pixelsIndex , 2bits per pixel, 4 bytes */
|
||||||
|
memcpy((void*)&pixelsIndex, *blockData, 4);
|
||||||
|
(*blockData) += 4;
|
||||||
|
|
||||||
|
if (ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA == decodeFlag)
|
||||||
|
{
|
||||||
|
// atitc_interpolated_alpha use interpolate alpha
|
||||||
|
// 8-Alpha block: derive the other six alphas.
|
||||||
|
// Bit code 000 = alpha0, 001 = alpha1, other are interpolated.
|
||||||
|
|
||||||
|
unsigned int alphaArray[8];
|
||||||
|
|
||||||
|
alphaArray[0] = (alpha ) & 0xff ;
|
||||||
|
alphaArray[1] = (alpha >> 8) & 0xff ;
|
||||||
|
|
||||||
|
if (alphaArray[0] >= alphaArray[1])
|
||||||
|
{
|
||||||
|
alphaArray[2] = (alphaArray[0]*6 + alphaArray[1]*1) / 7;
|
||||||
|
alphaArray[3] = (alphaArray[0]*5 + alphaArray[1]*2) / 7;
|
||||||
|
alphaArray[4] = (alphaArray[0]*4 + alphaArray[1]*3) / 7;
|
||||||
|
alphaArray[5] = (alphaArray[0]*3 + alphaArray[1]*4) / 7;
|
||||||
|
alphaArray[6] = (alphaArray[0]*2 + alphaArray[1]*5) / 7;
|
||||||
|
alphaArray[7] = (alphaArray[0]*1 + alphaArray[1]*6) / 7;
|
||||||
|
}
|
||||||
|
else if (alphaArray[0] < alphaArray[1])
|
||||||
|
{
|
||||||
|
alphaArray[2] = (alphaArray[0]*4 + alphaArray[1]*1) / 5;
|
||||||
|
alphaArray[3] = (alphaArray[0]*3 + alphaArray[1]*2) / 5;
|
||||||
|
alphaArray[4] = (alphaArray[0]*2 + alphaArray[1]*3) / 5;
|
||||||
|
alphaArray[5] = (alphaArray[0]*1 + alphaArray[1]*4) / 5;
|
||||||
|
alphaArray[6] = 0;
|
||||||
|
alphaArray[7] = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
// read the flowing 48bit indices (16*3)
|
||||||
|
alpha >>= 16;
|
||||||
|
|
||||||
|
for (int y = 0; y < 4; ++y)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 4; ++x)
|
||||||
|
{
|
||||||
|
decodeBlockData[x] = (alphaArray[alpha & 5] << 24) + colors[pixelsIndex & 3];
|
||||||
|
pixelsIndex >>= 2;
|
||||||
|
alpha >>= 3;
|
||||||
|
}
|
||||||
|
decodeBlockData += stride;
|
||||||
|
}
|
||||||
|
} //if (atc_interpolated_alpha == comFlag)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* atc_rgb atc_explicit_alpha use explicit alpha */
|
||||||
|
|
||||||
|
for (int y = 0; y < 4; ++y)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 4; ++x)
|
||||||
|
{
|
||||||
|
initAlpha = (alpha & 0x0f) << 28;
|
||||||
|
initAlpha += initAlpha >> 4;
|
||||||
|
decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3];
|
||||||
|
pixelsIndex >>= 2;
|
||||||
|
alpha >>= 4;
|
||||||
|
}
|
||||||
|
decodeBlockData += stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Decode ATITC encode data to RGB32
|
||||||
|
void atitc_decode(uint8_t *encodeData, //in_data
|
||||||
|
uint8_t *decodeData, //out_data
|
||||||
|
const unsigned int pixelsWidth,
|
||||||
|
const unsigned int pixelsHeight,
|
||||||
|
ATITCDecodeFlag decodeFlag)
|
||||||
|
{
|
||||||
|
uint32_t *decodeBlockData = (uint32_t *)decodeData;
|
||||||
|
|
||||||
|
for (int block_y = 0; block_y < pixelsHeight / 4; ++block_y, decodeBlockData += 3 * pixelsWidth) //stride = 3*width
|
||||||
|
{
|
||||||
|
for (int block_x = 0; block_x < pixelsWidth / 4; ++block_x, decodeBlockData += 4) //skip 4 pixels
|
||||||
|
{
|
||||||
|
uint64_t blockAlpha = 0;
|
||||||
|
|
||||||
|
switch (decodeFlag)
|
||||||
|
{
|
||||||
|
case ATITCDecodeFlag::ATC_RGB:
|
||||||
|
{
|
||||||
|
atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 0, 0LL, ATITCDecodeFlag::ATC_RGB);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATITCDecodeFlag::ATC_EXPLICIT_ALPHA:
|
||||||
|
{
|
||||||
|
memcpy((void *)&blockAlpha, encodeData, 8);
|
||||||
|
encodeData += 8;
|
||||||
|
atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, ATITCDecodeFlag::ATC_EXPLICIT_ALPHA);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA:
|
||||||
|
{
|
||||||
|
memcpy((void *)&blockAlpha, encodeData, 8);
|
||||||
|
encodeData += 8;
|
||||||
|
atitc_decode_block(&encodeData, decodeBlockData, pixelsWidth, 1, blockAlpha, ATITCDecodeFlag::ATC_INTERPOLATED_ALPHA);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}//switch
|
||||||
|
}//for block_x
|
||||||
|
}//for block_y
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef COCOS2DX_PLATFORM_THIRDPARTY_ATITC_
|
||||||
|
#define COCOS2DX_PLATFORM_THIRDPARTY_ATITC_
|
||||||
|
|
||||||
|
#include "CCStdC.h"
|
||||||
|
|
||||||
|
enum class ATITCDecodeFlag
|
||||||
|
{
|
||||||
|
ATC_RGB = 1,
|
||||||
|
ATC_EXPLICIT_ALPHA = 3,
|
||||||
|
ATC_INTERPOLATED_ALPHA = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
//Decode ATITC encode data to RGB32
|
||||||
|
void atitc_decode(uint8_t *encode_data,
|
||||||
|
uint8_t *decode_data,
|
||||||
|
const unsigned int pixelsWidth,
|
||||||
|
const unsigned int pixelsHeight,
|
||||||
|
ATITCDecodeFlag decodeFlag
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* defined(COCOS2DX_PLATFORM_THIRDPARTY_ATITC_) */
|
||||||
|
|
|
@ -4,6 +4,7 @@ INCLUDES += \
|
||||||
-I../platform/third_party/linux/libfreetype2 \
|
-I../platform/third_party/linux/libfreetype2 \
|
||||||
-I../platform/third_party/common/etc \
|
-I../platform/third_party/common/etc \
|
||||||
-I../platform/third_party/common/s3tc \
|
-I../platform/third_party/common/s3tc \
|
||||||
|
-I../platform/third_party/common/atitc \
|
||||||
-I../../extensions \
|
-I../../extensions \
|
||||||
-I../../extensions/CCBReader \
|
-I../../extensions/CCBReader \
|
||||||
-I../../extensions/GUI/CCControlExtension \
|
-I../../extensions/GUI/CCControlExtension \
|
||||||
|
@ -90,6 +91,7 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../platform/linux/CCDevice.cpp \
|
../platform/linux/CCDevice.cpp \
|
||||||
../platform/third_party/common/etc/etc1.cpp \
|
../platform/third_party/common/etc/etc1.cpp \
|
||||||
../platform/third_party/common/s3tc/s3tc.cpp\
|
../platform/third_party/common/s3tc/s3tc.cpp\
|
||||||
|
../platform/third_party/common/atitc/atitc.cpp\
|
||||||
../script_support/CCScriptSupport.cpp \
|
../script_support/CCScriptSupport.cpp \
|
||||||
../sprite_nodes/CCAnimation.cpp \
|
../sprite_nodes/CCAnimation.cpp \
|
||||||
../sprite_nodes/CCAnimationCache.cpp \
|
../sprite_nodes/CCAnimationCache.cpp \
|
||||||
|
|
|
@ -210,6 +210,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<ClCompile Include="..\platform\CCFileUtils.cpp" />
|
<ClCompile Include="..\platform\CCFileUtils.cpp" />
|
||||||
<ClCompile Include="..\platform\CCSAXParser.cpp" />
|
<ClCompile Include="..\platform\CCSAXParser.cpp" />
|
||||||
<ClCompile Include="..\platform\CCThread.cpp" />
|
<ClCompile Include="..\platform\CCThread.cpp" />
|
||||||
|
<ClCompile Include="..\platform\third_party\common\atitc\atitc.cpp" />
|
||||||
<ClCompile Include="..\platform\third_party\common\etc\etc1.cpp" />
|
<ClCompile Include="..\platform\third_party\common\etc\etc1.cpp" />
|
||||||
<ClCompile Include="..\platform\third_party\common\s3tc\s3tc.cpp" />
|
<ClCompile Include="..\platform\third_party\common\s3tc\s3tc.cpp" />
|
||||||
<ClCompile Include="..\platform\win32\CCAccelerometer.cpp" />
|
<ClCompile Include="..\platform\win32\CCAccelerometer.cpp" />
|
||||||
|
@ -372,6 +373,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<ClInclude Include="..\platform\CCSAXParser.h" />
|
<ClInclude Include="..\platform\CCSAXParser.h" />
|
||||||
<ClInclude Include="..\platform\CCThread.h" />
|
<ClInclude Include="..\platform\CCThread.h" />
|
||||||
<ClInclude Include="..\platform\platform.h" />
|
<ClInclude Include="..\platform\platform.h" />
|
||||||
|
<ClInclude Include="..\platform\third_party\common\atitc\atitc.h" />
|
||||||
<ClInclude Include="..\platform\third_party\common\etc\etc1.h" />
|
<ClInclude Include="..\platform\third_party\common\etc\etc1.h" />
|
||||||
<ClInclude Include="..\platform\third_party\common\s3tc\s3tc.h" />
|
<ClInclude Include="..\platform\third_party\common\s3tc\s3tc.h" />
|
||||||
<ClInclude Include="..\platform\win32\CCAccelerometer.h" />
|
<ClInclude Include="..\platform\win32\CCAccelerometer.h" />
|
||||||
|
|
|
@ -518,6 +518,9 @@
|
||||||
<ClCompile Include="..\platform\third_party\common\s3tc\s3tc.cpp">
|
<ClCompile Include="..\platform\third_party\common\s3tc\s3tc.cpp">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\platform\third_party\common\atitc\atitc.cpp">
|
||||||
|
<Filter>platform</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\base_nodes\CCAtlasNode.h">
|
<ClInclude Include="..\base_nodes\CCAtlasNode.h">
|
||||||
|
@ -1045,5 +1048,8 @@
|
||||||
<ClInclude Include="..\platform\third_party\common\s3tc\s3tc.h">
|
<ClInclude Include="..\platform\third_party\common\s3tc\s3tc.h">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\platform\third_party\common\atitc\atitc.h">
|
||||||
|
<Filter>platform</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -86,6 +86,20 @@ namespace {
|
||||||
PixelFormatInfoMapValue(Texture2D::PixelFormat::S3TC_DXT5, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)),
|
PixelFormatInfoMapValue(Texture2D::PixelFormat::S3TC_DXT5, Texture2D::PixelFormatInfo(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GL_ATC_RGB_AMD
|
||||||
|
PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_RGB, Texture2D::PixelFormatInfo(GL_ATC_RGB_AMD,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 4, true, false)),
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
|
||||||
|
PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_EXPLICIT_ALPHA, Texture2D::PixelFormatInfo(GL_ATC_RGBA_EXPLICIT_ALPHA_AMD,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)),
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
|
||||||
|
PixelFormatInfoMapValue(Texture2D::PixelFormat::ATC_INTERPOLATED_ALPHA, Texture2D::PixelFormatInfo(GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD,
|
||||||
|
0xFFFFFFFF, 0xFFFFFFFF, 8, true, false)),
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +566,8 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
||||||
|
|
||||||
if (info.compressed && !Configuration::getInstance()->supportsPVRTC()
|
if (info.compressed && !Configuration::getInstance()->supportsPVRTC()
|
||||||
&& !Configuration::getInstance()->supportsETC()
|
&& !Configuration::getInstance()->supportsETC()
|
||||||
&& !Configuration::getInstance()->supportsS3TC())
|
&& !Configuration::getInstance()->supportsS3TC()
|
||||||
|
&& !Configuration::getInstance()->supportsATITC())
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: WARNING: PVRTC/ETC images are not supported");
|
CCLOG("cocos2d: WARNING: PVRTC/ETC images are not supported");
|
||||||
return false;
|
return false;
|
||||||
|
@ -606,6 +621,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
||||||
// Specify OpenGL texture image
|
// Specify OpenGL texture image
|
||||||
int width = pixelsWide;
|
int width = pixelsWide;
|
||||||
int height = pixelsHigh;
|
int height = pixelsHigh;
|
||||||
|
|
||||||
for (int i = 0; i < mipmapsNum; ++i)
|
for (int i = 0; i < mipmapsNum; ++i)
|
||||||
{
|
{
|
||||||
unsigned char *data = mipmaps[i].address;
|
unsigned char *data = mipmaps[i].address;
|
||||||
|
@ -634,7 +650,6 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
||||||
|
|
||||||
width = MAX(width >> 1, 1);
|
width = MAX(width >> 1, 1);
|
||||||
height = MAX(height >> 1, 1);
|
height = MAX(height >> 1, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_contentSize = Size((float)pixelsWide, (float)pixelsHigh);
|
_contentSize = Size((float)pixelsWide, (float)pixelsHigh);
|
||||||
|
|
|
@ -105,7 +105,12 @@ public:
|
||||||
S3TC_DXT3,
|
S3TC_DXT3,
|
||||||
//! S3TC-compressed texture: S3TC_Dxt5
|
//! S3TC-compressed texture: S3TC_Dxt5
|
||||||
S3TC_DXT5,
|
S3TC_DXT5,
|
||||||
|
//! ATITC-compressed texture: ATC_RGB
|
||||||
|
ATC_RGB,
|
||||||
|
//! ATITC-compressed texture: ATC_EXPLICIT_ALPHA
|
||||||
|
ATC_EXPLICIT_ALPHA,
|
||||||
|
//! ATITC-compresed texture: ATC_INTERPOLATED_ALPHA
|
||||||
|
ATC_INTERPOLATED_ALPHA,
|
||||||
//! Default texture format: AUTO
|
//! Default texture format: AUTO
|
||||||
DEFAULT = AUTO,
|
DEFAULT = AUTO,
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,10 @@ static std::function<Layer*()> createFunctions[] =
|
||||||
CL(TextureS3TCDxt3),
|
CL(TextureS3TCDxt3),
|
||||||
CL(TextureS3TCDxt5),
|
CL(TextureS3TCDxt5),
|
||||||
|
|
||||||
|
CL(TextureATITCRGB),
|
||||||
|
CL(TextureATITCExplicit),
|
||||||
|
CL(TextureATITCInterpolated),
|
||||||
|
|
||||||
CL(TextureConvertRGB888),
|
CL(TextureConvertRGB888),
|
||||||
CL(TextureConvertRGBA8888),
|
CL(TextureConvertRGBA8888),
|
||||||
CL(TextureConvertI8),
|
CL(TextureConvertI8),
|
||||||
|
@ -2026,6 +2030,7 @@ std::string TextureS3TCDxt1::subtitle()
|
||||||
{
|
{
|
||||||
return "S3TC dxt1 decode,one bit for Alpha";
|
return "S3TC dxt1 decode,one bit for Alpha";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Implement of S3TC Dxt3
|
//Implement of S3TC Dxt3
|
||||||
TextureS3TCDxt3::TextureS3TCDxt3()
|
TextureS3TCDxt3::TextureS3TCDxt3()
|
||||||
{
|
{
|
||||||
|
@ -2044,7 +2049,8 @@ std::string TextureS3TCDxt3::subtitle()
|
||||||
{
|
{
|
||||||
return "S3TC dxt3 decode";
|
return "S3TC dxt3 decode";
|
||||||
}
|
}
|
||||||
//Implement fo S3TC Dxt5
|
|
||||||
|
//Implement of S3TC Dxt5
|
||||||
TextureS3TCDxt5::TextureS3TCDxt5()
|
TextureS3TCDxt5::TextureS3TCDxt5()
|
||||||
{
|
{
|
||||||
Sprite *sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds");
|
Sprite *sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds");
|
||||||
|
@ -2061,7 +2067,61 @@ std::string TextureS3TCDxt5::title()
|
||||||
std::string TextureS3TCDxt5::subtitle()
|
std::string TextureS3TCDxt5::subtitle()
|
||||||
{
|
{
|
||||||
return "S3TC dxt5 decode";
|
return "S3TC dxt5 decode";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Implement of ATITC
|
||||||
|
TextureATITCRGB::TextureATITCRGB()
|
||||||
|
{
|
||||||
|
Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGB_mipmaps.ktx");
|
||||||
|
|
||||||
|
Size size = Director::getInstance()->getWinSize();
|
||||||
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
||||||
|
|
||||||
|
addChild(sprite);
|
||||||
|
}
|
||||||
|
std::string TextureATITCRGB::title()
|
||||||
|
{
|
||||||
|
return "ATITC texture (*.ktx file) test#1";
|
||||||
|
}
|
||||||
|
std::string TextureATITCRGB::subtitle()
|
||||||
|
{
|
||||||
|
return "ATITC RGB (no Alpha channel) compressed texture test";
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureATITCExplicit::TextureATITCExplicit()
|
||||||
|
{
|
||||||
|
Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Explicit_mipmaps.ktx");
|
||||||
|
|
||||||
|
Size size = Director::getInstance()->getWinSize();
|
||||||
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
||||||
|
|
||||||
|
addChild(sprite);
|
||||||
|
}
|
||||||
|
std::string TextureATITCExplicit::title()
|
||||||
|
{
|
||||||
|
return "ATITC texture (*.ktx file) test#2";
|
||||||
|
}
|
||||||
|
std::string TextureATITCExplicit::subtitle()
|
||||||
|
{
|
||||||
|
return "ATITC RGBA explicit Alpha compressed texture test";
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureATITCInterpolated::TextureATITCInterpolated()
|
||||||
|
{
|
||||||
|
Sprite *sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Interpolated_mipmaps.ktx");
|
||||||
|
|
||||||
|
Size size = Director::getInstance()->getWinSize();
|
||||||
|
sprite->setPosition(Point(size.width / 2, size.height /2));
|
||||||
|
|
||||||
|
addChild(sprite);
|
||||||
|
}
|
||||||
|
std::string TextureATITCInterpolated::title()
|
||||||
|
{
|
||||||
|
return "ATITC texture (*.ktx file) test#3";
|
||||||
|
}
|
||||||
|
std::string TextureATITCInterpolated::subtitle()
|
||||||
|
{
|
||||||
|
return "ATITC RGBA Interpolated Alpha comrpessed texture test";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, Texture2D::PixelFormat format)
|
static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, Texture2D::PixelFormat format)
|
||||||
|
@ -2071,7 +2131,7 @@ static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path
|
||||||
sprite->setPosition(Point(x, y));
|
sprite->setPosition(Point(x, y));
|
||||||
demo.addChild(sprite, 0);
|
demo.addChild(sprite, 0);
|
||||||
|
|
||||||
// remove texture from texture manager
|
//remove texture from texture manager
|
||||||
TextureCache::getInstance()->removeTexture(sprite->getTexture());
|
TextureCache::getInstance()->removeTexture(sprite->getTexture());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -462,6 +462,7 @@ public:
|
||||||
virtual std::string title();
|
virtual std::string title();
|
||||||
virtual std::string subtitle();
|
virtual std::string subtitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// S3TC Dxt3 texture format test
|
// S3TC Dxt3 texture format test
|
||||||
class TextureS3TCDxt3 : public TextureDemo
|
class TextureS3TCDxt3 : public TextureDemo
|
||||||
{
|
{
|
||||||
|
@ -471,6 +472,7 @@ public:
|
||||||
virtual std::string title();
|
virtual std::string title();
|
||||||
virtual std::string subtitle();
|
virtual std::string subtitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// S3TC Dxt5 texture format test
|
// S3TC Dxt5 texture format test
|
||||||
class TextureS3TCDxt5 : public TextureDemo
|
class TextureS3TCDxt5 : public TextureDemo
|
||||||
{
|
{
|
||||||
|
@ -481,6 +483,37 @@ public:
|
||||||
virtual std::string subtitle();
|
virtual std::string subtitle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ATITC RGB texture format test
|
||||||
|
class TextureATITCRGB : public TextureDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextureATITCRGB();
|
||||||
|
|
||||||
|
virtual std::string title();
|
||||||
|
virtual std::string subtitle();
|
||||||
|
};
|
||||||
|
|
||||||
|
//ATITC RGBA Explicit texture format test
|
||||||
|
class TextureATITCExplicit : public TextureDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextureATITCExplicit();
|
||||||
|
|
||||||
|
virtual std::string title();
|
||||||
|
virtual std::string subtitle();
|
||||||
|
};
|
||||||
|
|
||||||
|
//ATITC RGBA Interpolated texture format test
|
||||||
|
class TextureATITCInterpolated : public TextureDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TextureATITCInterpolated();
|
||||||
|
|
||||||
|
virtual std::string title();
|
||||||
|
virtual std::string subtitle();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// RGB888 texture convert test
|
// RGB888 texture convert test
|
||||||
class TextureConvertRGB888 : public TextureDemo
|
class TextureConvertRGB888 : public TextureDemo
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue