2014-01-14 06:48:12 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// local import
|
|
|
|
#include "Texture2dTest.h"
|
|
|
|
#include "../testResource.h"
|
2013-12-26 10:03:45 +08:00
|
|
|
#include "renderer/CCRenderer.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
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
|
|
|
{
|
2013-07-26 05:49:43 +08:00
|
|
|
CL(TexturePVRv3Premult),
|
|
|
|
|
2014-03-25 16:19:34 +08:00
|
|
|
CL(TextureMipMap),
|
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),
|
2013-11-29 14:31:42 +08:00
|
|
|
CL(TextureTGA),
|
2014-03-22 21:15:45 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_INRT)
|
2013-06-07 08:12:28 +08:00
|
|
|
CL(TextureWEBP),
|
2014-03-22 21:15:45 +08:00
|
|
|
#endif
|
2013-06-07 08:12:28 +08:00
|
|
|
CL(TexturePixelFormat),
|
|
|
|
CL(TextureBlend),
|
|
|
|
CL(TextureAsync),
|
|
|
|
CL(TextureGlClamp),
|
|
|
|
CL(TextureGlRepeat),
|
|
|
|
CL(TextureSizeTest),
|
|
|
|
CL(TextureCache1),
|
|
|
|
CL(TextureDrawAtPoint),
|
|
|
|
CL(TextureDrawInRect),
|
|
|
|
|
|
|
|
CL(TextureETC1),
|
2013-07-29 17:34:33 +08:00
|
|
|
|
2013-08-06 11:19:45 +08:00
|
|
|
CL(TextureS3TCDxt1),
|
|
|
|
CL(TextureS3TCDxt3),
|
|
|
|
CL(TextureS3TCDxt5),
|
2014-02-20 18:27:52 +08:00
|
|
|
CL(TextureS3TCWithNoMipmaps),
|
2013-08-06 11:19:45 +08:00
|
|
|
|
2013-08-16 11:02:44 +08:00
|
|
|
CL(TextureATITCRGB),
|
|
|
|
CL(TextureATITCExplicit),
|
|
|
|
CL(TextureATITCInterpolated),
|
|
|
|
|
2013-07-29 17:34:33 +08:00
|
|
|
CL(TextureConvertRGB888),
|
|
|
|
CL(TextureConvertRGBA8888),
|
|
|
|
CL(TextureConvertI8),
|
|
|
|
CL(TextureConvertAI88),
|
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-08-16 16:05:27 +08:00
|
|
|
auto layer = (createFunctions[index])();;
|
2013-07-23 08:25:44 +08:00
|
|
|
return layer;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
auto textureCache = Director::getInstance()->getTextureCache();
|
|
|
|
log("%s\n", textureCache->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto col = LayerColor::create(Color4B(128,128,128,255));
|
2013-03-04 11:53:06 +08:00
|
|
|
addChild(col, -10);
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", textureCache->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TextureDemo::~TextureDemo()
|
|
|
|
{
|
2014-01-15 09:22:45 +08:00
|
|
|
auto textureCache = Director::getInstance()->getTextureCache();
|
|
|
|
textureCache->removeUnusedTextures();
|
|
|
|
log("%s\n", textureCache->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void TextureDemo::restartCallback(Ref* sender)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-11-14 09:47:26 +08:00
|
|
|
auto s = TextureTestScene::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(restartTextureTest());
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void TextureDemo::nextCallback(Ref* sender)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-11-14 09:47:26 +08:00
|
|
|
auto s = TextureTestScene::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(nextTextureTest());
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void TextureDemo::backCallback(Ref* sender)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-11-14 09:47:26 +08:00
|
|
|
auto s = TextureTestScene::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
s->addChild(backTextureTest());
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(s);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureDemo::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "No title";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureDemo::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2012-05-25 10:58:28 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureTIFF
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void TextureTIFF::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-05-25 10:58:28 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image.tiff");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-05-25 10:58:28 +08:00
|
|
|
this->addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
|
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-05-25 10:58:28 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureTIFF::title() const
|
2012-05-25 10:58:28 +08:00
|
|
|
{
|
|
|
|
return "TIFF Test";
|
|
|
|
}
|
|
|
|
|
2013-11-29 14:31:42 +08:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureTGA
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
void TextureTGA::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
|
|
|
|
auto img = Sprite::create("TileMaps/levelmap.tga");
|
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
|
|
|
this->addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2013-11-29 14:31:42 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureTGA::title() const
|
2013-11-29 14:31:42 +08:00
|
|
|
{
|
|
|
|
return "TGA Test";
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePNG
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePNG::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePNG::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PNG Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureJPEG
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureJPEG::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image.jpeg");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureJPEG::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "JPEG Test";
|
|
|
|
}
|
|
|
|
|
2013-02-05 11:37:13 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureWEBP
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureWEBP::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-02-05 11:37:13 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image.webp");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2013-02-05 11:37:13 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2013-02-05 11:37:13 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureWEBP::title() const
|
2013-02-05 11:37:13 +08:00
|
|
|
{
|
|
|
|
return "WEBP Test";
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureMipMap
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureMipMap::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-07 21:48:39 +08:00
|
|
|
auto texture0 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
texture0->generateMipmap();
|
2013-08-01 15:53:52 +08:00
|
|
|
Texture2D::TexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE };
|
2013-07-04 08:59:22 +08:00
|
|
|
texture0->setTexParameters(texParams);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-11-07 21:48:39 +08:00
|
|
|
auto texture1 = Director::getInstance()->getTextureCache()->addImage("Images/grossini_dance_atlas_nomipmap.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img0 = Sprite::createWithTexture(texture0);
|
2013-07-12 14:30:26 +08:00
|
|
|
img0->setTextureRect(Rect(85, 121, 85, 121));
|
2013-07-12 14:11:55 +08:00
|
|
|
img0->setPosition(Point( s.width/3.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img0);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img1 = Sprite::createWithTexture(texture1);
|
2013-07-12 14:30:26 +08:00
|
|
|
img1->setTextureRect(Rect(85, 121, 85, 121));
|
2013-07-12 14:11:55 +08:00
|
|
|
img1->setPosition(Point( 2*s.width/3.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img1);
|
|
|
|
|
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
|
|
|
|
auto sc_back = scale1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale2 = scale1->clone();
|
|
|
|
auto 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)));
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureMipMap::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Texture Mipmap";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureMipMap::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto imgMipMap = Sprite::create("Images/logo-mipmap.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( imgMipMap )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
imgMipMap->setPosition(Point( s.width/2.0f-100, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(imgMipMap);
|
|
|
|
|
|
|
|
// support mipmap filtering
|
2013-08-01 15:53:52 +08:00
|
|
|
Texture2D::TexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE };
|
2013-07-04 08:59:22 +08:00
|
|
|
imgMipMap->getTexture()->setTexParameters(texParams);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/logo-nomipmap.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f+100, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
|
|
|
|
auto sc_back = scale1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale2 = scale1->clone();
|
|
|
|
auto 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
|
|
|
}
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRMipMap::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVRTC MipMap Test";
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRMipMap::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Left image uses mipmap. Right image doesn't";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRMipMap2
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRMipMap2::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto imgMipMap = Sprite::create("Images/test_image_rgba4444_mipmap.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
imgMipMap->setPosition(Point( s.width/2.0f-100, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(imgMipMap);
|
|
|
|
|
|
|
|
// support mipmap filtering
|
2013-08-01 15:53:52 +08:00
|
|
|
Texture2D::TexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE };
|
2013-07-04 08:59:22 +08:00
|
|
|
imgMipMap->getTexture()->setTexParameters(texParams);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f+100, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale1 = EaseOut::create(ScaleBy::create(4, 0.01f), 3);
|
|
|
|
auto sc_back = scale1->reverse();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale2 = scale1->clone();
|
|
|
|
auto 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)));
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRMipMap2::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR MipMap Test #2";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRMipMap2::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_pvrtc2bpp.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVR2BPP::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("This test is not supported.");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRTest::title() const
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_pvrtc4bpp.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
if( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("This test is not supported in cocos2d-mac");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVR4BPP::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba8888.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA8888::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_bgra8888.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("BGRA8888 images are not supported");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRBGRA8888::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba5551.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA5551::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba4444.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA4444::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->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-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba4444.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
#else
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba4444.pvr.gz");
|
2012-04-19 14:35:52 +08:00
|
|
|
#endif
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA4444GZ::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR + RGBA 4444 + GZ Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA4444GZ::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba4444.pvr.ccz");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA4444CCZ::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR + RGBA 4444 + CCZ Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA4444CCZ::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgb565.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGB565::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgb888.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if (img != NULL)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGB888::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_a8.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRA8::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR + A8 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRI8
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRI8::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_i8.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRI8::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR + I8 Test";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRAI88
|
|
|
|
// Image generated using PVRTexTool:
|
|
|
|
// http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRAI88::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_ai88.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRAI88::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR + AI88 Test";
|
|
|
|
}
|
|
|
|
|
2012-11-20 10:42:03 +08:00
|
|
|
// TexturePVR2BPPv3
|
|
|
|
void TexturePVR2BPPv3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_pvrtc2bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVR2BPPv3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR TC 2bpp Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVR2BPPv3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRII2BPPv3
|
|
|
|
void TexturePVRII2BPPv3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_pvrtcii2bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRII2BPPv3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR TC II 2bpp Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRII2BPPv3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVR4BPPv3
|
|
|
|
void TexturePVR4BPPv3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_pvrtc4bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("This test is not supported");
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVR4BPPv3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR TC 4bpp Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVR4BPPv3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_pvrtcii4bpp_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("This test is not supported");
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRII4BPPv3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR TC II 4bpp Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRII4BPPv3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGBA8888v3
|
|
|
|
void TexturePVRRGBA8888v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba8888_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA8888v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + RGBA 8888 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA8888v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRBGRA8888v3
|
|
|
|
void TexturePVRBGRA8888v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_bgra8888_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("BGRA images are not supported");
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRBGRA8888v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + BGRA 8888 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRBGRA8888v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGBA5551v3
|
|
|
|
void TexturePVRRGBA5551v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba5551_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA5551v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + RGBA 5551 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA5551v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGBA4444v3
|
|
|
|
void TexturePVRRGBA4444v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgba4444_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA4444v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + RGBA 4444 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGBA4444v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGB565v3
|
|
|
|
void TexturePVRRGB565v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgb565_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGB565v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + RGB 565 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGB565v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRRGB888v3
|
|
|
|
void TexturePVRRGB888v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_rgb888_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGB888v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + RGB 888 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRRGB888v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRA8v3
|
|
|
|
void TexturePVRA8v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_a8_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRA8v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + A8 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRA8v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRI8v3
|
|
|
|
void TexturePVRI8v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_i8_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRI8v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + I8 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRI8v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "Testing PVR File Format v3";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TexturePVRAI88v3
|
|
|
|
void TexturePVRAI88v3::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-11-20 10:42:03 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image_ai88_v3.pvr");
|
2012-11-20 10:42:03 +08:00
|
|
|
|
|
|
|
if (img)
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point(s.width/2.0f, s.height/2.0f));
|
2012-11-20 10:42:03 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-11-20 10:42:03 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRAI88v3::title() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
return "PVR + AI88 Test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRAI88v3::subtitle() const
|
2012-11-20 10:42:03 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/test_image-bad_encoding.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRBadEncoding::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR Unsupported encoding";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRBadEncoding::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "You should not see any image";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRNonSquare
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRNonSquare::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/grossini_128x256_mipmap.pvr");
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRNonSquare::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR + Non square texture";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRNonSquare::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Loading a 128x256 texture";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRNPOT4444
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRNPOT4444::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/grossini_pvr_rgba4444.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if ( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRNPOT4444::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR RGBA4 + NPOT texture";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRNPOT4444::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Loading a 81x121 RGBA4444 texture.";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TexturePVRNPOT8888
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TexturePVRNPOT8888::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto img = Sprite::create("Images/grossini_pvr_rgba8888.pvr");
|
2012-04-19 14:35:52 +08:00
|
|
|
if( img )
|
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(img);
|
|
|
|
}
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRNPOT8888::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "PVR RGBA8 + NPOT texture";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRNPOT8888::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Loading a 81x121 RGBA8888 texture.";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureAlias
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureAlias::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Sprite 1: GL_LINEAR
|
|
|
|
//
|
|
|
|
// Default filter is GL_LINEAR
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create("Images/grossinis_sister1.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point( s.width/3.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite);
|
|
|
|
|
|
|
|
// this is the default filterting
|
|
|
|
sprite->getTexture()->setAntiAliasTexParameters();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sprite 1: GL_NEAREST
|
|
|
|
//
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite2 = Sprite::create("Images/grossinis_sister2.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite2->setPosition(Point( 2*s.width/3.0f, s.height/2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite2);
|
|
|
|
|
|
|
|
// Use Nearest in this one
|
|
|
|
sprite2->getTexture()->setAliasTexParameters();
|
|
|
|
|
|
|
|
// scale them to show
|
2013-06-22 11:02:43 +08:00
|
|
|
auto sc = ScaleBy::create(3, 8.0f);
|
|
|
|
auto sc_back = sc->reverse();
|
|
|
|
auto scaleforever = RepeatForever::create(Sequence::create(sc, sc_back, NULL));
|
|
|
|
auto scaleToo = scaleforever->clone();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
sprite2->runAction(scaleforever);
|
|
|
|
sprite->runAction(scaleToo);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureAlias::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "AntiAlias / Alias textures";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureAlias::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto background = LayerColor::create(Color4B(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-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite1 = Sprite::create("Images/test-rgba1.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite1->setPosition(Point(1*s.width/7, s.height/2+32));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite1, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTexture(sprite1->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGBA 4444 image (16-bit)
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite2 = Sprite::create("Images/test-rgba1.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite2->setPosition(Point(2*s.width/7, s.height/2-32));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite2, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTexture(sprite2->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGB5A1 image (16-bit)
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite3 = Sprite::create("Images/test-rgba1.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite3->setPosition(Point(3*s.width/7, s.height/2+32));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite3, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTexture(sprite3->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGB888 image
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB888);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite4 = Sprite::create("Images/test-rgba1.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite4->setPosition(Point(4*s.width/7, s.height/2-32));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite4, 0);
|
|
|
|
|
|
|
|
// remove texture from texture manager
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTexture(sprite4->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// RGB565 image (16-bit)
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite5 = Sprite::create("Images/test-rgba1.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite5->setPosition(Point(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-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTexture(sprite5->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// A8 image (8-bit)
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite6 = Sprite::create("Images/test-rgba1.png");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite6->setPosition(Point(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-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTexture(sprite6->getTexture());
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto fadeout = FadeOut::create(2);
|
|
|
|
auto fadein = FadeIn::create(2);
|
|
|
|
auto seq = Sequence::create(DelayTime::create(2), fadeout, fadein, NULL);
|
|
|
|
auto seq_4ever = RepeatForever::create(seq);
|
|
|
|
auto seq_4ever2 = seq_4ever->clone();
|
|
|
|
auto seq_4ever3 = seq_4ever->clone();
|
|
|
|
auto seq_4ever4 = seq_4ever->clone();
|
|
|
|
auto seq_4ever5 = seq_4ever->clone();
|
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-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePixelFormat::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Texture Pixel Formats";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePixelFormat::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto cloud = Sprite::create("Images/test_blend.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(cloud, i+1, 100+i);
|
2013-07-12 14:11:55 +08:00
|
|
|
cloud->setPosition(Point(50+25*i, 80));
|
2013-07-26 04:36:19 +08:00
|
|
|
cloud->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// 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);
|
2013-07-12 14:11:55 +08:00
|
|
|
cloud->setPosition(Point(50+25*i, 160));
|
2013-07-05 16:49:22 +08:00
|
|
|
BlendFunc blendFunc2 = { GL_ONE_MINUS_DST_COLOR, GL_ZERO };
|
2012-04-19 14:35:52 +08:00
|
|
|
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);
|
2013-07-12 14:11:55 +08:00
|
|
|
cloud->setPosition(Point(50+25*i, 320-80));
|
2013-07-05 16:49:22 +08:00
|
|
|
BlendFunc blendFunc3 = { GL_SRC_ALPHA, GL_ONE };
|
2012-04-19 14:35:52 +08:00
|
|
|
cloud->setBlendFunc(blendFunc3); // additive blending
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureBlend::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Texture Blending";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureBlend::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = Label::createWithTTF("Loading...", "fonts/Marker Felt.ttf", 32);
|
2013-07-12 14:11:55 +08:00
|
|
|
label->setPosition(Point( size.width/2, size.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(label, 10);
|
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale = ScaleBy::create(0.3f, 2);
|
|
|
|
auto scale_back = scale->reverse();
|
|
|
|
auto seq = Sequence::create(scale, scale_back, NULL);
|
2013-06-20 14:17:10 +08:00
|
|
|
label->runAction(RepeatForever::create(seq));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
scheduleOnce(schedule_selector(TextureAsync::loadImages), 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureAsync::~TextureAsync()
|
|
|
|
{
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->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);
|
2014-01-02 17:23:00 +08:00
|
|
|
Director::getInstance()->getTextureCache()->addImageAsync(szSpriteName, CC_CALLBACK_1(TextureAsync::imageLoaded, this));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-02 17:23:00 +08:00
|
|
|
Director::getInstance()->getTextureCache()->addImageAsync("Images/background1.jpg", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
|
|
|
|
Director::getInstance()->getTextureCache()->addImageAsync("Images/background2.jpg", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
|
|
|
|
Director::getInstance()->getTextureCache()->addImageAsync("Images/background.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
|
|
|
|
Director::getInstance()->getTextureCache()->addImageAsync("Images/atlastest.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
|
|
|
|
Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_atlas.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-02 17:23:00 +08:00
|
|
|
void TextureAsync::imageLoaded(Texture2D* texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto director = Director::getInstance();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-20 13:01:27 +08:00
|
|
|
//CCASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2014-01-02 17:23:00 +08:00
|
|
|
auto sprite = Sprite::createWithTexture(texture);
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setAnchorPoint(Point(0,0));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite, -1);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto size = director->getWinSize();
|
2013-06-15 14:03:30 +08:00
|
|
|
int i = _imageOffset * 32;
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point( i % (int)size.width, (i / (int)size.width) * 32 ));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_imageOffset++;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-01-02 17:23:00 +08:00
|
|
|
log("Image loaded: %p", texture);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureAsync::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Texture Async Load";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureAsync::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Textures should load while an animation is being run";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureGlClamp
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureGlClamp::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->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-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create("Images/pattern1.png", Rect(0,0,512,256));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite, -1, kTagSprite1);
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point(size.width/2,size.height/2));
|
2013-08-01 15:53:52 +08:00
|
|
|
Texture2D::TexParams params = {GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE};
|
2013-07-04 08:59:22 +08:00
|
|
|
sprite->getTexture()->setTexParameters(params);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto rotate = RotateBy::create(4, 360);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(rotate);
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale = ScaleBy::create(2, 0.04f);
|
|
|
|
auto scaleBack = scale->reverse();
|
|
|
|
auto seq = Sequence::create(scale, scaleBack, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(seq);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureGlClamp::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Texture GL_CLAMP";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureGlClamp::~TextureGlClamp()
|
|
|
|
{
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeUnusedTextures();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureGlRepeat
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureGlRepeat::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->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-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create("Images/pattern1.png", Rect(0, 0, 4096, 4096));
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(sprite, -1, kTagSprite1);
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point(size.width/2,size.height/2));
|
2013-08-01 15:53:52 +08:00
|
|
|
Texture2D::TexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
|
2013-07-04 08:59:22 +08:00
|
|
|
sprite->getTexture()->setTexParameters(params);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-22 11:02:43 +08:00
|
|
|
auto rotate = RotateBy::create(4, 360);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(rotate);
|
2013-06-22 11:02:43 +08:00
|
|
|
auto scale = ScaleBy::create(2, 0.04f);
|
|
|
|
auto scaleBack = scale->reverse();
|
|
|
|
auto seq = Sequence::create(scale, scaleBack, NULL);
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->runAction(seq);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureGlRepeat::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Texture GL_REPEAT";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureGlRepeat::~TextureGlRepeat()
|
|
|
|
{
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->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
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
log("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-07-24 06:20:22 +08:00
|
|
|
log("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
else
|
2013-07-24 06:20:22 +08:00
|
|
|
log("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-24 06:20:22 +08:00
|
|
|
log("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-07-24 06:20:22 +08:00
|
|
|
log("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
else
|
2013-07-24 06:20:22 +08:00
|
|
|
log("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
// @todo
|
2013-07-24 06:20:22 +08:00
|
|
|
// log("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-07-24 06:20:22 +08:00
|
|
|
// log("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
// else
|
2013-07-24 06:20:22 +08:00
|
|
|
// log("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
//
|
2013-07-24 06:20:22 +08:00
|
|
|
// log("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-07-24 06:20:22 +08:00
|
|
|
// log("OK");
|
2012-04-19 14:35:52 +08:00
|
|
|
// else
|
2013-07-24 06:20:22 +08:00
|
|
|
// log("Error");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureSizeTest::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "Different Texture Sizes";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureSizeTest::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "512x512, 1024x1024. See the console.";
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// TextureCache1
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void TextureCache1::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->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");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point(s.width/5*1, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->getTexture()->setAliasTexParameters();
|
|
|
|
sprite->setScale(2);
|
|
|
|
addChild(sprite);
|
|
|
|
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->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");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point(s.width/5*2, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
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");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point(s.width/5*3, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->getTexture()->setAliasTexParameters();
|
|
|
|
sprite->setScale(2);
|
|
|
|
addChild(sprite);
|
|
|
|
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->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");
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point(s.width/5*4, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
sprite->getTexture()->setAntiAliasTexParameters();
|
|
|
|
sprite->setScale(2);
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureCache1::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "CCTextureCache: remove";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureCache1::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "4 images should appear: alias, antialias, alias, antilias";
|
|
|
|
}
|
|
|
|
|
|
|
|
// TextureDrawAtPoint
|
|
|
|
void TextureDrawAtPoint::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-11-07 21:48:39 +08:00
|
|
|
_tex1 = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png");
|
|
|
|
_Tex2F = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->retain();
|
2013-07-05 16:49:22 +08:00
|
|
|
_Tex2F->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TextureDrawAtPoint::~TextureDrawAtPoint()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->release();
|
2013-07-05 16:49:22 +08:00
|
|
|
_Tex2F->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureDrawAtPoint::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "CCTexture2D: drawAtPoint";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureDrawAtPoint::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "draws 2 textures using drawAtPoint";
|
|
|
|
}
|
|
|
|
|
2014-03-01 08:10:48 +08:00
|
|
|
void TextureDrawAtPoint::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2014-03-01 08:10:48 +08:00
|
|
|
TextureDemo::draw(renderer, transform, transformUpdated);
|
2013-12-26 10:03:45 +08:00
|
|
|
|
2014-01-19 03:35:27 +08:00
|
|
|
_renderCmd.init(_globalZOrder);
|
2014-03-06 07:49:08 +08:00
|
|
|
_renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this, transform, transformUpdated);
|
2014-03-01 08:10:48 +08:00
|
|
|
renderer->addCommand(&_renderCmd);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-26 10:03:45 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-03-06 07:49:08 +08:00
|
|
|
void TextureDrawAtPoint::onDraw(const kmMat4 &transform, bool transformUpdated)
|
2013-12-26 10:03:45 +08:00
|
|
|
{
|
2014-03-06 07:49:08 +08:00
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLLoadMatrix(&transform);
|
|
|
|
|
2013-12-26 10:03:45 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
_tex1->drawAtPoint(Point(s.width/2-50, s.height/2 - 50));
|
|
|
|
_Tex2F->drawAtPoint(Point(s.width/2+50, s.height/2 - 50));
|
2013-12-26 10:03:45 +08:00
|
|
|
|
2014-03-06 07:49:08 +08:00
|
|
|
kmGLPopMatrix();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// TextureDrawInRect
|
|
|
|
|
|
|
|
void TextureDrawInRect::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
2013-11-07 21:48:39 +08:00
|
|
|
_tex1 = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister1.png");
|
|
|
|
_Tex2F = Director::getInstance()->getTextureCache()->addImage("Images/grossinis_sister2.png");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->retain();
|
2013-07-05 16:49:22 +08:00
|
|
|
_Tex2F->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TextureDrawInRect::~TextureDrawInRect()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->release();
|
2013-07-05 16:49:22 +08:00
|
|
|
_Tex2F->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2014-03-01 08:10:48 +08:00
|
|
|
void TextureDrawInRect::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2014-03-01 08:10:48 +08:00
|
|
|
TextureDemo::draw(renderer, transform, transformUpdated);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-01-19 03:35:27 +08:00
|
|
|
_renderCmd.init(_globalZOrder);
|
2014-03-06 07:49:08 +08:00
|
|
|
_renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this, transform, transformUpdated);
|
2014-03-01 08:10:48 +08:00
|
|
|
renderer->addCommand(&_renderCmd);
|
2013-12-26 10:24:40 +08:00
|
|
|
}
|
|
|
|
|
2014-03-06 07:49:08 +08:00
|
|
|
void TextureDrawInRect::onDraw(const kmMat4 &transform, bool transformUpdated)
|
2013-12-26 10:24:40 +08:00
|
|
|
{
|
2014-03-06 07:49:08 +08:00
|
|
|
kmGLPushMatrix();
|
|
|
|
kmGLLoadMatrix(&transform);
|
2013-12-26 10:24:40 +08:00
|
|
|
|
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto rect1 = Rect( s.width/2 - 80, 20, _tex1->getContentSize().width * 0.5f, _tex1->getContentSize().height *2 );
|
|
|
|
auto rect2 = Rect( s.width/2 + 80, s.height/2, _tex1->getContentSize().width * 2, _tex1->getContentSize().height * 0.5f );
|
2013-12-26 10:24:40 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_tex1->drawInRect(rect1);
|
2013-07-05 16:49:22 +08:00
|
|
|
_Tex2F->drawInRect(rect2);
|
2013-12-26 10:24:40 +08:00
|
|
|
|
2014-03-06 07:49:08 +08:00
|
|
|
kmGLPopMatrix();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureDrawInRect::title() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return "CCTexture2D: drawInRect";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureDrawInRect::subtitle() const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto layer = nextTextureTest();
|
2013-07-23 08:25:44 +08:00
|
|
|
addChild(layer);
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->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-08-16 16:05:27 +08:00
|
|
|
auto item1 = MenuItemFont::create("PNG", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item1->setTag(0);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto item2 = MenuItemFont::create("RGBA8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item2->setTag(1);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto item3 = MenuItemFont::create("RGB8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item3->setTag(2);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto item4 = MenuItemFont::create("RGBA4", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item4->setTag(3);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto item5 = MenuItemFont::create("A8", CC_CALLBACK_1(TextureMemoryAlloc::updateImage, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
item5->setTag(4);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto menu = Menu::create(item1, item2, item3, item4, item5, NULL);
|
2012-06-13 10:41:04 +08:00
|
|
|
menu->alignItemsHorizontally();
|
|
|
|
|
|
|
|
addChild(menu);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto warmup = MenuItemFont::create("warm up texture", CC_CALLBACK_1(TextureMemoryAlloc::changeBackgroundVisible, this));
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto 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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
menu2->setPosition(Point(s.width/2, s.height/4));
|
2012-06-13 10:41:04 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::Ref *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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void TextureMemoryAlloc::updateImage(cocos2d::Ref *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-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeUnusedTextures();
|
2012-06-13 10:41:04 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
int tag = ((Node*)sender)->getTag();
|
2013-12-19 03:45:30 +08:00
|
|
|
std::string file;
|
2012-06-13 10:41:04 +08:00
|
|
|
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-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-07-12 14:11:55 +08:00
|
|
|
_background->setPosition(Point(s.width/2, s.height/2));
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureMemoryAlloc::title() const
|
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
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureMemoryAlloc::subtitle() const
|
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-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-02-28 14:54:09 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto background = LayerColor::create(Color4B(128,128,128,255), size.width, size.height);
|
2013-02-28 14:54:09 +08:00
|
|
|
addChild(background, -1);
|
|
|
|
|
|
|
|
|
|
|
|
// PVR premultiplied
|
2013-08-16 16:05:27 +08:00
|
|
|
auto pvr1 = Sprite::create("Images/grossinis_sister1-testalpha_premult.pvr");
|
2013-02-28 14:54:09 +08:00
|
|
|
addChild(pvr1, 0);
|
2013-07-12 14:11:55 +08:00
|
|
|
pvr1->setPosition(Point(size.width/4*1, size.height/2));
|
2013-02-28 14:54:09 +08:00
|
|
|
transformSprite(pvr1);
|
|
|
|
|
|
|
|
// PVR non-premultiplied
|
2013-08-16 16:05:27 +08:00
|
|
|
auto pvr2 = Sprite::create("Images/grossinis_sister1-testalpha_nopremult.pvr");
|
2013-02-28 14:54:09 +08:00
|
|
|
addChild(pvr2, 0);
|
2013-07-12 14:11:55 +08:00
|
|
|
pvr2->setPosition(Point(size.width/4*2, size.height/2));
|
2013-02-28 14:54:09 +08:00
|
|
|
transformSprite(pvr2);
|
|
|
|
|
|
|
|
// PNG
|
2013-07-26 04:36:19 +08:00
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
|
2013-08-16 16:05:27 +08:00
|
|
|
auto png = Sprite::create("Images/grossinis_sister1-testalpha.png");
|
2013-02-28 14:54:09 +08:00
|
|
|
addChild(png, 0);
|
2013-07-12 14:11:55 +08:00
|
|
|
png->setPosition(Point(size.width/4*3, size.height/2));
|
2013-02-28 14:54:09 +08:00
|
|
|
transformSprite(png);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRv3Premult::title() const
|
2013-02-28 14:54:09 +08:00
|
|
|
{
|
|
|
|
return "PVRv3 Premult Flag";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TexturePVRv3Premult::subtitle() const
|
2013-02-28 14:54:09 +08:00
|
|
|
{
|
|
|
|
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-22 11:02:43 +08:00
|
|
|
auto fade = FadeOut::create(2);
|
|
|
|
auto dl = DelayTime::create(2);
|
|
|
|
auto fadein = fade->reverse();
|
|
|
|
auto seq = Sequence::create(fade, fadein, dl, NULL);
|
|
|
|
auto 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();
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-05-27 14:42:22 +08:00
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
TextureETC1::TextureETC1()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create("Images/ETC1.pkm");
|
2013-05-27 14:42:22 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-07-12 14:11:55 +08:00
|
|
|
sprite->setPosition(Point(size.width/2, size.height/2));
|
2013-05-27 14:42:22 +08:00
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureETC1::title() const
|
2013-05-27 14:42:22 +08:00
|
|
|
{
|
|
|
|
return "ETC1 texture";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureETC1::subtitle() const
|
2013-05-27 14:42:22 +08:00
|
|
|
{
|
|
|
|
return "only supported on android";
|
|
|
|
}
|
2013-07-29 17:34:33 +08:00
|
|
|
|
2013-08-06 11:19:45 +08:00
|
|
|
//Implement of S3TC Dxt1
|
|
|
|
TextureS3TCDxt1::TextureS3TCDxt1()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt1_mipmaps.dds");
|
|
|
|
//auto sprite = Sprite::create("Images/water_2_dxt1.dds");
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-08-09 12:54:05 +08:00
|
|
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
2013-08-06 11:19:45 +08:00
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureS3TCDxt1::title() const
|
2013-08-06 11:19:45 +08:00
|
|
|
{
|
|
|
|
return "S3TC texture test#1";
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureS3TCDxt1::subtitle() const
|
2013-08-06 11:19:45 +08:00
|
|
|
{
|
2013-08-06 15:33:38 +08:00
|
|
|
return "S3TC dxt1 decode,one bit for Alpha";
|
2013-08-06 11:19:45 +08:00
|
|
|
}
|
2013-08-16 11:02:44 +08:00
|
|
|
|
2013-08-06 11:19:45 +08:00
|
|
|
//Implement of S3TC Dxt3
|
|
|
|
TextureS3TCDxt3::TextureS3TCDxt3()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt3_mipmaps.dds");
|
|
|
|
//auto sprite = Sprite::create("Images/water_2_dxt3.dds");
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-08-09 12:54:05 +08:00
|
|
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
2013-08-06 11:19:45 +08:00
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureS3TCDxt3::title() const
|
2013-08-06 11:19:45 +08:00
|
|
|
{
|
|
|
|
return "S3TC texture test#2";
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureS3TCDxt3::subtitle() const
|
2013-08-06 11:19:45 +08:00
|
|
|
{
|
|
|
|
return "S3TC dxt3 decode";
|
|
|
|
}
|
2013-08-16 11:02:44 +08:00
|
|
|
|
|
|
|
//Implement of S3TC Dxt5
|
2013-08-06 11:19:45 +08:00
|
|
|
TextureS3TCDxt5::TextureS3TCDxt5()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create("Images/test_256x256_s3tc_dxt5_mipmaps.dds");
|
|
|
|
//auto sprite = Sprite::create("Images/water_2_dxt5.dds");
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-08-09 12:54:05 +08:00
|
|
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
2013-08-06 11:19:45 +08:00
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureS3TCDxt5::title() const
|
2013-08-06 11:19:45 +08:00
|
|
|
{
|
|
|
|
return "S3TC texture test#3";
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureS3TCDxt5::subtitle() const
|
2013-08-06 11:19:45 +08:00
|
|
|
{
|
2013-08-16 11:02:44 +08:00
|
|
|
return "S3TC dxt5 decode";
|
|
|
|
}
|
|
|
|
|
2014-02-20 18:27:52 +08:00
|
|
|
//Implement of S3TC with no mipmaps
|
|
|
|
TextureS3TCWithNoMipmaps::TextureS3TCWithNoMipmaps()
|
|
|
|
{
|
|
|
|
auto sprite = Sprite::create("Images/test_512x512_s3tc_dxt5_with_no_mipmaps.dds");
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
|
|
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
|
|
|
std::string TextureS3TCWithNoMipmaps::title() const
|
|
|
|
{
|
|
|
|
return "S3TC with no mipmaps";
|
|
|
|
}
|
|
|
|
|
2013-08-16 11:02:44 +08:00
|
|
|
//Implement of ATITC
|
|
|
|
TextureATITCRGB::TextureATITCRGB()
|
|
|
|
{
|
2013-08-22 13:40:57 +08:00
|
|
|
auto sprite = Sprite::create("Images/test_256x256_ATC_RGB_mipmaps.ktx");
|
2013-08-06 11:19:45 +08:00
|
|
|
|
2013-08-22 13:40:57 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-08-16 11:02:44 +08:00
|
|
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureATITCRGB::title() const
|
2013-08-16 11:02:44 +08:00
|
|
|
{
|
|
|
|
return "ATITC texture (*.ktx file) test#1";
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureATITCRGB::subtitle() const
|
2013-08-16 11:02:44 +08:00
|
|
|
{
|
|
|
|
return "ATITC RGB (no Alpha channel) compressed texture test";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureATITCExplicit::TextureATITCExplicit()
|
|
|
|
{
|
2013-08-22 13:40:57 +08:00
|
|
|
auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Explicit_mipmaps.ktx");
|
2013-08-16 11:02:44 +08:00
|
|
|
|
2013-08-22 13:40:57 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-08-16 11:02:44 +08:00
|
|
|
sprite->setPosition(Point(size.width / 2, size.height / 2));
|
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureATITCExplicit::title() const
|
2013-08-16 11:02:44 +08:00
|
|
|
{
|
|
|
|
return "ATITC texture (*.ktx file) test#2";
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureATITCExplicit::subtitle() const
|
2013-08-16 11:02:44 +08:00
|
|
|
{
|
|
|
|
return "ATITC RGBA explicit Alpha compressed texture test";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureATITCInterpolated::TextureATITCInterpolated()
|
|
|
|
{
|
2013-08-22 13:40:57 +08:00
|
|
|
auto sprite = Sprite::create("Images/test_256x256_ATC_RGBA_Interpolated_mipmaps.ktx");
|
2013-08-16 11:02:44 +08:00
|
|
|
|
2013-08-22 13:40:57 +08:00
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-08-16 11:02:44 +08:00
|
|
|
sprite->setPosition(Point(size.width / 2, size.height /2));
|
|
|
|
|
|
|
|
addChild(sprite);
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureATITCInterpolated::title() const
|
2013-08-16 11:02:44 +08:00
|
|
|
{
|
|
|
|
return "ATITC texture (*.ktx file) test#3";
|
|
|
|
}
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureATITCInterpolated::subtitle() const
|
2013-08-16 11:02:44 +08:00
|
|
|
{
|
|
|
|
return "ATITC RGBA Interpolated Alpha comrpessed texture test";
|
2013-08-06 11:19:45 +08:00
|
|
|
}
|
2013-07-29 17:34:33 +08:00
|
|
|
|
|
|
|
static void addImageToDemo(TextureDemo& demo, float x, float y, const char* path, Texture2D::PixelFormat format)
|
|
|
|
{
|
|
|
|
Texture2D::setDefaultAlphaPixelFormat(format);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto sprite = Sprite::create(path);
|
2013-07-29 17:34:33 +08:00
|
|
|
sprite->setPosition(Point(x, y));
|
|
|
|
demo.addChild(sprite, 0);
|
|
|
|
|
2013-08-16 11:02:44 +08:00
|
|
|
//remove texture from texture manager
|
2013-11-07 21:48:39 +08:00
|
|
|
Director::getInstance()->getTextureCache()->removeTexture(sprite->getTexture());
|
2013-07-29 17:34:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//TextureConvertRGB888
|
|
|
|
void TextureConvertRGB888::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-07-29 17:34:33 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
|
2013-07-29 17:34:33 +08:00
|
|
|
addChild(background, -1);
|
|
|
|
|
|
|
|
const char* img = "Images/test_image_rgb888.png";
|
|
|
|
addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA8888);
|
|
|
|
addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB888);
|
|
|
|
addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGB565);
|
|
|
|
addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::A8);
|
|
|
|
addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::I8);
|
|
|
|
addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::AI88);
|
|
|
|
addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA4444);
|
|
|
|
addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB5A1);
|
|
|
|
|
|
|
|
// restore default
|
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2013-07-29 17:34:33 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertRGB888::title() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "RGB888 convert test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertRGB888::subtitle() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
|
|
|
|
}
|
|
|
|
//TextureConvertRGBA8888
|
|
|
|
void TextureConvertRGBA8888::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-07-29 17:34:33 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
|
2013-07-29 17:34:33 +08:00
|
|
|
addChild(background, -1);
|
|
|
|
|
|
|
|
const char* img = "Images/test_image_rgba8888.png";
|
|
|
|
addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA8888);
|
|
|
|
addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB888);
|
|
|
|
addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGB565);
|
|
|
|
addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::A8);
|
|
|
|
addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::I8);
|
|
|
|
addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::AI88);
|
|
|
|
addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA4444);
|
|
|
|
addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB5A1);
|
|
|
|
|
|
|
|
// restore default
|
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2013-07-29 17:34:33 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertRGBA8888::title() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "RGBA8888 convert test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertRGBA8888::subtitle() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
|
|
|
|
}
|
|
|
|
//TextureConvertI8
|
|
|
|
void TextureConvertI8::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-07-29 17:34:33 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
|
2013-07-29 17:34:33 +08:00
|
|
|
addChild(background, -1);
|
|
|
|
|
|
|
|
const char* img = "Images/test_image_i8.png";
|
|
|
|
addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA8888);
|
|
|
|
addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB888);
|
|
|
|
addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGB565);
|
|
|
|
addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::A8);
|
|
|
|
addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::I8);
|
|
|
|
addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::AI88);
|
|
|
|
addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA4444);
|
|
|
|
addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB5A1);
|
|
|
|
|
|
|
|
// restore default
|
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2013-07-29 17:34:33 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertI8::title() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "I8 convert test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertI8::subtitle() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
|
|
|
|
}
|
|
|
|
//TextureConvertAI88
|
|
|
|
void TextureConvertAI88::onEnter()
|
|
|
|
{
|
|
|
|
TextureDemo::onEnter();
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
2013-07-29 17:34:33 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto background = LayerColor::create(Color4B(255,0,0,255), s.width, s.height);
|
2013-07-29 17:34:33 +08:00
|
|
|
addChild(background, -1);
|
|
|
|
|
|
|
|
const char* img = "Images/test_image_ai88.png";
|
|
|
|
addImageToDemo(*this, 1*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA8888);
|
|
|
|
addImageToDemo(*this, 2*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB888);
|
|
|
|
addImageToDemo(*this, 3*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGB565);
|
|
|
|
addImageToDemo(*this, 4*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::A8);
|
|
|
|
addImageToDemo(*this, 5*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::I8);
|
|
|
|
addImageToDemo(*this, 6*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::AI88);
|
|
|
|
addImageToDemo(*this, 7*s.width/9, s.height/2+32, img, Texture2D::PixelFormat::RGBA4444);
|
|
|
|
addImageToDemo(*this, 8*s.width/9, s.height/2-32, img, Texture2D::PixelFormat::RGB5A1);
|
|
|
|
|
|
|
|
// restore default
|
|
|
|
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
2014-01-15 09:22:45 +08:00
|
|
|
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
|
2013-07-29 17:34:33 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertAI88::title() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "AI88 convert test";
|
|
|
|
}
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
std::string TextureConvertAI88::subtitle() const
|
2013-07-29 17:34:33 +08:00
|
|
|
{
|
|
|
|
return "RGBA8888,RGB888,RGB565,A8,I8,AI88,RGBA4444,RGB5A1";
|
|
|
|
}
|