New issue
 Projects > cocos2d-x > Issues > Bug #1584

VolatileTexture don't support pvr format cache

Bug #1584 [New]

CCTextureCache::addPVRImage() add pvr texture as CCImage::kFmtRawData
but VolatileTexture::reloadTexture()using CCImage::initWithImageData() which don’t support pvr format.

I have change the code like this:

switch (vt->m_eCashedImageType)
    {
    case kImageFile:
        {            
            std::string lowerCase(vt->m_strFileName);
            for (unsigned int i = 0; i < lowerCase.length(); ++i)
            {
                lowerCase[i] = tolower(lowerCase[i]);
            }

            if (std::string::npos != lowerCase.find(".pvr"))
            {
                vt->texture->initWithPVRFile(vt->m_strFileName.c_str());
            } else 
            {
                CCImage image;
                CCFileData data(vt->m_strFileName.c_str(), "rb");
                unsigned long nSize  = data.getSize();
                unsigned char* pBuffer = data.getBuffer();

                if (image.initWithImageData((void*)pBuffer, nSize, vt->m_FmtImage))
                {
                    CCTexture2DPixelFormat oldPixelFormat = CCTexture2D::defaultAlphaPixelFormat();
                    CCTexture2D::setDefaultAlphaPixelFormat(vt->m_PixelFormat);
                    vt->texture->initWithImage(ℑ);
                    CCTexture2D::setDefaultAlphaPixelFormat(oldPixelFormat);
                }
            }
        }
        break;
    case kImageData:
        .
        .
        .

Atom PDF

Status:New
Start date:2012-11-29
Priority:Normal
Due date:
Assignee:-
% Done:

0%

Category:android
Target version:-

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.