diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk
index d4d54723ee..af7d5fa779 100644
--- a/cocos2dx/Android.mk
+++ b/cocos2dx/Android.mk
@@ -128,6 +128,7 @@ text_input_node/CCTextFieldTTF.cpp \
textures/CCTexture2D.cpp \
textures/CCTextureAtlas.cpp \
textures/CCTextureCache.cpp \
+textures/CCTextureETC.cpp \
textures/CCTexturePVR.cpp \
tilemap_parallax_nodes/CCParallaxNode.cpp \
tilemap_parallax_nodes/CCTMXLayer.cpp \
diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java
new file mode 100644
index 0000000000..a21cd23af2
--- /dev/null
+++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java
@@ -0,0 +1,104 @@
+/****************************************************************************
+Copyright (c) 2013 cocos2d-x.org
+
+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.
+ ****************************************************************************/
+package org.cocos2dx.lib;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.opengl.ETC1Util;
+import android.util.Log;
+
+public class Cocos2dxETCLoader {
+ private static final String ASSETS_PATH = "assets/";
+ private static Context context;
+
+ public static boolean loadTexture(String filePath) {
+ if (! ETC1Util.isETC1Supported()) {
+ return false;
+ }
+
+ if (filePath.length() == 0) {
+ return false;
+ }
+
+ // Create ETC1Texture
+ InputStream inputStream = null;
+ ETC1Util.ETC1Texture texture = null;
+ AssetManager assetManager = null;
+ try {
+ if (filePath.charAt(0) == '/') {
+ // absolute path
+ inputStream = new FileInputStream(filePath);
+ } else {
+ // remove prefix: "assets/"
+ if (filePath.startsWith(ASSETS_PATH)) {
+ filePath = filePath.substring(ASSETS_PATH.length());
+ }
+ assetManager = context.getAssets();
+ inputStream = assetManager.open(filePath);
+ }
+
+ texture = ETC1Util.createTexture(inputStream);
+ inputStream.close();
+ assetManager.close();
+ } catch (Exception e) {
+ Log.d("Cocos2dx", "Unable to create texture for " + filePath);
+
+ texture = null;
+ }
+
+ if (texture != null) {
+ try {
+ int width = texture.getWidth();
+ int height = texture.getHeight();
+
+ final byte[] data = new byte[width * height * 3];
+ final ByteBuffer buf = ByteBuffer.wrap(data);
+ buf.order(ByteOrder.nativeOrder());
+ buf.put(texture.getData());
+
+ nativeSetTextureInfo(width,
+ height,
+ data);
+ } catch (Exception e)
+ {
+ Log.d("invoke native function error", e.toString());
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static void setContext(Context context) {
+ Cocos2dxETCLoader.context = context;
+ }
+
+ private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data);
+}
diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java
index 14cad86662..f4459f5e44 100644
--- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java
+++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java
@@ -75,6 +75,7 @@ public class Cocos2dxHelper {
Cocos2dxHelper.sCocos2dSound = new Cocos2dxSound(pContext);
Cocos2dxHelper.sAssetManager = pContext.getAssets();
Cocos2dxBitmap.setContext(pContext);
+ Cocos2dxETCLoader.setContext(pContext);
}
// ===========================================================
diff --git a/cocos2dx/proj.emscripten/Makefile b/cocos2dx/proj.emscripten/Makefile
index 3c83b1350e..62502c2459 100644
--- a/cocos2dx/proj.emscripten/Makefile
+++ b/cocos2dx/proj.emscripten/Makefile
@@ -102,6 +102,7 @@ SOURCES = ../actions/CCAction.cpp \
../textures/CCTexture2D.cpp \
../textures/CCTextureAtlas.cpp \
../textures/CCTextureCache.cpp \
+../textures/CCTextureETC.cpp \
../textures/CCTexturePVR.cpp \
../tilemap_parallax_nodes/CCParallaxNode.cpp \
../tilemap_parallax_nodes/CCTMXLayer.cpp \
diff --git a/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
index c5f3e0dc2b..1099eb9a53 100644
--- a/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
+++ b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
@@ -1 +1 @@
-89741f647de6b40616d5c45625fcd3c2d8e9d20a
\ No newline at end of file
+3a74fba6589c007b54123dfc2d385ab7d3d81919
\ No newline at end of file
diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile
index b383c293a4..597cba12e0 100644
--- a/cocos2dx/proj.linux/Makefile
+++ b/cocos2dx/proj.linux/Makefile
@@ -99,6 +99,7 @@ SOURCES = ../actions/CCAction.cpp \
../textures/CCTexture2D.cpp \
../textures/CCTextureAtlas.cpp \
../textures/CCTextureCache.cpp \
+../textures/CCTextureETC.cpp \
../textures/CCTexturePVR.cpp \
../tilemap_parallax_nodes/CCParallaxNode.cpp \
../tilemap_parallax_nodes/CCTMXLayer.cpp \
diff --git a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
index b4c415dff2..61ebce90d4 100644
--- a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
+++ b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id
@@ -1 +1 @@
-703f1f571cf577296708f26a90de6288773b8db5
\ No newline at end of file
+e0a8a8e12824edeb721e51ab7c9126db055e39c4
\ No newline at end of file
diff --git a/cocos2dx/proj.nacl/Makefile b/cocos2dx/proj.nacl/Makefile
index 5cfc61b5c2..f058135b7b 100644
--- a/cocos2dx/proj.nacl/Makefile
+++ b/cocos2dx/proj.nacl/Makefile
@@ -99,6 +99,7 @@ SOURCES = ../actions/CCAction.cpp \
../textures/CCTexture2D.cpp \
../textures/CCTextureAtlas.cpp \
../textures/CCTextureCache.cpp \
+../textures/CCTextureETC.cpp \
../textures/CCTexturePVR.cpp \
../tilemap_parallax_nodes/CCParallaxNode.cpp \
../tilemap_parallax_nodes/CCTMXLayer.cpp \
diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj
index 87a9f97ea6..8f64536817 100644
--- a/cocos2dx/proj.win32/cocos2d.vcxproj
+++ b/cocos2dx/proj.win32/cocos2d.vcxproj
@@ -230,6 +230,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
+
@@ -389,6 +390,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
+
diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj.filters b/cocos2dx/proj.win32/cocos2d.vcxproj.filters
index f4b3988e83..44049e5aa6 100644
--- a/cocos2dx/proj.win32/cocos2d.vcxproj.filters
+++ b/cocos2dx/proj.win32/cocos2d.vcxproj.filters
@@ -1,4 +1,4 @@
-
+
@@ -462,6 +462,9 @@
cocoa
+
+ textures
+
@@ -930,6 +933,8 @@
cocoa
-
+
+ textures
+
\ No newline at end of file
diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp
index 894332948d..f9e45965ff 100644
--- a/cocos2dx/textures/CCTexture2D.cpp
+++ b/cocos2dx/textures/CCTexture2D.cpp
@@ -40,6 +40,7 @@ THE SOFTWARE.
#include "support/ccUtils.h"
#include "platform/CCPlatformMacros.h"
#include "textures/CCTexturePVR.h"
+#include "textures/CCTextureETC.h"
#include "CCDirector.h"
#include "shaders/CCGLProgram.h"
#include "shaders/ccGLStateCache.h"
@@ -722,6 +723,34 @@ bool CCTexture2D::initWithPVRFile(const char* file)
return bRet;
}
+bool CCTexture2D::initWithETCFile(const char* file)
+{
+ bool bRet = false;
+ // nothing to do with CCObject::init
+
+ CCTextureETC *etc = new CCTextureETC;
+ bRet = etc->initWithFile(file);
+
+ if (bRet)
+ {
+ m_uName = etc->getName();
+ m_fMaxS = 1.0f;
+ m_fMaxT = 1.0f;
+ m_uPixelsWide = etc->getWidth();
+ m_uPixelsHigh = etc->getHeight();
+ m_tContentSize = CCSizeMake((float)m_uPixelsWide, (float)m_uPixelsHigh);
+ m_bHasPremultipliedAlpha = true;
+
+ etc->release();
+ }
+ else
+ {
+ CCLOG("cocos2d: Couldn't load ETC image %s", file);
+ }
+
+ return bRet;
+}
+
void CCTexture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied)
{
PVRHaveAlphaPremultiplied_ = haveAlphaPremultiplied;
diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h
index 0a09397519..133ff9a887 100644
--- a/cocos2dx/textures/CCTexture2D.h
+++ b/cocos2dx/textures/CCTexture2D.h
@@ -150,6 +150,9 @@ public:
/** Initializes a texture from a PVR file */
bool initWithPVRFile(const char* file);
+
+ /** Initializes a texture from a ETC file */
+ bool initWithETCFile(const char* file);
/** sets the min filter, mag filter, wrap s and wrap t texture parameters.
If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp
index 8bbd1a3a75..a70d6e47bc 100644
--- a/cocos2dx/textures/CCTextureCache.cpp
+++ b/cocos2dx/textures/CCTextureCache.cpp
@@ -399,6 +399,11 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
{
texture = this->addPVRImage(fullpath.c_str());
}
+ else if (std::string::npos != lowerCase.find(".pkm"))
+ {
+ // ETC1 file format, only supportted on Android
+ texture = this->addETCImage(fullpath.c_str());
+ }
else
{
CCImage::EImageFormat eImageFormat = CCImage::kFmtUnKnown;
@@ -484,6 +489,35 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path)
return texture;
}
+CCTexture2D* CCTextureCache::addETCImage(const char* path)
+{
+ CCAssert(path != NULL, "TextureCache: fileimage MUST not be nil");
+
+ CCTexture2D* texture = NULL;
+ std::string key(path);
+
+ if( (texture = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) )
+ {
+ return texture;
+ }
+
+ // Split up directory and filename
+ std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathForFilename(key.c_str());
+ texture = new CCTexture2D();
+ if(texture != NULL && texture->initWithETCFile(fullpath.c_str()))
+ {
+ m_pTextures->setObject(texture, key.c_str());
+ texture->autorelease();
+ }
+ else
+ {
+ CCLOG("cocos2d: Couldn't add ETCImage:%s in CCTextureCache",key.c_str());
+ CC_SAFE_DELETE(texture);
+ }
+
+ return texture;
+}
+
CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
{
CCAssert(image != NULL, "TextureCache: image MUST not be nil");
diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h
index 51bcc84900..209796653d 100644
--- a/cocos2dx/textures/CCTextureCache.h
+++ b/cocos2dx/textures/CCTextureCache.h
@@ -154,6 +154,12 @@ public:
* object and it will return it. Otherwise it will return a reference of a previously loaded image
*/
CCTexture2D* addPVRImage(const char* filename);
+
+ /** Returns a Texture2D object given an ETC filename
+ * If the file image was not previously loaded, it will create a new CCTexture2D
+ * object and it will return it. Otherwise it will return a reference of a previously loaded image
+ */
+ CCTexture2D* addETCImage(const char* filename);
/** Reload all textures
It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1
diff --git a/cocos2dx/textures/CCTextureETC.cpp b/cocos2dx/textures/CCTextureETC.cpp
new file mode 100644
index 0000000000..a6189aa19b
--- /dev/null
+++ b/cocos2dx/textures/CCTextureETC.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+ Copyright (c) 2013 cocos2d-x.org
+
+ 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.
+ ****************************************************************************/
+
+#include "CCTextureETC.h"
+#include "platform/CCPlatformConfig.h"
+#include "platform/CCFileUtils.h"
+
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
+#include "platform/android/jni/JniHelper.h"
+#endif
+
+
+NS_CC_BEGIN
+
+CCTextureETC::CCTextureETC()
+: _name(0)
+, _width(0)
+, _height(0)
+{}
+
+CCTextureETC::~CCTextureETC()
+{
+}
+
+bool CCTextureETC::initWithFile(const char *file)
+{
+ // Only Android supports ETC file format
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
+ bool ret = loadTexture(CCFileUtils::sharedFileUtils()->fullPathForFilename(file).c_str());
+ return ret;
+#else
+ return false;
+#endif
+}
+
+unsigned int CCTextureETC::getName() const
+{
+ return _name;
+}
+
+unsigned int CCTextureETC::getWidth() const
+{
+ return _width;
+}
+
+unsigned int CCTextureETC::getHeight() const
+{
+ return _height;
+}
+
+// Call back function for java
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
+#define LOG_TAG "CCTextureETC.cpp"
+#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
+
+static unsigned int sWidth = 0;
+static unsigned int sHeight = 0;
+static unsigned char *sData = NULL;
+static unsigned int sLength = 0;
+
+extern "C"
+{
+ JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray data)
+ {
+ sWidth = (unsigned int)width;
+ sHeight = (unsigned int)height;
+ sLength = sWidth * sHeight * 3;
+ sData = new unsigned char[sLength];
+ env->GetByteArrayRegion(data, 0, sLength, (jbyte*)sData);
+ }
+}
+#endif
+
+bool CCTextureETC::loadTexture(const char* file)
+{
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
+ JniMethodInfo t;
+ if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxETCLoader", "loadTexture", "(Ljava/lang/String;)Z"))
+ {
+ jstring stringArg1 = t.env->NewStringUTF(file);
+ jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, stringArg1);
+
+ t.env->DeleteLocalRef(stringArg1);
+ t.env->DeleteLocalRef(t.classID);
+
+ if (ret)
+ {
+ _width = sWidth;
+ _height = sHeight;
+
+
+ glGenTextures(1, &_name);
+ glBindTexture(GL_TEXTURE_2D, _name);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_ETC1_RGB8_OES, _width, _height, 0, sLength, sData);
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+
+ delete [] sData;
+ sData = NULL;
+
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR)
+ {
+ LOGD("width %d, height %d, lenght %d", _width, _height, sLength);
+ LOGD("cocos2d: TextureETC: Error uploading compressed texture %s glError: 0x%04X", file, err);
+ return false;
+ }
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+#else
+ return false;
+#endif
+}
+
+NS_CC_END
diff --git a/cocos2dx/textures/CCTextureETC.h b/cocos2dx/textures/CCTextureETC.h
new file mode 100644
index 0000000000..69b0211c7c
--- /dev/null
+++ b/cocos2dx/textures/CCTextureETC.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+ Copyright (c) 2013 cocos2d-x.org
+
+ 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.
+ ****************************************************************************/
+
+#ifndef __CCETCTEXTURE_H__
+#define __CCETCTEXTURE_H__
+
+#include "cocoa/CCObject.h"
+#include "platform/CCPlatformMacros.h"
+#include "CCGL.h"
+
+NS_CC_BEGIN
+
+class CC_DLL CCTextureETC : public CCObject
+{
+public:
+ CCTextureETC();
+ virtual ~CCTextureETC();
+
+ bool initWithFile(const char* file);
+
+ unsigned int getName() const;
+ unsigned int getWidth() const;
+ unsigned int getHeight() const;
+
+private:
+ bool loadTexture(const char* file);
+
+private:
+ GLuint _name;
+ unsigned int _width;
+ unsigned int _height;
+};
+
+NS_CC_END
+
+#endif /* defined(__CCETCTEXTURE_H__) */
diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp
index 4173e5d6c7..bba47cb0eb 100644
--- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp
+++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp
@@ -66,6 +66,8 @@ TESTLAYER_CREATE_FUNC(TextureCache1);
TESTLAYER_CREATE_FUNC(TextureDrawAtPoint);
TESTLAYER_CREATE_FUNC(TextureDrawInRect);
+TESTLAYER_CREATE_FUNC(TextureETC1);
+
static NEWTEXTURE2DTESTFUNC createFunctions[] =
{
createTextureMemoryAlloc,
@@ -118,6 +120,8 @@ static NEWTEXTURE2DTESTFUNC createFunctions[] =
createTextureCache1,
createTextureDrawAtPoint,
createTextureDrawInRect,
+
+ createTextureETC1,
};
static unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFunctions[0]);
@@ -2050,3 +2054,38 @@ void TexturePVRv3Premult::transformSprite(cocos2d::CCSprite *sprite)
CCRepeatForever *repeat = CCRepeatForever::create(seq);
sprite->runAction(repeat);
}
+
+// Implementation of ETC1
+
+/*
+class TextureETC1 : public TextureDemo
+{
+public:
+ TextureETC1();
+
+ virtual std::string title();
+ virtual std::string subtitle();
+};
+ */
+
+TextureETC1::TextureETC1()
+{
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
+ CCSprite *sprite = CCSprite::create("Images/ETC1.pkm");
+
+ CCSize size = CCDirector::sharedDirector()->getWinSize();
+ sprite->setPosition(ccp(size.width/2, size.height/2));
+
+ addChild(sprite);
+#endif
+}
+
+std::string TextureETC1::title()
+{
+ return "ETC1 texture";
+}
+
+std::string TextureETC1::subtitle()
+{
+ return "only supported on android";
+}
diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h
index 9b671237be..d237ea58a3 100644
--- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h
+++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h
@@ -442,4 +442,14 @@ public:
void transformSprite(cocos2d::CCSprite *sprite);
};
+// ETC1 texture format test
+class TextureETC1 : public TextureDemo
+{
+public:
+ TextureETC1();
+
+ virtual std::string title();
+ virtual std::string subtitle();
+};
+
#endif // __TEXTURE2D_TEST_H__