2012-04-19 14:35:52 +08:00
|
|
|
// local import
|
|
|
|
#include "Texture2dTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kTagLabel = 1,
|
|
|
|
kTagSprite1 = 2,
|
|
|
|
kTagSprite2 = 3,
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
static std::function<Layer*()> createFunctions[] =
|
2013-06-07 08:12:28 +08:00
|
|
|
{
|
|
|
|
CL(TextureMemoryAlloc),
|
|
|
|
CL(TextureAlias),
|
|
|
|
CL(TexturePVRMipMap),
|
|
|
|
CL(TexturePVRMipMap2),
|
|
|
|
CL(TexturePVRNonSquare),
|
|
|
|
CL(TexturePVRNPOT4444),
|
|
|
|
CL(TexturePVRNPOT8888),
|
2013-06-20 14:04:44 +08:00
|
|
|
CL(TexturePVRTest),
|
2013-06-07 08:12:28 +08:00
|
|
|
CL(TexturePVR2BPP),
|
|
|
|
CL(TexturePVR2BPPv3),
|
|
|
|
CL(TexturePVR4BPP),
|
|
|
|
CL(TexturePVR4BPPv3),
|
|
|
|
CL(TexturePVRII4BPPv3),
|
|
|
|
CL(TexturePVRRGBA8888),
|
|
|
|
CL(TexturePVRRGBA8888v3),
|
|
|
|
CL(TexturePVRBGRA8888),
|
|
|
|
CL(TexturePVRBGRA8888v3),
|
|
|
|
CL(TexturePVRRGBA4444),
|
|
|
|
CL(TexturePVRRGBA4444v3),
|
|
|
|
CL(TexturePVRRGBA4444GZ),
|
|
|
|
CL(TexturePVRRGBA4444CCZ),
|
|
|
|
CL(TexturePVRRGBA5551),
|
|
|
|
CL(TexturePVRRGBA5551v3),
|
|
|
|
CL(TexturePVRRGB565),
|
|
|
|
CL(TexturePVRRGB565v3),
|
|
|
|
CL(TexturePVRRGB888),
|
|
|
|
CL(TexturePVRRGB888v3),
|
|
|
|
CL(TexturePVRA8),
|
|
|
|
CL(TexturePVRA8v3),
|
|
|
|
CL(TexturePVRI8),
|
|
|
|
CL(TexturePVRI8v3),
|
|
|
|
CL(TexturePVRAI88),
|
|
|
|
CL(TexturePVRAI88v3),
|
|
|
|
|
|
|
|
CL(TexturePVRv3Premult),
|
|
|
|
|
|
|
|
CL(TexturePVRBadEncoding),
|
|
|
|
CL(TexturePNG),
|
|
|
|
CL(TextureJPEG),
|
|
|
|
CL(TextureTIFF),
|
|
|
|
CL(TextureWEBP),
|
|
|
|
CL(TexturePixelFormat),
|
|
|
|
CL(TextureBlend),
|
|
|
|
CL(TextureAsync),
|
|
|
|
CL(TextureGlClamp),
|
|
|
|
CL(TextureGlRepeat),
|
|
|
|
CL(TextureSizeTest),
|
|
|
|
CL(TextureCache1),
|
|
|
|
CL(TextureDrawAtPoint),
|
|
|
|
CL(TextureDrawInRect),
|
|
|
|
|
|
|
|
CL(TextureETC1),
|
2012-11-20 10:42:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFunctions[0]);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
static int sceneIdx=-1;
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* createTextureTest(int index)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = (createFunctions[index])();;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if (pLayer)
|
|
|
|
{
|
|
|
|
pLayer->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
return pLayer;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* nextTextureTest();
|
|
|
|
Layer* backTextureTest();
|
|
|
|
Layer* restartTextureTest();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* nextTextureTest()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
sceneIdx++;
|
|
|
|
sceneIdx = sceneIdx % TEST_CASE_COUNT;
|
|
|
|
|
|
|
|
return createTextureTest(sceneIdx);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* backTextureTest()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
sceneIdx--;
|
|
|
|
if( sceneIdx < 0 )
|
|
|
|
sceneIdx = TEST_CASE_COUNT -1;
|
|
|
|
|
|
|
|
return createTextureTest(sceneIdx);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* restartTextureTest()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return createTextureTest(sceneIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureDemo
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureDemo::onEnter()
|
|
|
|
{
|
2013-06-07 08:12:28 +08:00
|
|
|
BaseTest::onEnter();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LayerColor *col = LayerColor::create(ccc4(128,128,128,255));
|
2013-03-04 11:53:06 +08:00
|
|
|
addChild(col, -10);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TextureDemo::~TextureDemo()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeUnusedTextures();
|
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TextureDemo::restartCallback(Object* pSender)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene *s = new TextureTestScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(restartTextureTest());
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(s);
|
2012-04-19 14:35:52 +08:00
|
|
|
s->autorelease();
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TextureDemo::nextCallback(Object* pSender)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene *s = new TextureTestScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(nextTextureTest());
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(s);
|
2012-04-19 14:35:52 +08:00
|
|
|
s->autorelease();
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TextureDemo::backCallback(Object* pSender)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Scene *s = new TextureTestScene();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(backTextureTest());
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(s);
|
2012-04-19 14:35:52 +08:00
|
|
|
s->autorelease();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureDemo::title()
|
|
|
|
{
|
|
|
|
return "No title";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureDemo::subtitle()
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2012-05-25 10:58:28 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureTIFF
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void TextureTIFF::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-05-25 10:58:28 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image.tiff");
|
2012-05-25 10:58:28 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
this->addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-05-25 10:58:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureTIFF::title()
|
|
|
|
{
|
|
|
|
return "TIFF Test";
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePNG
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePNG::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePNG::title()
|
|
|
|
{
|
|
|
|
return "PNG Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureJPEG
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureJPEG::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image.jpeg");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureJPEG::title()
|
|
|
|
{
|
|
|
|
return "JPEG Test";
|
|
|
|
}
|
|
|
|
|
2013-02-05 11:37:13 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureWEBP
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureWEBP::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2013-02-05 11:37:13 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image.webp");
|
2013-02-05 11:37:13 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2013-02-05 11:37:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureWEBP::title()
|
|
|
|
{
|
|
|
|
return "WEBP Test";
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureMipMap
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureMipMap::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D *texture0 = TextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
texture0->generateMipmap();
|
|
|
|
ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE };
|
|
|
|
texture0->setTexParameters(&texParams);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D *texture1 = TextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas_nomipmap.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img0 = Sprite::createWithTexture(texture0);
|
2012-04-19 14:35:52 +08:00
|
|
|
img0->setTextureRect(CCRectMake(85, 121, 85, 121));
|
|
|
|
img0->setPosition(ccp( s.width/3.0f, s.height/2.0f));
|
|
|
|
addChild(img0);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img1 = Sprite::createWithTexture(texture1);
|
2012-04-19 14:35:52 +08:00
|
|
|
img1->setTextureRect(CCRectMake(85, 121, 85, 121));
|
|
|
|
img1->setPosition(ccp( 2*s.width/3.0f, s.height/2.0f));
|
|
|
|
addChild(img1);
|
|
|
|
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
EaseOut* scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
|
|
|
|
ActionInterval* sc_back = scale1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
EaseOut* scale2 = (EaseOut*) (scale1->copy());
|
2012-04-19 14:35:52 +08:00
|
|
|
scale2->autorelease();
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* sc_back2 = scale2->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
img0->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL)));
|
|
|
|
img1->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, NULL)));
|
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureMipMap::title()
|
|
|
|
{
|
|
|
|
return "Texture Mipmap";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureMipMap::subtitle()
|
|
|
|
{
|
|
|
|
return "Left image uses mipmap. Right image doesn't";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRMipMap
|
|
|
|
// To generate PVR images read this article:
|
|
|
|
// http://developer.apple.com/iphone/library/qa/qa2008/qa1611.html
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRMipMap::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *imgMipMap = Sprite::create("Images/logo-mipmap.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( imgMipMap )
|
|
|
|
{
|
|
|
|
imgMipMap->setPosition(ccp( s.width/2.0f-100, s.height/2.0f));
|
|
|
|
addChild(imgMipMap);
|
|
|
|
|
|
|
|
// support mipmap filtering
|
|
|
|
ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE };
|
|
|
|
imgMipMap->getTexture()->setTexParameters(&texParams);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/logo-nomipmap.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f+100, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
EaseOut* scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
|
|
|
|
ActionInterval* sc_back = scale1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
EaseOut* scale2 = (EaseOut*) (scale1->copy());
|
2012-04-19 14:35:52 +08:00
|
|
|
scale2->autorelease();
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* sc_back2 = scale2->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL)));
|
|
|
|
img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, NULL)));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRMipMap::title()
|
|
|
|
{
|
|
|
|
return "PVRTC MipMap Test";
|
|
|
|
}
|
|
|
|
std::string TexturePVRMipMap::subtitle()
|
|
|
|
{
|
|
|
|
return "Left image uses mipmap. Right image doesn't";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRMipMap2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRMipMap2::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *imgMipMap = Sprite::create("Images/test_image_rgba4444_mipmap.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
imgMipMap->setPosition(ccp( s.width/2.0f-100, s.height/2.0f));
|
|
|
|
addChild(imgMipMap);
|
|
|
|
|
|
|
|
// support mipmap filtering
|
|
|
|
ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE };
|
|
|
|
imgMipMap->getTexture()->setTexParameters(&texParams);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f+100, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
EaseOut* scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
|
|
|
|
ActionInterval* sc_back = scale1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
EaseOut* scale2 = (EaseOut*) (scale1->copy());
|
2012-04-19 14:35:52 +08:00
|
|
|
scale2->autorelease();
|
2013-06-20 14:17:10 +08:00
|
|
|
ActionInterval* sc_back2 = scale2->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
imgMipMap->runAction(RepeatForever::create(Sequence::create(scale1, sc_back, NULL)));
|
|
|
|
img->runAction(RepeatForever::create(Sequence::create(scale2, sc_back2, NULL)));
|
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRMipMap2::title()
|
|
|
|
{
|
|
|
|
return "PVR MipMap Test #2";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRMipMap2::subtitle()
|
|
|
|
{
|
|
|
|
return "Left image uses mipmap. Right image doesn't";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVR2BPP
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVR2BPP::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_pvrtc2bpp.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVR2BPP::title()
|
|
|
|
{
|
|
|
|
return "PVR TC 2bpp Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVR
|
|
|
|
// To generate PVR images read this article:
|
|
|
|
// http://developer.apple.com/iphone/library/qa/qa2008/qa1611.html
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
2013-06-20 13:43:40 +08:00
|
|
|
void TexturePVRTest::onEnter()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCLog("This test is not supported.");
|
|
|
|
}
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 13:43:40 +08:00
|
|
|
std::string TexturePVRTest::title()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR TC 4bpp Test #2";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVR4BPP
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVR4BPP::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_pvrtc4bpp.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCLog("This test is not supported in cocos2d-mac");
|
|
|
|
}
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVR4BPP::title()
|
|
|
|
{
|
|
|
|
return "PVR TC 4bpp Test #3";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRRGBA8888
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRRGBA8888::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba8888.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGBA8888::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 8888 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRBGRA8888
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRBGRA8888::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_bgra8888.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCLog("BGRA8888 images are not supported");
|
|
|
|
}
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRBGRA8888::title()
|
|
|
|
{
|
|
|
|
return "PVR + BGRA 8888 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRRGBA5551
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRRGBA5551::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba5551.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGBA5551::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 5551 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRRGBA4444
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRRGBA4444::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGBA4444::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 4444 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRRGBA4444GZ
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRRGBA4444GZ::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
|
|
|
// android can not pack .gz file into apk file
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
#else
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr.gz");
|
2012-04-19 14:35:52 +08:00
|
|
|
#endif
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGBA4444GZ::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 4444 + GZ Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGBA4444GZ::subtitle()
|
|
|
|
{
|
|
|
|
return "This is a gzip PVR image";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRRGBA4444CCZ
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRRGBA4444CCZ::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba4444.pvr.ccz");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGBA4444CCZ::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 4444 + CCZ Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGBA4444CCZ::subtitle()
|
|
|
|
{
|
|
|
|
return "This is a ccz PVR image";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRRGB565
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRRGB565::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgb565.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRRGB565::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGB 565 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVR RGB888
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
void TexturePVRRGB888::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgb888.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if (img != NULL)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
std::string TexturePVRRGB888::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGB 888 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRA8
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRA8::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_a8.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRA8::title()
|
|
|
|
{
|
|
|
|
return "PVR + A8 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRI8
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRI8::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_i8.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRI8::title()
|
|
|
|
{
|
|
|
|
return "PVR + I8 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRAI88
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRAI88::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_ai88.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRAI88::title()
|
|
|
|
{
|
|
|
|
return "PVR + AI88 Test";
|
|
|
|
}
|
|
|
|
|
2012-11-20 10:42:03 +08:00
|
|
|
// TexturePVR2BPPv3
|
|
|
|
void TexturePVR2BPPv3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_pvrtc2bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVR2BPPv3::title()
|
|
|
|
{
|
|
|
|
return "PVR TC 2bpp Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVR2BPPv3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRII2BPPv3
|
|
|
|
void TexturePVRII2BPPv3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_pvrtcii2bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRII2BPPv3::title()
|
|
|
|
{
|
|
|
|
return "PVR TC II 2bpp Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRII2BPPv3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVR4BPPv3
|
|
|
|
void TexturePVR4BPPv3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_pvrtc4bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCLog("This test is not supported");
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVR4BPPv3::title()
|
|
|
|
{
|
|
|
|
return "PVR TC 4bpp Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVR4BPPv3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRII4BPPv3
|
|
|
|
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
|
|
|
|
void TexturePVRII4BPPv3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_pvrtcii4bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCLog("This test is not supported");
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRII4BPPv3::title()
|
|
|
|
{
|
|
|
|
return "PVR TC II 4bpp Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRII4BPPv3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGBA8888v3
|
|
|
|
void TexturePVRRGBA8888v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba8888_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGBA8888v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 8888 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGBA8888v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRBGRA8888v3
|
|
|
|
void TexturePVRBGRA8888v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_bgra8888_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCLog("BGRA images are not supported");
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRBGRA8888v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + BGRA 8888 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRBGRA8888v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGBA5551v3
|
|
|
|
void TexturePVRRGBA5551v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba5551_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGBA5551v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 5551 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGBA5551v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGBA4444v3
|
|
|
|
void TexturePVRRGBA4444v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgba4444_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGBA4444v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGBA 4444 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGBA4444v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGB565v3
|
|
|
|
void TexturePVRRGB565v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgb565_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGB565v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGB 565 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGB565v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGB888v3
|
|
|
|
void TexturePVRRGB888v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_rgb888_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGB888v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + RGB 888 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRRGB888v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRA8v3
|
|
|
|
void TexturePVRA8v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_a8_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRA8v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + A8 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRA8v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRI8v3
|
|
|
|
void TexturePVRI8v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_i8_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRI8v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + I8 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRI8v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRAI88v3
|
|
|
|
void TexturePVRAI88v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image_ai88_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
|
|
|
img->setPosition(ccp(s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRAI88v3::title()
|
|
|
|
{
|
|
|
|
return "PVR + AI88 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
string TexturePVRAI88v3::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRBadEncoding
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRBadEncoding::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/test_image-bad_encoding.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRBadEncoding::title()
|
|
|
|
{
|
|
|
|
return "PVR Unsupported encoding";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRBadEncoding::subtitle()
|
|
|
|
{
|
|
|
|
return "You should not see any image";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRNonSquare
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRNonSquare::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/grossini_128x256_mipmap.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRNonSquare::title()
|
|
|
|
{
|
|
|
|
return "PVR + Non square texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRNonSquare::subtitle()
|
|
|
|
{
|
|
|
|
return "Loading a 128x256 texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRNPOT4444
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRNPOT4444::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/grossini_pvr_rgba4444.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if ( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRNPOT4444::title()
|
|
|
|
{
|
|
|
|
return "PVR RGBA4 + NPOT texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRNPOT4444::subtitle()
|
|
|
|
{
|
|
|
|
return "Loading a 81x121 RGBA4444 texture.";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRNPOT8888
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRNPOT8888::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *img = Sprite::create("Images/grossini_pvr_rgba8888.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
|
|
|
img->setPosition(ccp( s.width/2.0f, s.height/2.0f));
|
|
|
|
addChild(img);
|
|
|
|
}
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRNPOT8888::title()
|
|
|
|
{
|
|
|
|
return "PVR RGBA8 + NPOT texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePVRNPOT8888::subtitle()
|
|
|
|
{
|
|
|
|
return "Loading a 81x121 RGBA8888 texture.";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureAlias
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureAlias::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Sprite 1: GL_LINEAR
|
|
|
|
//
|
|
|
|
// Default filter is GL_LINEAR
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite = Sprite::create("Images/grossinis_sister1.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setPosition(ccp( s.width/3.0f, s.height/2.0f));
|
|
|
|
addChild(sprite);
|
|
|
|
|
|
|
|
// this is the default filterting
|
|
|
|
sprite->getTexture()->setAntiAliasTexParameters();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sprite 1: GL_NEAREST
|
|
|
|
//
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite2 = Sprite::create("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite2->setPosition(ccp( 2*s.width/3.0f, s.height/2.0f));
|
|
|
|
addChild(sprite2);
|
|
|
|
|
|
|
|
// Use Nearest in this one
|
|
|
|
sprite2->getTexture()->setAliasTexParameters();
|
|
|
|
|
|
|
|
// scale them to show
|
2013-06-20 14:17:10 +08:00
|
|
|
ScaleBy* sc = ScaleBy::create(3, 8.0f);
|
|
|
|
ScaleBy* sc_back = (ScaleBy*) (sc->reverse());
|
|
|
|
RepeatForever* scaleforever = RepeatForever::create(Sequence::create(sc, sc_back, NULL));
|
|
|
|
RepeatForever* scaleToo = (RepeatForever*) (scaleforever->copy());
|
2012-04-19 14:35:52 +08:00
|
|
|
scaleToo->autorelease();
|
|
|
|
|
|
|
|
sprite2->runAction(scaleforever);
|
|
|
|
sprite->runAction(scaleToo);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureAlias::title()
|
|
|
|
{
|
|
|
|
return "AntiAlias / Alias textures";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureAlias::subtitle()
|
|
|
|
{
|
|
|
|
return "Left image is antialiased. Right image is aliases";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePixelFormat
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePixelFormat::onEnter()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// This example displays 1 png images 4 times.
|
|
|
|
// Each time the image is generated using:
|
|
|
|
// 1- 32-bit RGBA8
|
|
|
|
// 2- 16-bit RGBA4
|
|
|
|
// 3- 16-bit RGB5A1
|
|
|
|
// 4- 16-bit RGB565
|
|
|
|
TextureDemo::onEnter();
|
2013-06-07 08:12:28 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LayerColor *background = LayerColor::create(ccc4(128,128,128,255), s.width, s.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(background, -1);
|
|
|
|
|
|
|
|
// RGBA 8888 image (32-bit)
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
|
|
|
Sprite *sprite1 = Sprite::create("Images/test-rgba1.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite1->setPosition(ccp(1*s.width/7, s.height/2+32));
|
|
|
|
addChild(sprite1, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTexture(sprite1->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGBA 4444 image (16-bit)
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
|
|
|
Sprite *sprite2 = Sprite::create("Images/test-rgba1.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite2->setPosition(ccp(2*s.width/7, s.height/2-32));
|
|
|
|
addChild(sprite2, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTexture(sprite2->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGB5A1 image (16-bit)
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1);
|
|
|
|
Sprite *sprite3 = Sprite::create("Images/test-rgba1.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite3->setPosition(ccp(3*s.width/7, s.height/2+32));
|
|
|
|
addChild(sprite3, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTexture(sprite3->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGB888 image
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB888);
|
|
|
|
Sprite *sprite4 = Sprite::create("Images/test-rgba1.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite4->setPosition(ccp(4*s.width/7, s.height/2-32));
|
|
|
|
addChild(sprite4, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTexture(sprite4->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGB565 image (16-bit)
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565);
|
|
|
|
Sprite *sprite5 = Sprite::create("Images/test-rgba1.png");
|
2012-04-27 15:53:29 +08:00
|
|
|
sprite5->setPosition(ccp(5*s.width/7, s.height/2+32));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite5, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTexture(sprite5->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// A8 image (8-bit)
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8);
|
|
|
|
Sprite *sprite6 = Sprite::create("Images/test-rgba1.png");
|
2012-04-27 18:37:11 +08:00
|
|
|
sprite6->setPosition(ccp(6*s.width/7, s.height/2-32));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite6, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTexture(sprite6->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
FadeOut* fadeout = FadeOut::create(2);
|
|
|
|
FadeIn* fadein = FadeIn::create(2);
|
|
|
|
Sequence* seq = Sequence::create(DelayTime::create(2), fadeout, fadein, NULL);
|
|
|
|
RepeatForever* seq_4ever = RepeatForever::create(seq);
|
|
|
|
RepeatForever* seq_4ever2 = (RepeatForever*) (seq_4ever->copy()); seq_4ever2->autorelease();
|
|
|
|
RepeatForever* seq_4ever3 = (RepeatForever*) (seq_4ever->copy()); seq_4ever3->autorelease();
|
|
|
|
RepeatForever* seq_4ever4 = (RepeatForever*) (seq_4ever->copy()); seq_4ever4->autorelease();
|
|
|
|
RepeatForever* seq_4ever5 = (RepeatForever*) (seq_4ever->copy()); seq_4ever5->autorelease();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
sprite1->runAction(seq_4ever);
|
|
|
|
sprite2->runAction(seq_4ever2);
|
|
|
|
sprite3->runAction(seq_4ever3);
|
|
|
|
sprite4->runAction(seq_4ever4);
|
|
|
|
sprite5->runAction(seq_4ever5);
|
|
|
|
|
|
|
|
// restore default
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default);
|
|
|
|
TextureCache::sharedTextureCache()->dumpCachedTextureInfo();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePixelFormat::title()
|
|
|
|
{
|
|
|
|
return "Texture Pixel Formats";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TexturePixelFormat::subtitle()
|
|
|
|
{
|
|
|
|
return "Textures: RGBA8888, RGBA4444, RGB5A1, RGB888, RGB565, A8";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureBlend
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureBlend::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
|
|
|
for( int i=0;i < 15;i++ )
|
|
|
|
{
|
|
|
|
// BOTTOM sprites have alpha pre-multiplied
|
|
|
|
// they use by default GL_ONE, GL_ONE_MINUS_SRC_ALPHA
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *cloud = Sprite::create("Images/test_blend.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(cloud, i+1, 100+i);
|
|
|
|
cloud->setPosition(ccp(50+25*i, 80));
|
|
|
|
ccBlendFunc blendFunc1 = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
|
|
|
|
cloud->setBlendFunc(blendFunc1);
|
|
|
|
|
|
|
|
// CENTER sprites have also alpha pre-multiplied
|
|
|
|
// they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
|
2013-06-20 14:17:10 +08:00
|
|
|
cloud = Sprite::create("Images/test_blend.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(cloud, i+1, 200+i);
|
|
|
|
cloud->setPosition(ccp(50+25*i, 160));
|
|
|
|
ccBlendFunc blendFunc2 = { GL_ONE_MINUS_DST_COLOR, GL_ZERO };
|
|
|
|
cloud->setBlendFunc(blendFunc2);
|
|
|
|
|
|
|
|
// UPPER sprites are using custom blending function
|
|
|
|
// You can set any blend function to your sprites
|
2013-06-20 14:17:10 +08:00
|
|
|
cloud = Sprite::create("Images/test_blend.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(cloud, i+1, 200+i);
|
|
|
|
cloud->setPosition(ccp(50+25*i, 320-80));
|
|
|
|
ccBlendFunc blendFunc3 = { GL_SRC_ALPHA, GL_ONE };
|
|
|
|
cloud->setBlendFunc(blendFunc3); // additive blending
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureBlend::title()
|
|
|
|
{
|
|
|
|
return "Texture Blending";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureBlend::subtitle()
|
|
|
|
{
|
|
|
|
return "Testing 3 different blending modes";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureAsync
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void TextureAsync::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_imageOffset = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size =Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF *label = LabelTTF::create("Loading...", "Marker Felt", 32);
|
2012-04-19 14:35:52 +08:00
|
|
|
label->setPosition(ccp( size.width/2, size.height/2));
|
|
|
|
addChild(label, 10);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
ScaleBy* scale = ScaleBy::create(0.3f, 2);
|
|
|
|
ScaleBy* scale_back = (ScaleBy*)scale->reverse();
|
|
|
|
Sequence* seq = Sequence::create(scale, scale_back, NULL);
|
|
|
|
label->runAction(RepeatForever::create(seq));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
scheduleOnce(schedule_selector(TextureAsync::loadImages), 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureAsync::~TextureAsync()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeAllTextures();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void TextureAsync::loadImages(float dt)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
for( int i=0;i < 8;i++) {
|
|
|
|
for( int j=0;j < 8; j++) {
|
|
|
|
char szSpriteName[100] = {0};
|
|
|
|
sprintf(szSpriteName, "Images/sprites_test/sprite-%d-%d.png", i, j);
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->addImageAsync(szSpriteName,this, callfuncO_selector(TextureAsync::imageLoaded));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->addImageAsync("Images/background1.jpg",this, callfuncO_selector(TextureAsync::imageLoaded));
|
|
|
|
TextureCache::sharedTextureCache()->addImageAsync("Images/background2.jpg",this, callfuncO_selector(TextureAsync::imageLoaded));
|
|
|
|
TextureCache::sharedTextureCache()->addImageAsync("Images/background.png",this, callfuncO_selector(TextureAsync::imageLoaded));
|
|
|
|
TextureCache::sharedTextureCache()->addImageAsync("Images/atlastest.png",this, callfuncO_selector(TextureAsync::imageLoaded));
|
|
|
|
TextureCache::sharedTextureCache()->addImageAsync("Images/grossini_dance_atlas.png",this, callfuncO_selector(TextureAsync::imageLoaded));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TextureAsync::imageLoaded(Object* pObj)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D* tex = (Texture2D*)pObj;
|
|
|
|
Director *director = Director::sharedDirector();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//CCAssert( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread");
|
|
|
|
|
|
|
|
// IMPORTANT: The order on the callback is not guaranteed. Don't depend on the callback
|
|
|
|
|
|
|
|
// This test just creates a sprite based on the Texture
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite = Sprite::createWithTexture(tex);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setAnchorPoint(ccp(0,0));
|
|
|
|
addChild(sprite, -1);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = director->getWinSize();
|
2013-06-15 14:03:30 +08:00
|
|
|
int i = _imageOffset * 32;
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setPosition(ccp( i % (int)size.width, (i / (int)size.width) * 32 ));
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_imageOffset++;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCLog("Image loaded: %p", tex);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureAsync::title()
|
|
|
|
{
|
|
|
|
return "Texture Async Load";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureAsync::subtitle()
|
|
|
|
{
|
|
|
|
return "Textures should load while an animation is being run";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureGlClamp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureGlClamp::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// The .png image MUST be power of 2 in order to create a continue effect.
|
|
|
|
// eg: 32x64, 512x128, 256x1024, 64x64, etc..
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite = Sprite::create("Images/pattern1.png", CCRectMake(0,0,512,256));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite, -1, kTagSprite1);
|
|
|
|
sprite->setPosition(ccp(size.width/2,size.height/2));
|
|
|
|
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE};
|
|
|
|
sprite->getTexture()->setTexParameters(¶ms);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
RotateBy* rotate = RotateBy::create(4, 360);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(rotate);
|
2013-06-20 14:17:10 +08:00
|
|
|
ScaleBy* scale = ScaleBy::create(2, 0.04f);
|
|
|
|
ScaleBy* scaleBack = (ScaleBy*) (scale->reverse());
|
|
|
|
Sequence* seq = Sequence::create(scale, scaleBack, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureGlClamp::title()
|
|
|
|
{
|
|
|
|
return "Texture GL_CLAMP";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureGlClamp::~TextureGlClamp()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeUnusedTextures();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureGlRepeat
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureGlRepeat::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// The .png image MUST be power of 2 in order to create a continue effect.
|
|
|
|
// eg: 32x64, 512x128, 256x1024, 64x64, etc..
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite = Sprite::create("Images/pattern1.png", CCRectMake(0, 0, 4096, 4096));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite, -1, kTagSprite1);
|
|
|
|
sprite->setPosition(ccp(size.width/2,size.height/2));
|
|
|
|
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
|
|
|
|
sprite->getTexture()->setTexParameters(¶ms);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
RotateBy* rotate = RotateBy::create(4, 360);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(rotate);
|
2013-06-20 14:17:10 +08:00
|
|
|
ScaleBy* scale = ScaleBy::create(2, 0.04f);
|
|
|
|
ScaleBy* scaleBack = (ScaleBy*) (scale->reverse());
|
|
|
|
Sequence* seq = Sequence::create(scale, scaleBack, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(seq);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureGlRepeat::title()
|
|
|
|
{
|
|
|
|
return "Texture GL_REPEAT";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureGlRepeat::~TextureGlRepeat()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeUnusedTextures();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureSizeTest
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureSizeTest::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite = NULL;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCLog("Loading 512x512 image...");
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite = Sprite::create("Images/texture512x512.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( sprite )
|
2013-03-16 23:56:03 +08:00
|
|
|
CCLog("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
else
|
2013-03-16 23:56:03 +08:00
|
|
|
CCLog("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCLog("Loading 1024x1024 image...");
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite = Sprite::create("Images/texture1024x1024.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( sprite )
|
2013-03-16 23:56:03 +08:00
|
|
|
CCLog("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
else
|
2013-03-16 23:56:03 +08:00
|
|
|
CCLog("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
// @todo
|
|
|
|
// CCLog("Loading 2048x2048 image...");
|
2013-06-20 14:17:10 +08:00
|
|
|
// sprite = Sprite::create("Images/texture2048x2048.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
// if( sprite )
|
2013-03-16 23:56:03 +08:00
|
|
|
// CCLog("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
// else
|
2013-03-16 23:56:03 +08:00
|
|
|
// CCLog("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
//
|
|
|
|
// CCLog("Loading 4096x4096 image...");
|
2013-06-20 14:17:10 +08:00
|
|
|
// sprite = Sprite::create("Images/texture4096x4096.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
// if( sprite )
|
2013-03-16 23:56:03 +08:00
|
|
|
// CCLog("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
// else
|
2013-03-16 23:56:03 +08:00
|
|
|
// CCLog("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureSizeTest::title()
|
|
|
|
{
|
|
|
|
return "Different Texture Sizes";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureSizeTest::subtitle()
|
|
|
|
{
|
|
|
|
return "512x512, 1024x1024. See the console.";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureCache1
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureCache1::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite = Sprite::create("Images/grossinis_sister1.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setPosition(ccp(s.width/5*1, s.height/2));
|
|
|
|
sprite->getTexture()->setAliasTexParameters();
|
|
|
|
sprite->setScale(2);
|
|
|
|
addChild(sprite);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTexture(sprite->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite = Sprite::create("Images/grossinis_sister1.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setPosition(ccp(s.width/5*2, s.height/2));
|
|
|
|
sprite->getTexture()->setAntiAliasTexParameters();
|
|
|
|
sprite->setScale(2);
|
|
|
|
addChild(sprite);
|
|
|
|
|
|
|
|
// 2nd set of sprites
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite = Sprite::create("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setPosition(ccp(s.width/5*3, s.height/2));
|
|
|
|
sprite->getTexture()->setAliasTexParameters();
|
|
|
|
sprite->setScale(2);
|
|
|
|
addChild(sprite);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeTextureForKey("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
sprite = Sprite::create("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->setPosition(ccp(s.width/5*4, s.height/2));
|
|
|
|
sprite->getTexture()->setAntiAliasTexParameters();
|
|
|
|
sprite->setScale(2);
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureCache1::title()
|
|
|
|
{
|
|
|
|
return "CCTextureCache: remove";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureCache1::subtitle()
|
|
|
|
{
|
|
|
|
return "4 images should appear: alias, antialias, alias, antilias";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TextureDrawAtPoint
|
|
|
|
void TextureDrawAtPoint::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_tex1 = TextureCache::sharedTextureCache()->addImage("Images/grossinis_sister1.png");
|
|
|
|
_tex2 = TextureCache::sharedTextureCache()->addImage("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->retain();
|
|
|
|
_tex2->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TextureDrawAtPoint::~TextureDrawAtPoint()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->release();
|
|
|
|
_tex2->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureDrawAtPoint::title()
|
|
|
|
{
|
|
|
|
return "CCTexture2D: drawAtPoint";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureDrawAtPoint::subtitle()
|
|
|
|
{
|
|
|
|
return "draws 2 textures using drawAtPoint";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextureDrawAtPoint::draw()
|
|
|
|
{
|
|
|
|
TextureDemo::draw();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->drawAtPoint(ccp(s.width/2-50, s.height/2 - 50));
|
|
|
|
_tex2->drawAtPoint(ccp(s.width/2+50, s.height/2 - 50));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// TextureDrawInRect
|
|
|
|
|
|
|
|
void TextureDrawInRect::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-20 14:17:10 +08:00
|
|
|
_tex1 = TextureCache::sharedTextureCache()->addImage("Images/grossinis_sister1.png");
|
|
|
|
_tex2 = TextureCache::sharedTextureCache()->addImage("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->retain();
|
|
|
|
_tex2->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TextureDrawInRect::~TextureDrawInRect()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->release();
|
|
|
|
_tex2->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void TextureDrawInRect::draw()
|
|
|
|
{
|
|
|
|
TextureDemo::draw();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Rect rect1 = CCRectMake( s.width/2 - 80, 20, _tex1->getContentSize().width * 0.5f, _tex1->getContentSize().height *2 );
|
|
|
|
Rect rect2 = CCRectMake( s.width/2 + 80, s.height/2, _tex1->getContentSize().width * 2, _tex1->getContentSize().height * 0.5f );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->drawInRect(rect1);
|
|
|
|
_tex2->drawInRect(rect2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureDrawInRect::title()
|
|
|
|
{
|
|
|
|
return "CCTexture2D: drawInRect";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureDrawInRect::subtitle()
|
|
|
|
{
|
|
|
|
return "draws 2 textures using drawInRect";
|
|
|
|
}
|
|
|
|
|
2012-06-13 10:41:04 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureTestScene
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureTestScene::runThisTest()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = nextTextureTest();
|
2012-06-13 10:41:04 +08:00
|
|
|
addChild(pLayer);
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(this);
|
2012-06-13 10:41:04 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-13 10:41:04 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureMemoryAlloc
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureMemoryAlloc::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-06-15 14:03:30 +08:00
|
|
|
_background = NULL;
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItemFont::setFontSize(24);
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItem *item1 = MenuItemFont::create("PNG", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item1->setTag(0);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItem *item2 = MenuItemFont::create("RGBA8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item2->setTag(1);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItem *item3 = MenuItemFont::create("RGB8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item3->setTag(2);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItem *item4 = MenuItemFont::create("RGBA4", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item4->setTag(3);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItem *item5 = MenuItemFont::create("A8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item5->setTag(4);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Menu *menu = Menu::create(item1, item2, item3, item4, item5, NULL);
|
2012-06-13 10:41:04 +08:00
|
|
|
menu->alignItemsHorizontally();
|
|
|
|
|
|
|
|
addChild(menu);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItemFont *warmup = MenuItemFont::create("warm up texture", CC_CALLBACK_1(TextureMemoryAlloc::changeBackgroundVisible, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Menu *menu2 = Menu::create(warmup, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-06-13 10:41:04 +08:00
|
|
|
menu2->alignItemsHorizontally();
|
|
|
|
|
|
|
|
addChild(menu2);
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2012-06-13 10:41:04 +08:00
|
|
|
|
|
|
|
menu2->setPosition(ccp(s.width/2, s.height/4));
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::Object *sender)
|
2012-06-13 10:41:04 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_background)
|
2012-06-13 10:41:04 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_background->setVisible(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TextureMemoryAlloc::updateImage(cocos2d::Object *sender)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_background)
|
2012-06-13 10:41:04 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_background->removeFromParentAndCleanup(true);
|
2012-06-13 10:41:04 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
TextureCache::sharedTextureCache()->removeUnusedTextures();
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
int tag = ((Node*)sender)->getTag();
|
2012-06-13 10:41:04 +08:00
|
|
|
string file;
|
|
|
|
switch (tag)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
file = "Images/test_1021x1024.png";
|
|
|
|
break;
|
2012-06-28 17:34:50 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
|
|
|
// android can not pack .gz file into apk file
|
|
|
|
case 1:
|
|
|
|
file = "Images/test_1021x1024_rgba8888.pvr";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
file = "Images/test_1021x1024_rgb888.pvr";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
file = "Images/test_1021x1024_rgba4444.pvr";
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
file = "Images/test_1021x1024_a8.pvr";
|
|
|
|
break;
|
|
|
|
#else
|
2012-06-13 10:41:04 +08:00
|
|
|
case 1:
|
|
|
|
file = "Images/test_1021x1024_rgba8888.pvr.gz";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
file = "Images/test_1021x1024_rgb888.pvr.gz";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
file = "Images/test_1021x1024_rgba4444.pvr.gz";
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
file = "Images/test_1021x1024_a8.pvr.gz";
|
|
|
|
break;
|
2012-06-28 17:34:50 +08:00
|
|
|
#endif
|
2012-06-13 10:41:04 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
_background = Sprite::create(file.c_str());
|
2013-06-15 14:03:30 +08:00
|
|
|
addChild(_background, -10);
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_background->setVisible(false);
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2013-06-15 14:03:30 +08:00
|
|
|
_background->setPosition(ccp(s.width/2, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-06-13 10:41:04 +08:00
|
|
|
string TextureMemoryAlloc::title()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-06-13 10:41:04 +08:00
|
|
|
return "Texture memory";
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2012-06-13 10:41:04 +08:00
|
|
|
string TextureMemoryAlloc::subtitle()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-06-13 10:41:04 +08:00
|
|
|
return "Testing Texture Memory allocation. Use Instruments + VM Tracker";
|
2013-02-28 14:54:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRv3Premult
|
|
|
|
TexturePVRv3Premult::TexturePVRv3Premult()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2013-02-28 14:54:09 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
LayerColor *background = LayerColor::create(ccc4(128,128,128,255), size.width, size.height);
|
2013-02-28 14:54:09 +08:00
|
|
|
addChild(background, -1);
|
|
|
|
|
|
|
|
|
|
|
|
// PVR premultiplied
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *pvr1 = Sprite::create("Images/grossinis_sister1-testalpha_premult.pvr");
|
2013-02-28 14:54:09 +08:00
|
|
|
addChild(pvr1, 0);
|
|
|
|
pvr1->setPosition(ccp(size.width/4*1, size.height/2));
|
|
|
|
transformSprite(pvr1);
|
|
|
|
|
|
|
|
// PVR non-premultiplied
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *pvr2 = Sprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr");
|
2013-02-28 14:54:09 +08:00
|
|
|
addChild(pvr2, 0);
|
|
|
|
pvr2->setPosition(ccp(size.width/4*2, size.height/2));
|
|
|
|
transformSprite(pvr2);
|
|
|
|
|
|
|
|
// PNG
|
2013-06-20 14:17:10 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
|
|
|
TextureCache::sharedTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
|
|
|
|
Sprite *png = Sprite::create("Images/grossinis_sister1-testalpha.png");
|
2013-02-28 14:54:09 +08:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void TexturePVRv3Premult::transformSprite(cocos2d::Sprite *sprite)
|
2013-02-28 14:54:09 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
FadeOut *fade = FadeOut::create(2);
|
|
|
|
DelayTime *dl = DelayTime::create(2);
|
|
|
|
FadeOut *fadein = (FadeOut*)fade->reverse();
|
|
|
|
Sequence *seq = Sequence::create(fade, fadein, dl, NULL);
|
|
|
|
RepeatForever *repeat = RepeatForever::create(seq);
|
2013-02-28 14:54:09 +08:00
|
|
|
sprite->runAction(repeat);
|
|
|
|
}
|
2013-05-27 14:42:22 +08:00
|
|
|
|
|
|
|
// Implementation of ETC1
|
|
|
|
|
|
|
|
/*
|
|
|
|
class TextureETC1 : public TextureDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TextureETC1();
|
|
|
|
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
TextureETC1::TextureETC1()
|
|
|
|
{
|
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite *sprite = Sprite::create("Images/ETC1.pkm");
|
2013-05-27 14:42:22 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
2013-05-27 14:42:22 +08:00
|
|
|
sprite->setPosition(ccp(size.width/2, size.height/2));
|
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureETC1::title()
|
|
|
|
{
|
|
|
|
return "ETC1 texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string TextureETC1::subtitle()
|
|
|
|
{
|
|
|
|
return "only supported on android";
|
|
|
|
}
|