mirror of https://github.com/axmolengine/axmol.git
fixed #621, Add Texture2dTest in tests project.
This commit is contained in:
parent
d2b44a203f
commit
6a8b563feb
|
@ -186,7 +186,7 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor
|
|||
case kCCTexture2DPixelFormat_A8:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
default:;
|
||||
default:
|
||||
CCAssert(0, "NSInternalInconsistencyException");
|
||||
|
||||
}
|
||||
|
@ -566,16 +566,14 @@ bool CCTexture2D::initWithPVRFile(const char* file)
|
|||
m_ePixelFormat = pvr->getFormat();
|
||||
|
||||
this->setAntiAliasTexParameters();
|
||||
pvr->release();
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("cocos2d: Couldn't load PVR image %s", file);
|
||||
}
|
||||
|
||||
pvr->release();
|
||||
|
||||
return bRet;
|
||||
|
||||
}
|
||||
|
||||
void CCTexture2D::setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
|
||||
|
@ -669,6 +667,9 @@ unsigned int CCTexture2D::bitsPerPixelForFormat()
|
|||
case kCCTexture2DPixelFormat_AI88:
|
||||
ret = 16;
|
||||
break;
|
||||
case kCCTexture2DPixelFormat_RGB888:
|
||||
ret = 24;
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
assert(false);
|
||||
|
|
|
@ -476,7 +476,7 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path)
|
|||
}
|
||||
else
|
||||
{
|
||||
pvrdata = CCFileUtils::getFileData(path, "r", (unsigned long *)(&pvrlen));
|
||||
pvrdata = CCFileUtils::getFileData(path, "rb", (unsigned long *)(&pvrlen));
|
||||
}
|
||||
|
||||
if (pvrlen < 0)
|
||||
|
@ -495,12 +495,12 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path)
|
|||
|
||||
if ( !unpackPVRData(pvrdata, pvrlen) || !createGLTexture() )
|
||||
{
|
||||
free(pvrdata);
|
||||
delete [] pvrdata;
|
||||
this->release();
|
||||
return false;
|
||||
}
|
||||
|
||||
free(pvrdata);
|
||||
delete [] pvrdata;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -191,6 +191,11 @@ files
|
|||
"*.h"
|
||||
"*.cpp"
|
||||
|
||||
[Tests/Texture2dTest]
|
||||
("../tests/Texture2dTest")
|
||||
"*.h"
|
||||
"*.cpp"
|
||||
|
||||
[Tests/TileMapTest]
|
||||
("../tests/TileMapTest")
|
||||
"*.h"
|
||||
|
|
|
@ -74,6 +74,7 @@ LOCAL_SRC_FILES := main.cpp \
|
|||
../../../tests/SceneTest/SceneTest.cpp \
|
||||
../../../tests/SchedulerTest/SchedulerTest.cpp \
|
||||
../../../tests/SpriteTest/SpriteTest.cpp \
|
||||
../../../tests/Texture2dTest/Texture2dTest.cpp \
|
||||
../../../tests/TileMapTest/TileMapTest.cpp \
|
||||
../../../tests/TouchesTest/Ball.cpp \
|
||||
../../../tests/TouchesTest/Paddle.cpp \
|
||||
|
|
|
@ -1 +1 @@
|
|||
ee629ad852ffaadaaf47f1d39c96f7daf670f9be
|
||||
898c0f4be35b091c881554d3a75aafca0788707a
|
|
@ -1071,6 +1071,18 @@
|
|||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Texture2dTest"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\tests\Texture2dTest\Texture2dTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\tests\Texture2dTest\Texture2dTest.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
|
|
|
@ -112,6 +112,7 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/SchedulerTest.o \
|
||||
$(OBJECTS_DIR)/SpriteTest.o \
|
||||
$(OBJECTS_DIR)/TextInputTest.o \
|
||||
$(OBJECTS_DIR)/Texture2dTest.o \
|
||||
$(OBJECTS_DIR)/TileMapTest.o \
|
||||
$(OBJECTS_DIR)/Ball.o \
|
||||
$(OBJECTS_DIR)/Paddle.o \
|
||||
|
@ -365,6 +366,9 @@ $(OBJECTS_DIR)/SpriteTest.o : ../tests/SpriteTest/SpriteTest.cpp
|
|||
$(OBJECTS_DIR)/TextInputTest.o : ../tests/TextInputTest/TextInputTest.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/TextInputTest.o ../tests/TextInputTest/TextInputTest.cpp
|
||||
|
||||
$(OBJECTS_DIR)/Texture2dTest.o : ../tests/Texture2dTest/Texture2dTest.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/Texture2dTest.o ../tests/Texture2dTest/Texture2dTest.cpp
|
||||
|
||||
$(OBJECTS_DIR)/TileMapTest.o : ../tests/TileMapTest/TileMapTest.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/TileMapTest.o ../tests/TileMapTest/TileMapTest.cpp
|
||||
|
||||
|
|
|
@ -1078,6 +1078,18 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Texture2dTest"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\tests\Texture2dTest\Texture2dTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\tests\Texture2dTest\Texture2dTest.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,266 @@
|
|||
#ifndef __TEXTURE2D_TEST_H__
|
||||
#define __TEXTURE2D_TEST_H__
|
||||
|
||||
#include "../testBasic.h"
|
||||
|
||||
class TextureDemo : public CCLayer
|
||||
{
|
||||
public:
|
||||
virtual ~TextureDemo();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
|
||||
void restartCallback(CCObject* pSender);
|
||||
void nextCallback(CCObject* pSender);
|
||||
void backCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class TexturePNG : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureJPEG : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureMipMap : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVR : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVR2BPP : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVR4BPP : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRRGBA8888 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRBGRA8888 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRRGBA4444 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRRGBA4444GZ : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRRGBA4444CCZ : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRRGBA5551 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRRGB565 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRA8 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRI8 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRAI88 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRBadEncoding : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRMipMap : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRMipMap2 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRNonSquare : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRNPOT4444 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRNPOT8888 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePVRRaw : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureAlias : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePixelFormat : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureBlend : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureGlRepeat : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual ~TextureGlRepeat();
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureGlClamp : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual ~TextureGlClamp();
|
||||
virtual std::string title();
|
||||
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureSizeTest : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureCache1 : public TextureDemo
|
||||
{
|
||||
public:
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TextureTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
#endif // __TEXTURE2D_TEST_H__
|
|
@ -74,6 +74,8 @@ static TestScene* CreateTestScene(int nIdx)
|
|||
pScene = new SchedulerTestScene(); break;
|
||||
case TEST_RENDERTEXTURE:
|
||||
pScene = new RenderTextureScene(); break;
|
||||
case TEST_TEXTURE2D:
|
||||
pScene = new TextureTestScene(); break;
|
||||
case TEST_BOX2D:
|
||||
pScene = new Box2DTestScene(); break;
|
||||
case TEST_BOX2DBED:
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "UserDefaultTest/UserDefaultTest.h"
|
||||
#include "DirectorTest/DirectorTest.h"
|
||||
#include "BugsTest/BugsTest.h"
|
||||
#include "Texture2dTest/Texture2dTest.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY)
|
||||
#include "ChipmunkTest/cocos2dChipmunkDemo.h"
|
||||
|
@ -79,6 +80,7 @@ enum
|
|||
TEST_SPRITE,
|
||||
TEST_SCHEDULER,
|
||||
TEST_RENDERTEXTURE,
|
||||
TEST_TEXTURE2D,
|
||||
TEST_BOX2D,
|
||||
TEST_BOX2DBED,
|
||||
TEST_EFFECT_ADVANCE,
|
||||
|
@ -122,6 +124,7 @@ const std::string g_aTestNames[TESTS_COUNT] = {
|
|||
"SpriteTest",
|
||||
"SchdulerTest",
|
||||
"RenderTextureTest",
|
||||
"Texture2DTest",
|
||||
"Box2dTest",
|
||||
"Box2dTestBed",
|
||||
"EffectAdvancedTest",
|
||||
|
|
Loading…
Reference in New Issue