mirror of https://github.com/axmolengine/axmol.git
issue #1686:synchronized Texture2DTest
This commit is contained in:
parent
47830a5ef4
commit
f5e334d9e3
|
@ -14,6 +14,7 @@ static CCLayer* create##className() \
|
|||
{ return new className(); }
|
||||
|
||||
TEXTURE2D_CREATE_FUNC(TextureMemoryAlloc);
|
||||
|
||||
TEXTURE2D_CREATE_FUNC(TextureAlias);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVRMipMap);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVRMipMap2);
|
||||
|
@ -21,6 +22,7 @@ TEXTURE2D_CREATE_FUNC(TexturePVRNonSquare);
|
|||
TEXTURE2D_CREATE_FUNC(TexturePVRNPOT4444);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVRNPOT8888);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVR);
|
||||
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVR2BPP);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVR2BPPv3);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVR4BPP);
|
||||
|
@ -46,6 +48,9 @@ TEXTURE2D_CREATE_FUNC(TexturePVRI8);
|
|||
TEXTURE2D_CREATE_FUNC(TexturePVRI8v3);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVRAI88);
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVRAI88v3);
|
||||
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVRv3Premult);
|
||||
|
||||
TEXTURE2D_CREATE_FUNC(TexturePVRBadEncoding);
|
||||
TESTLAYER_CREATE_FUNC(TexturePNG);
|
||||
TESTLAYER_CREATE_FUNC(TextureJPEG);
|
||||
|
@ -97,6 +102,8 @@ static NEWTEXTURE2DTESTFUNC createFunctions[] =
|
|||
createTexturePVRAI88,
|
||||
createTexturePVRAI88v3,
|
||||
|
||||
createTexturePVRv3Premult,
|
||||
|
||||
createTexturePVRBadEncoding,
|
||||
createTexturePNG,
|
||||
createTextureJPEG,
|
||||
|
@ -1988,4 +1995,54 @@ string TextureMemoryAlloc::title()
|
|||
string TextureMemoryAlloc::subtitle()
|
||||
{
|
||||
return "Testing Texture Memory allocation. Use Instruments + VM Tracker";
|
||||
}
|
||||
}
|
||||
|
||||
// TexturePVRv3Premult
|
||||
TexturePVRv3Premult::TexturePVRv3Premult()
|
||||
{
|
||||
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLayerColor *background = CCLayerColor::create(ccc4(128,128,128,255), size.width, size.height);
|
||||
addChild(background, -1);
|
||||
|
||||
|
||||
// PVR premultiplied
|
||||
CCSprite *pvr1 = CCSprite::create("Images/grossinis_sister1-testalpha_premult.pvr");
|
||||
addChild(pvr1, 0);
|
||||
pvr1->setPosition(ccp(size.width/4*1, size.height/2));
|
||||
transformSprite(pvr1);
|
||||
|
||||
// PVR non-premultiplied
|
||||
CCSprite *pvr2 = CCSprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr");
|
||||
addChild(pvr2, 0);
|
||||
pvr2->setPosition(ccp(size.width/4*2, size.height/2));
|
||||
transformSprite(pvr2);
|
||||
|
||||
// PNG
|
||||
CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888);
|
||||
CCTextureCache::sharedTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
|
||||
CCSprite *png = CCSprite::create("Images/grossinis_sister1-testalpha.png");
|
||||
addChild(png, 0);
|
||||
png->setPosition(ccp(size.width/4*3, size.height/2));
|
||||
transformSprite(png);
|
||||
}
|
||||
|
||||
std::string TexturePVRv3Premult::title()
|
||||
{
|
||||
return "PVRv3 Premult Flag";
|
||||
}
|
||||
|
||||
std::string TexturePVRv3Premult::subtitle()
|
||||
{
|
||||
return "All images should look exactly the same";
|
||||
}
|
||||
|
||||
void TexturePVRv3Premult::transformSprite(cocos2d::CCSprite *sprite)
|
||||
{
|
||||
CCFadeOut *fade = CCFadeOut::create(2);
|
||||
CCDelayTime *dl = CCDelayTime::create(2);
|
||||
CCFadeOut *fadein = (CCFadeOut*)fade->reverse();
|
||||
CCSequence *seq = CCSequence::create(fade, fadein, dl, NULL);
|
||||
CCRepeatForever *repeat = CCRepeatForever::create(seq);
|
||||
sprite->runAction(repeat);
|
||||
}
|
||||
|
|
|
@ -431,4 +431,15 @@ private:
|
|||
CCSprite *m_pBackground;
|
||||
};
|
||||
|
||||
class TexturePVRv3Premult : public TextureDemo
|
||||
{
|
||||
public:
|
||||
TexturePVRv3Premult();
|
||||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
void transformSprite(cocos2d::CCSprite *sprite);
|
||||
};
|
||||
|
||||
#endif // __TEXTURE2D_TEST_H__
|
||||
|
|
Loading…
Reference in New Issue