mirror of https://github.com/axmolengine/axmol.git
commit
257241c487
|
@ -201,12 +201,9 @@ public:
|
||||||
/** returns the bits-per-pixel of the in-memory OpenGL texture
|
/** returns the bits-per-pixel of the in-memory OpenGL texture
|
||||||
@since v1.0
|
@since v1.0
|
||||||
*/
|
*/
|
||||||
unsigned int bitsPerPixelForFormat();
|
unsigned int bitsPerPixelForFormat();
|
||||||
|
|
||||||
|
|
||||||
void setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
|
|
||||||
|
|
||||||
/** sets the default pixel format for UIImages that contains alpha channel.
|
/** sets the default pixel format for UIImagescontains alpha channel.
|
||||||
If the UIImage contains alpha channel, then the options are:
|
If the UIImage contains alpha channel, then the options are:
|
||||||
- generate 32-bit textures: kCCTexture2DPixelFormat_RGBA8888 (default one)
|
- generate 32-bit textures: kCCTexture2DPixelFormat_RGBA8888 (default one)
|
||||||
- generate 24-bit textures: kCCTexture2DPixelFormat_RGB888
|
- generate 24-bit textures: kCCTexture2DPixelFormat_RGB888
|
||||||
|
@ -228,6 +225,16 @@ public:
|
||||||
*/
|
*/
|
||||||
static CCTexture2DPixelFormat defaultAlphaPixelFormat();
|
static CCTexture2DPixelFormat defaultAlphaPixelFormat();
|
||||||
|
|
||||||
|
/** treats (or not) PVR files as if they have alpha premultiplied.
|
||||||
|
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
|
||||||
|
possible load them as if they have (or not) the alpha channel premultiplied.
|
||||||
|
|
||||||
|
By default it is disabled.
|
||||||
|
|
||||||
|
@since v0.99.5
|
||||||
|
*/
|
||||||
|
static void PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initPremultipliedATextureWithImage(CCImage * image, unsigned int pixelsWide, unsigned int pixelsHigh);
|
bool initPremultipliedATextureWithImage(CCImage * image, unsigned int pixelsWide, unsigned int pixelsHigh);
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,9 @@ namespace cocos2d {
|
||||||
// Default is: RGBA8888 (32-bit textures)
|
// Default is: RGBA8888 (32-bit textures)
|
||||||
static CCTexture2DPixelFormat g_defaultAlphaPixelFormat = kCCTexture2DPixelFormat_Default;
|
static CCTexture2DPixelFormat g_defaultAlphaPixelFormat = kCCTexture2DPixelFormat_Default;
|
||||||
|
|
||||||
|
// By default PVR images are treated as if they don't have the alpha channel premultiplied
|
||||||
|
static bool PVRHaveAlphaPremultiplied_ = false;
|
||||||
|
|
||||||
CCTexture2D::CCTexture2D()
|
CCTexture2D::CCTexture2D()
|
||||||
: m_uPixelsWide(0)
|
: m_uPixelsWide(0)
|
||||||
, m_uPixelsHigh(0)
|
, m_uPixelsHigh(0)
|
||||||
|
@ -538,7 +541,7 @@ bool CCTexture2D::initWithPVRTCData(const void *data, int level, int bpp, bool h
|
||||||
m_uPixelsHigh = length;
|
m_uPixelsHigh = length;
|
||||||
m_fMaxS = 1.0f;
|
m_fMaxS = 1.0f;
|
||||||
m_fMaxT = 1.0f;
|
m_fMaxT = 1.0f;
|
||||||
m_bHasPremultipliedAlpha = m_bPVRHaveAlphaPremultiplied;
|
m_bHasPremultipliedAlpha = PVRHaveAlphaPremultiplied_;
|
||||||
m_ePixelFormat = pixelFormat;
|
m_ePixelFormat = pixelFormat;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -562,8 +565,8 @@ bool CCTexture2D::initWithPVRFile(const char* file)
|
||||||
m_fMaxT = 1.0f;
|
m_fMaxT = 1.0f;
|
||||||
m_uPixelsWide = pvr->getWidth();
|
m_uPixelsWide = pvr->getWidth();
|
||||||
m_uPixelsHigh = pvr->getHeight();
|
m_uPixelsHigh = pvr->getHeight();
|
||||||
m_tContentSize = CCSizeMake(m_uPixelsWide, m_uPixelsHigh);
|
m_tContentSize = CCSizeMake((float)m_uPixelsWide, (float)m_uPixelsHigh);
|
||||||
m_bHasPremultipliedAlpha = m_bPVRHaveAlphaPremultiplied;
|
m_bHasPremultipliedAlpha = PVRHaveAlphaPremultiplied_;
|
||||||
m_ePixelFormat = pvr->getFormat();
|
m_ePixelFormat = pvr->getFormat();
|
||||||
|
|
||||||
this->setAntiAliasTexParameters();
|
this->setAntiAliasTexParameters();
|
||||||
|
@ -577,9 +580,9 @@ bool CCTexture2D::initWithPVRFile(const char* file)
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCTexture2D::setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
void CCTexture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
||||||
{
|
{
|
||||||
m_bPVRHaveAlphaPremultiplied = haveAlphaPremultiplied;
|
PVRHaveAlphaPremultiplied_ = haveAlphaPremultiplied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue