From 5fd56370d80bc58294dfb6325fb752ff2c164939 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 13 Nov 2012 11:06:32 +0800 Subject: [PATCH] issue #1555:fix a bug about CCGLProgram --- cocos2dx/CCDirector.cpp | 91 ++++++++++++------- cocos2dx/CCDirector.h | 8 +- cocos2dx/include/ccMacros.h | 4 +- cocos2dx/include/cocos2d.h | 2 +- cocos2dx/physics_nodes/CCPhysicsDebugNode.cpp | 33 ------- cocos2dx/physics_nodes/CCPhysicsDebugNode.h | 6 -- cocos2dx/physics_nodes/CCPhysicsSprite.cpp | 27 ------ cocos2dx/physics_nodes/CCPhysicsSprite.h | 7 -- cocos2dx/platform/ios/CCES2Renderer.m | 4 + cocos2dx/shaders/CCGLProgram.cpp | 19 ++-- cocos2dx/shaders/CCGLProgram.h | 2 +- cocos2dx/shaders/CCShaderCache.cpp | 29 +++++- cocos2dx/shaders/ccGLStateCache.cpp | 33 ++++--- cocos2dx/shaders/ccGLStateCache.h | 20 ++-- ...ccShader_PositionColorLengthTexture_frag.h | 41 +++++++++ ...ccShader_PositionColorLengthTexture_vert.h | 47 ++++++++++ .../shaders/ccShader_PositionColor_frag.h | 47 +++++++--- .../shaders/ccShader_PositionColor_vert.h | 55 +++++++---- .../ccShader_PositionTextureA8Color_frag.h | 55 ++++++++--- .../ccShader_PositionTextureA8Color_vert.h | 64 +++++++++---- ...hader_PositionTextureColorAlphaTest_frag.h | 68 +++++++++----- .../ccShader_PositionTextureColor_frag.h | 51 ++++++++--- .../ccShader_PositionTextureColor_vert.h | 65 ++++++++----- .../shaders/ccShader_PositionTexture_frag.h | 49 +++++++--- .../ccShader_PositionTexture_uColor_frag.h | 55 ++++++++--- .../ccShader_PositionTexture_uColor_vert.h | 57 ++++++++---- .../shaders/ccShader_PositionTexture_vert.h | 56 ++++++++---- .../shaders/ccShader_Position_uColor_frag.h | 47 +++++++--- .../shaders/ccShader_Position_uColor_vert.h | 60 ++++++++---- cocos2dx/shaders/ccShaders.cpp | 5 + cocos2dx/shaders/ccShaders.h | 3 + 31 files changed, 756 insertions(+), 354 deletions(-) create mode 100644 cocos2dx/shaders/ccShader_PositionColorLengthTexture_frag.h create mode 100644 cocos2dx/shaders/ccShader_PositionColorLengthTexture_vert.h diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index d06204dd55..31b7be83d8 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -390,7 +390,10 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) void CCDirector::purgeCachedData(void) { CCLabelBMFont::purgeCachedData(); - CCTextureCache::sharedTextureCache()->removeUnusedTextures(); + if (s_SharedDirector->getOpenGLView()) + { + CCTextureCache::sharedTextureCache()->removeUnusedTextures(); + } CCFileUtils::sharedFileUtils()->purgeCachedEntries(); } @@ -407,7 +410,7 @@ void CCDirector::setAlphaBlending(bool bOn) } else { - glDisable(GL_BLEND); + ccGLBlendFunc(GL_ONE, GL_ZERO); } CHECK_GL_ERROR_DEBUG(); @@ -429,20 +432,50 @@ void CCDirector::setDepthTest(bool bOn) CHECK_GL_ERROR_DEBUG(); } +static void +GLToClipTransform(kmMat4 *transformOut) +{ + kmMat4 projection; + kmGLGetMatrix(KM_GL_PROJECTION, &projection); + + kmMat4 modelview; + kmGLGetMatrix(KM_GL_MODELVIEW, &modelview); + + kmMat4Multiply(transformOut, &projection, &modelview); +} + CCPoint CCDirector::convertToGL(const CCPoint& uiPoint) { - CCSize s = m_obWinSizeInPoints; - float newY = s.height - uiPoint.y; - - return ccp(uiPoint.x, newY); + kmMat4 transform; + GLToClipTransform(&transform); + + kmMat4 transformInv; + kmMat4Inverse(&transformInv, &transform); + + // Calculate z=0 using -> transform*[0, 0, 0, 1]/w + kmScalar zClip = transform.mat[14]/transform.mat[15]; + + CCSize glSize = m_pobOpenGLView->getFrameSize(); + kmVec3 clipCoord = {2.0*uiPoint.x/glSize.width - 1.0, 1.0 - 2.0*uiPoint.y/glSize.height, zClip}; + + kmVec3 glCoord; + kmVec3TransformCoord(&glCoord, &clipCoord, &transformInv); + + return ccp(glCoord.x, glCoord.y); } CCPoint CCDirector::convertToUI(const CCPoint& glPoint) { - CCSize winSize = m_obWinSizeInPoints; - float oppositeY = winSize.height - glPoint.y; + kmMat4 transform; + GLToClipTransform(&transform); - return ccp(glPoint.x, oppositeY); + kmVec3 clipCoord; + // Need to calculate the zero depth from the transform. + kmVec3 glCoord = {glPoint.x, glPoint.y, 0.0}; + kmVec3TransformCoord(&clipCoord, &glCoord, &transform); + + CCSize glSize = m_pobOpenGLView->getFrameSize(); + return ccp(glSize.width*(clipCoord.x*0.5 + 0.5), glSize.height*(-clipCoord.y*0.5 + 0.5)); } CCSize CCDirector::getWinSize(void) @@ -483,7 +516,7 @@ CCPoint CCDirector::getVisibleOrigin() void CCDirector::runWithScene(CCScene *pScene) { - CCAssert(pScene != NULL, "running scene should not be null"); + CCAssert(pScene != NULL, "This command can only be used to start the CCDirector. There is already a scene present."); CCAssert(m_pRunningScene == NULL, "m_pRunningScene should be null"); pushScene(pScene); @@ -492,6 +525,7 @@ void CCDirector::runWithScene(CCScene *pScene) void CCDirector::replaceScene(CCScene *pScene) { + CCAssert(m_pRunningScene, "Use runWithScene: instead to start the director"); CCAssert(pScene != NULL, "the scene should not be null"); unsigned int index = m_pobScenesStack->count(); @@ -547,6 +581,7 @@ void CCDirector::popToRootScene(void) CCScene *current = (CCScene*)m_pobScenesStack->lastObject(); if( current->isRunning() ) { + current->onExitTransitionDidStart(); current->onExit(); } current->cleanup(); @@ -575,6 +610,7 @@ void CCDirector::purgeDirector() if (m_pRunningScene) { + m_pRunningScene->onExitTransitionDidStart(); m_pRunningScene->onExit(); m_pRunningScene->cleanup(); m_pRunningScene->release(); @@ -593,9 +629,6 @@ void CCDirector::purgeDirector() CC_SAFE_RELEASE_NULL(m_pSPFLabel); CC_SAFE_RELEASE_NULL(m_pDrawsLabel); - CCObject* pProjectionDelegate = (CCObject*)m_pProjectionDelegate; - CC_SAFE_RELEASE_NULL(pProjectionDelegate); - // purge bitmap cache CCLabelBMFont::purgeCachedData(); @@ -633,6 +666,7 @@ void CCDirector::setNextScene(void) { if (m_pRunningScene) { + m_pRunningScene->onExitTransitionDidStart(); m_pRunningScene->onExit(); } @@ -739,26 +773,13 @@ void CCDirector::createStatsLabel() { if( m_pFPSLabel && m_pSPFLabel ) { - //CCTexture2D *texture = m_pFPSLabel->getTexture(); - CC_SAFE_RELEASE_NULL(m_pFPSLabel); CC_SAFE_RELEASE_NULL(m_pSPFLabel); CC_SAFE_RELEASE_NULL(m_pDrawsLabel); - // CCTextureCache::sharedTextureCache()->removeTexture(texture); CCFileUtils::sharedFileUtils()->purgeCachedEntries(); } - /* - CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat(); - CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); - m_pFPSLabel = new CCLabelAtlas(); - m_pFPSLabel->initWithString("00.0", "fps_images.png", 12, 32, '.'); - m_pSPFLabel = new CCLabelAtlas(); - m_pSPFLabel->initWithString("0.000", "fps_images.png", 12, 32, '.'); - m_pDrawsLabel = new CCLabelAtlas(); - m_pDrawsLabel->initWithString("000", "fps_images.png", 12, 32, '.'); - */ int fontSize = 0; if (m_obWinSizeInPoints.width > m_obWinSizeInPoints.height) { @@ -776,9 +797,6 @@ void CCDirector::createStatsLabel() m_pDrawsLabel = CCLabelTTF::create("000", "Arial", fontSize); m_pDrawsLabel->retain(); - //CCTexture2D::setDefaultAlphaPixelFormat(currentFormat); - - CCSize contentSize = m_pDrawsLabel->getContentSize(); m_pDrawsLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height*5/2), CC_DIRECTOR_STATS_POSITION)); contentSize = m_pSPFLabel->getContentSize(); @@ -787,11 +805,6 @@ void CCDirector::createStatsLabel() m_pFPSLabel->setPosition(ccpAdd(ccp(contentSize.width/2, contentSize.height/2), CC_DIRECTOR_STATS_POSITION)); } - -/*************************************************** -* mobile platforms specific functions -**************************************************/ - float CCDirector::getContentScaleFactor(void) { return m_fContentScaleFactor; @@ -818,6 +831,16 @@ void CCDirector::setNotificationNode(CCNode *node) CC_SAFE_RETAIN(m_pNotificationNode); } +CCDirectorDelegate* CCDirector::getDelegate() const +{ + return m_pProjectionDelegate; +} + +void CCDirector::setDelegate(CCDirectorDelegate* pDelegate) +{ + m_pProjectionDelegate = pDelegate; +} + void CCDirector::setScheduler(CCScheduler* pScheduler) { if (m_pScheduler != pScheduler) diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 1005003c77..b24670690b 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -159,6 +159,12 @@ public: */ CCNode* getNotificationNode(); void setNotificationNode(CCNode *node); + + /** CCDirector delegate. It shall implemente the CCDirectorDelegate protocol + @since v0.99.5 + */ + CCDirectorDelegate* getDelegate() const; + void setDelegate(CCDirectorDelegate* pDelegate); // window size @@ -181,7 +187,7 @@ public: CCPoint getVisibleOrigin(); /** converts a UIKit coordinate to an OpenGL coordinate - Useful to convert (multi) touches coordinates to the current layout (portrait or landscape) + Useful to convert (multi) touch coordinates to the current layout (portrait or landscape) */ CCPoint convertToGL(const CCPoint& obPoint); diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index 991c7f6ef5..f0acb25538 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -69,7 +69,7 @@ simple macro that swaps 2 variables */ #define CC_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) * 57.29577951f) // PI * 180 -#define kCCRepeatForever UINT_MAX -1 +#define kCCRepeatForever (UINT_MAX -1) /** @def CC_BLEND_SRC default gl blend src function. Compatible with premultiplied alpha images. @@ -84,7 +84,7 @@ default gl blend src function. Compatible with premultiplied alpha images. */ #define CC_NODE_DRAW_SETUP() \ do { \ - ccGLEnable( m_glServerState ); \ + ccGLEnable(m_glServerState); \ CCAssert(getShaderProgram(), "No shader program set for this node"); \ { \ getShaderProgram()->use(); \ diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index 588dc0eb20..ce7ece7e30 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -241,7 +241,7 @@ THE SOFTWARE. #include "CCCamera.h" #include "CCConfiguration.h" #include "CCDirector.h" -#include "CCDrawingPrimitives.h" +#include "draw_nodes/CCDrawingPrimitives.h" #include "CCScheduler.h" NS_CC_BEGIN diff --git a/cocos2dx/physics_nodes/CCPhysicsDebugNode.cpp b/cocos2dx/physics_nodes/CCPhysicsDebugNode.cpp index 925323939c..21fa97ca44 100644 --- a/cocos2dx/physics_nodes/CCPhysicsDebugNode.cpp +++ b/cocos2dx/physics_nodes/CCPhysicsDebugNode.cpp @@ -167,15 +167,6 @@ static void DrawConstraint(cpConstraint *constraint, CCDrawNode *renderer) } } -class ChipmunkSpace : public CCObject -{ -public: - cpSpace* getSapce() const - { - return NULL; - } -}; - // implementation of CCPhysicsDebugNode void CCPhysicsDebugNode::draw() @@ -194,31 +185,8 @@ void CCPhysicsDebugNode::draw() CCPhysicsDebugNode::CCPhysicsDebugNode() : m_pSpacePtr(NULL) -, m_pSpaceObj(NULL) {} -CCPhysicsDebugNode* CCPhysicsDebugNode::create(ChipmunkSpace *space) -{ - CCPhysicsDebugNode *node = new CCPhysicsDebugNode(); - if (node) - { - node->init(); - - node->m_pSpaceObj = space; - CC_SAFE_RETAIN(node->m_pSpaceObj); - - node->m_pSpacePtr = space->getSapce(); - - node->autorelease(); - } - else - { - CC_SAFE_DELETE(node); - } - - return node; -} - CCPhysicsDebugNode* CCPhysicsDebugNode::create(cpSpace *space) { CCPhysicsDebugNode *node = new CCPhysicsDebugNode(); @@ -240,7 +208,6 @@ CCPhysicsDebugNode* CCPhysicsDebugNode::create(cpSpace *space) CCPhysicsDebugNode::~CCPhysicsDebugNode() { - CC_SAFE_RELEASE(m_pSpaceObj); } NS_CC_END diff --git a/cocos2dx/physics_nodes/CCPhysicsDebugNode.h b/cocos2dx/physics_nodes/CCPhysicsDebugNode.h index 5c495c1292..92705bdb29 100644 --- a/cocos2dx/physics_nodes/CCPhysicsDebugNode.h +++ b/cocos2dx/physics_nodes/CCPhysicsDebugNode.h @@ -32,8 +32,6 @@ NS_CC_BEGIN -class ChipmunkSpace; - /** A Node that draws the components of a physics engine. @@ -46,13 +44,9 @@ class ChipmunkSpace; class CC_DLL CCPhysicsDebugNode : public CCDrawNode { protected: - ChipmunkSpace *m_pSpaceObj; cpSpace *m_pSpacePtr; public: - /** Create a debug node for an Objective-Chipmunk space. */ - static CCPhysicsDebugNode* create(ChipmunkSpace *space); - /** Create a debug node for a regular Chipmunk space. */ static CCPhysicsDebugNode* create(cpSpace *space); diff --git a/cocos2dx/physics_nodes/CCPhysicsSprite.cpp b/cocos2dx/physics_nodes/CCPhysicsSprite.cpp index 94e79ff583..ac3fedd022 100644 --- a/cocos2dx/physics_nodes/CCPhysicsSprite.cpp +++ b/cocos2dx/physics_nodes/CCPhysicsSprite.cpp @@ -66,33 +66,6 @@ bool CCPhysicsSprite::isDirty() #if CC_ENABLE_CHIPMUNK_INTEGRATION -// implementation of ChipmunkBody -ChipmunkBody* ChipmunkBody::create() -{ - ChipmunkBody* pRet = new ChipmunkBody(); - if (pRet) - { - pRet->autorelease(); - } - return pRet; -} - -cpBody* ChipmunkBody::getBody() -{ - return NULL; -} - -// implementation of ChipmunkSprite -ChipmunkBody* ChipmunkSprite::getChipmunkBody() const -{ - return (ChipmunkBody*)m_pBody->data; -} - -void ChipmunkSprite::setChipmunkBody(ChipmunkBody *chipmunkBody) -{ - m_pBody = chipmunkBody->getBody(); -} - // Override the setters and getters to always reflect the body's properties. const CCPoint& ChipmunkSprite::getPosition() { diff --git a/cocos2dx/physics_nodes/CCPhysicsSprite.h b/cocos2dx/physics_nodes/CCPhysicsSprite.h index 02325538de..00cac9fd8d 100644 --- a/cocos2dx/physics_nodes/CCPhysicsSprite.h +++ b/cocos2dx/physics_nodes/CCPhysicsSprite.h @@ -29,13 +29,6 @@ NS_CC_BEGIN #if CC_ENABLE_CHIPMUNK_INTEGRATION #include chipmunk.h -class CC_DLL ChipmunkBody : public CCObject -{ -public: - static ChipmunkBody* create(); - - cpBody* getBody(); -}; #elif CC_ENABLE_BOX2D_INTEGRATION class b2Body; diff --git a/cocos2dx/platform/ios/CCES2Renderer.m b/cocos2dx/platform/ios/CCES2Renderer.m index aee0b40ff8..5a0ac248cb 100644 --- a/cocos2dx/platform/ios/CCES2Renderer.m +++ b/cocos2dx/platform/ios/CCES2Renderer.m @@ -154,6 +154,10 @@ glRenderbufferStorage(GL_RENDERBUFFER, depthFormat_, backingWidth_, backingHeight_); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer_); + + if (depthFormat_ == GL_DEPTH24_STENCIL8_OES) { + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthBuffer_); + } // bind color buffer glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer_); diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index 5cf8305ef4..027c2b1065 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -40,9 +40,9 @@ NS_CC_BEGIN typedef struct _hashUniformEntry { - GLvoid* value; // value + GLvoid* value; // value unsigned int location; // Key - UT_hash_handle hh; // hash entry + UT_hash_handle hh; // hash entry } tHashUniformEntry; CCGLProgram::CCGLProgram() @@ -50,6 +50,7 @@ CCGLProgram::CCGLProgram() , m_uVertShader(0) , m_uFragShader(0) , m_pHashForUniforms(NULL) +, m_bUsesTime(false) { memset(m_uUniforms, 0, sizeof(m_uUniforms)); } @@ -87,18 +88,15 @@ bool CCGLProgram::initWithVertexShaderByteArray(const GLchar* vShaderByteArray, if (vShaderByteArray) { - if (!compileShader(&m_uVertShader, GL_VERTEX_SHADER, vShaderByteArray)) { CCLOG("cocos2d: ERROR: Failed to compile vertex shader"); } - } // Create and compile fragment shader if (fShaderByteArray) { - if (!compileShader(&m_uFragShader, GL_FRAGMENT_SHADER, fShaderByteArray)) { CCLOG("cocos2d: ERROR: Failed to compile fragment shader"); @@ -161,12 +159,9 @@ bool CCGLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* sour *shader = glCreateShader(type); glShaderSource(*shader, sizeof(sources)/sizeof(*sources), sources, NULL); - CHECK_GL_ERROR_DEBUG(); glCompileShader(*shader); - CHECK_GL_ERROR_DEBUG(); glGetShaderiv(*shader, GL_COMPILE_STATUS, &status); - CHECK_GL_ERROR_DEBUG(); if (! status) { @@ -189,7 +184,7 @@ bool CCGLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* sour abort(); } - return ( status == GL_TRUE ); + return (status == GL_TRUE); } void CCGLProgram::addAttribute(const char* attributeName, GLuint index) @@ -440,9 +435,9 @@ void CCGLProgram::setUniformsForBuiltins() kmMat4Multiply(&matrixMVP, &matrixP, &matrixMV); - setUniformLocationWith4fv(m_uUniforms[kCCUniformPMatrix], matrixP.mat, 1); - setUniformLocationWith4fv(m_uUniforms[kCCUniformMVMatrix], matrixMV.mat, 1); - setUniformLocationWith4fv(m_uUniforms[kCCUniformMVPMatrix], matrixMVP.mat, 1); + setUniformLocationwithMatrix4fv(m_uUniforms[kCCUniformPMatrix], matrixP.mat, 1); + setUniformLocationwithMatrix4fv(m_uUniforms[kCCUniformMVMatrix], matrixMV.mat, 1); + setUniformLocationwithMatrix4fv(m_uUniforms[kCCUniformMVPMatrix], matrixMVP.mat, 1); if(m_bUsesTime) { diff --git a/cocos2dx/shaders/CCGLProgram.h b/cocos2dx/shaders/CCGLProgram.h index bfc5a943f0..011d1759d7 100644 --- a/cocos2dx/shaders/CCGLProgram.h +++ b/cocos2dx/shaders/CCGLProgram.h @@ -82,7 +82,7 @@ enum { #define kCCUniformAlphaTestValue "CC_alpha_value" // Attribute names -#define kCCAttributeNameColor "a_color" +#define kCCAttributeNameColor "a_color" #define kCCAttributeNamePosition "a_position" #define kCCAttributeNameTexCoord "a_texCoord" diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index 92c0782895..2a07de9a52 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -39,6 +39,7 @@ enum { kCCShaderType_PositionTexture_uColor, kCCShaderType_PositionTextureA8Color, kCCShaderType_Position_uColor, + kCCShaderType_PositionLengthTexureColor, kCCShaderType_MAX, }; @@ -140,7 +141,16 @@ void CCShaderCache::loadDefaultShaders() loadDefaultShader(p, kCCShaderType_Position_uColor); m_pPrograms->setObject(p, kCCShader_Position_uColor); - p->release(); + p->release(); + + // + // Position, Legth(TexCoords, Color (used by Draw Node basically ) + // + p = new CCGLProgram(); + loadDefaultShader(p, kCCShaderType_PositionLengthTexureColor); + + m_pPrograms->setObject(p, kCCShader_PositionLengthTexureColor); + p->release(); } void CCShaderCache::reloadDefaultShaders() @@ -190,7 +200,14 @@ void CCShaderCache::reloadDefaultShaders() // p = programForKey(kCCShader_Position_uColor); p->reset(); - loadDefaultShader(p, kCCShaderType_Position_uColor); + loadDefaultShader(p, kCCShaderType_Position_uColor); + + // + // Position, Legth(TexCoords, Color (used by Draw Node basically ) + // + p = programForKey(kCCShader_PositionLengthTexureColor); + p->reset(); + loadDefaultShader(p, kCCShaderType_Position_uColor); } void CCShaderCache::loadDefaultShader(CCGLProgram *p, int type) @@ -246,6 +263,14 @@ void CCShaderCache::loadDefaultShader(CCGLProgram *p, int type) p->addAttribute("aVertex", kCCVertexAttrib_Position); + break; + case kCCShaderType_PositionLengthTexureColor: + p->initWithVertexShaderByteArray(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag); + + p->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position); + p->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords); + p->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color); + break; default: CCLOG("cocos2d: %s:%d, error shader type", __FUNCTION__, __LINE__); diff --git a/cocos2dx/shaders/ccGLStateCache.cpp b/cocos2dx/shaders/ccGLStateCache.cpp index e09fc94c83..211409f3c9 100644 --- a/cocos2dx/shaders/ccGLStateCache.cpp +++ b/cocos2dx/shaders/ccGLStateCache.cpp @@ -33,9 +33,9 @@ THE SOFTWARE. #include "kazmath/GL/matrix.h" #include "kazmath/kazmath.h" -NS_CC_BEGIN +using namespace cocos2d; -static GLuint s_uCurrentProjectionMatrix = -1; +static GLuint s_uCurrentProjectionMatrix = -1; static bool s_bVertexAttribPosition = false; static bool s_bVertexAttribColor = false; static bool s_bVertexAttribTexCoords = false; @@ -49,8 +49,8 @@ static GLuint s_uCurrentShaderProgram = -1; static GLuint s_uCurrentBoundTexture[kCCMaxActiveTexture] = {(GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, (GLuint)-1,(GLuint)-1,(GLuint)-1,(GLuint)-1, }; static GLenum s_eBlendingSource = -1; static GLenum s_eBlendingDest = -1; -static int s_eGLServerState = 0; -static GLuint s_uVAO = 0; +static int s_eGLServerState = 0; +static GLuint s_uVAO = 0; #endif // CC_ENABLE_GL_STATE_CACHE // GL State Cache functions @@ -58,10 +58,12 @@ static GLuint s_uVAO = 0; void ccGLInvalidateStateCache( void ) { kmGLFreeAll(); + s_uCurrentProjectionMatrix = -1; s_bVertexAttribPosition = false; s_bVertexAttribColor = false; s_bVertexAttribTexCoords = false; + #if CC_ENABLE_GL_STATE_CACHE s_uCurrentShaderProgram = -1; for( int i=0; i < kCCMaxActiveTexture; i++ ) @@ -78,8 +80,10 @@ void ccGLInvalidateStateCache( void ) void ccGLDeleteProgram( GLuint program ) { #if CC_ENABLE_GL_STATE_CACHE - if( program == s_uCurrentShaderProgram ) + if(program == s_uCurrentShaderProgram) + { s_uCurrentShaderProgram = -1; + } #endif // CC_ENABLE_GL_STATE_CACHE glDeleteProgram( program ); @@ -134,24 +138,29 @@ void ccGLBlendResetToCache(void) #endif // CC_ENABLE_GL_STATE_CACHE } +void ccGLBindTexture2D(GLuint textureId) +{ + ccGLBindTexture2DN(0, textureId); +} + void ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId) { #if CC_ENABLE_GL_STATE_CACHE CCAssert(textureUnit < kCCMaxActiveTexture, "textureUnit is too big"); - if( s_uCurrentBoundTexture[textureUnit] != textureId ) + if (s_uCurrentBoundTexture[textureUnit] != textureId) { s_uCurrentBoundTexture[textureUnit] = textureId; glActiveTexture(GL_TEXTURE0 + textureUnit); - glBindTexture(GL_TEXTURE_2D, textureId ); + glBindTexture(GL_TEXTURE_2D, textureId); } #else glActiveTexture(GL_TEXTURE0 + textureUnit); - glBindTexture(GL_TEXTURE_2D, textureId ); + glBindTexture(GL_TEXTURE_2D, textureId); #endif } -void ccGLDeleteTexture( GLuint textureId ) +void ccGLDeleteTexture(GLuint textureId) { ccGLDeleteTextureN(0, textureId); } @@ -165,7 +174,7 @@ void ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId) } #endif // CC_ENABLE_GL_STATE_CACHE - glDeleteTextures(1, &textureId ); + glDeleteTextures(1, &textureId); } void ccGLBindVAO(GLuint vaoId) @@ -181,7 +190,7 @@ void ccGLBindVAO(GLuint vaoId) #endif } -void ccGLEnable( ccGLServerState flags ) +void ccGLEnable(ccGLServerState flags) { #if CC_ENABLE_GL_STATE_CACHE @@ -255,5 +264,3 @@ void ccSetProjectionMatrixDirty( void ) { s_uCurrentProjectionMatrix = -1; } - -NS_CC_END diff --git a/cocos2dx/shaders/ccGLStateCache.h b/cocos2dx/shaders/ccGLStateCache.h index 6cd79d68ea..941c0d1423 100644 --- a/cocos2dx/shaders/ccGLStateCache.h +++ b/cocos2dx/shaders/ccGLStateCache.h @@ -30,8 +30,6 @@ THE SOFTWARE. #include "CCGL.h" #include "platform/CCPlatformMacros.h" -NS_CC_BEGIN - /** * @addtogroup shaders * @{ @@ -44,8 +42,8 @@ enum { kCCVertexAttribFlag_None = 0, kCCVertexAttribFlag_Position = 1 << 0, - kCCVertexAttribFlag_Color = 1 << 1, - kCCVertexAttribFlag_TexCoords = 1 << 2, + kCCVertexAttribFlag_Color = 1 << 1, + kCCVertexAttribFlag_TexCoords = 1 << 2, kCCVertexAttribFlag_PosColorTex = ( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color | kCCVertexAttribFlag_TexCoords ), }; @@ -64,6 +62,10 @@ typedef enum { } ccGLServerState; +#ifdef __cplusplus +extern "C" { +#endif + /** @file ccGLStateCache.h */ @@ -117,14 +119,14 @@ void CC_DLL ccGLEnableVertexAttribs(unsigned int flags); /** If the texture is not already bound to texture unit 0, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. - @since v2.1.0 + @since v2.0.0 */ void ccGLBindTexture2D(GLuint textureId); /** If the texture is not already bound to a given unit, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. - @since v2.0.0 + @since v2.1.0 */ void CC_DLL ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId); @@ -154,7 +156,9 @@ void CC_DLL ccGLEnable( ccGLServerState flags ); // end of shaders group /// @} - -NS_CC_END + +#ifdef __cplusplus +} +#endif #endif /* __CCGLSTATE_H__ */ diff --git a/cocos2dx/shaders/ccShader_PositionColorLengthTexture_frag.h b/cocos2dx/shaders/ccShader_PositionColorLengthTexture_frag.h new file mode 100644 index 0000000000..80470e273c --- /dev/null +++ b/cocos2dx/shaders/ccShader_PositionColorLengthTexture_frag.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * 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. + */ + +" \n\ +#extension GL_OES_standard_derivatives : enable \n\ + \n\ +#ifdef GL_ES \n\ +varying mediump vec4 v_color; \n\ +varying mediump vec2 v_texcoord; \n\ +#else \n\ +varying vec4 v_color; \n\ +varying vec2 v_texcoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ +#if defined GL_OES_standard_derivatives \n\ + gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n\ +#else \n\ + gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); \n\ +#endif \n\ +} \n\ +"; diff --git a/cocos2dx/shaders/ccShader_PositionColorLengthTexture_vert.h b/cocos2dx/shaders/ccShader_PositionColorLengthTexture_vert.h new file mode 100644 index 0000000000..3a8e96d467 --- /dev/null +++ b/cocos2dx/shaders/ccShader_PositionColorLengthTexture_vert.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +attribute mediump vec4 a_position; \n\ +attribute mediump vec2 a_texcoord; \n\ +attribute mediump vec4 a_color; \n\ + \n\ +varying mediump vec4 v_color; \n\ +varying mediump vec2 v_texcoord; \n\ + \n\ +#else \n\ +attribute vec4 a_position; \n\ +attribute vec2 a_texcoord; \n\ +attribute vec4 a_color; \n\ + \n\ +varying vec4 v_color; \n\ +varying vec2 v_texcoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + v_color = vec4(a_color.rgb * a_color.a, a_color.a); \n\ + v_texcoord = a_texcoord; \n\ + \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ +} \n\ +"; diff --git a/cocos2dx/shaders/ccShader_PositionColor_frag.h b/cocos2dx/shaders/ccShader_PositionColor_frag.h index e607a1357f..910903d2e7 100644 --- a/cocos2dx/shaders/ccShader_PositionColor_frag.h +++ b/cocos2dx/shaders/ccShader_PositionColor_frag.h @@ -1,12 +1,37 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +precision lowp float; \n\ +#endif \n\ + \n\ +varying vec4 v_fragmentColor; \n\ + \n\ +void main() \n\ +{ \n\ + gl_FragColor = v_fragmentColor; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionColor_vert.h b/cocos2dx/shaders/ccShader_PositionColor_vert.h index 1394b94c0a..633f338a9a 100644 --- a/cocos2dx/shaders/ccShader_PositionColor_vert.h +++ b/cocos2dx/shaders/ccShader_PositionColor_vert.h @@ -1,17 +1,40 @@ -" \n\ -attribute vec4 a_position; \n\ -attribute vec4 a_color; \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = u_MVPMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +attribute vec4 a_position; \n\ +attribute vec4 a_color; \n\ +#ifdef GL_ES \n\ +varying lowp vec4 v_fragmentColor; \n\ +#else \n\ +varying vec4 v_fragmentColor; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ + v_fragmentColor = a_color; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTextureA8Color_frag.h b/cocos2dx/shaders/ccShader_PositionTextureA8Color_frag.h index 01f1ac4b60..6a8fb85ae1 100644 --- a/cocos2dx/shaders/ccShader_PositionTextureA8Color_frag.h +++ b/cocos2dx/shaders/ccShader_PositionTextureA8Color_frag.h @@ -1,16 +1,41 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = vec4( v_fragmentColor.rgb, // RGB from uniform \n\ - v_fragmentColor.a * texture2D(u_texture, v_texCoord).a // A from texture & uniform \n\ - ); \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +precision lowp float; \n\ +#endif \n\ + \n\ +varying vec4 v_fragmentColor; \n\ +varying vec2 v_texCoord; \n\ +uniform sampler2D CC_Texture0; \n\ + \n\ +void main() \n\ +{ \n\ + gl_FragColor = vec4( v_fragmentColor.rgb, // RGB from uniform \n\ + v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform \n\ + ); \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTextureA8Color_vert.h b/cocos2dx/shaders/ccShader_PositionTextureA8Color_vert.h index a51b78d4d4..bb29e7d93a 100644 --- a/cocos2dx/shaders/ccShader_PositionTextureA8Color_vert.h +++ b/cocos2dx/shaders/ccShader_PositionTextureA8Color_vert.h @@ -1,21 +1,45 @@ -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ -attribute vec4 a_color; \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = u_MVPMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +attribute vec4 a_position; \n\ +attribute vec2 a_texCoord; \n\ +attribute vec4 a_color; \n\ + \n\ +#ifdef GL_ES \n\ +varying lowp vec4 v_fragmentColor; \n\ +varying mediump vec2 v_texCoord; \n\ +#else \n\ +varying vec4 v_fragmentColor; \n\ +varying vec2 v_texCoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ + v_fragmentColor = a_color; \n\ + v_texCoord = a_texCoord; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTextureColorAlphaTest_frag.h b/cocos2dx/shaders/ccShader_PositionTextureColorAlphaTest_frag.h index 0299abbc3f..fe321ba222 100644 --- a/cocos2dx/shaders/ccShader_PositionTextureColorAlphaTest_frag.h +++ b/cocos2dx/shaders/ccShader_PositionTextureColorAlphaTest_frag.h @@ -1,23 +1,47 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ -uniform float u_alpha_value; \n\ - \n\ -void main() \n\ -{ \n\ - vec4 texColor = texture2D(u_texture, v_texCoord); \n\ - \n\ - // mimic: glAlphaFunc(GL_GREATER) \n\ - // pass if ( incoming_pixel >= u_alpha_value ) => fail if incoming_pixel < u_alpha_value \n\ - \n\ - if ( texColor.a <= u_alpha_value ) \n\ - discard; \n\ - \n\ - gl_FragColor = texColor * v_fragmentColor; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Brian Chapados + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +precision lowp float; \n\ +#endif \n\ + \n\ +varying vec4 v_fragmentColor; \n\ +varying vec2 v_texCoord; \n\ +uniform sampler2D CC_Texture0; \n\ +uniform float CC_alpha_value; \n\ + \n\ +void main() \n\ +{ \n\ + vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n\ + \n\ + // mimic: glAlphaFunc(GL_GREATER) \n\ + // pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value \n\ + \n\ + if ( texColor.a <= CC_alpha_value ) \n\ + discard; \n\ + \n\ + gl_FragColor = texColor * v_fragmentColor; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTextureColor_frag.h b/cocos2dx/shaders/ccShader_PositionTextureColor_frag.h index 442bfc7857..df5527ef56 100644 --- a/cocos2dx/shaders/ccShader_PositionTextureColor_frag.h +++ b/cocos2dx/shaders/ccShader_PositionTextureColor_frag.h @@ -1,14 +1,39 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor * texture2D(u_texture, v_texCoord); \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +precision lowp float; \n\ +#endif \n\ + \n\ +varying vec4 v_fragmentColor; \n\ +varying vec2 v_texCoord; \n\ +uniform sampler2D CC_Texture0; \n\ + \n\ +void main() \n\ +{ \n\ + gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTextureColor_vert.h b/cocos2dx/shaders/ccShader_PositionTextureColor_vert.h index f6f7db335f..bb29e7d93a 100644 --- a/cocos2dx/shaders/ccShader_PositionTextureColor_vert.h +++ b/cocos2dx/shaders/ccShader_PositionTextureColor_vert.h @@ -1,22 +1,45 @@ -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ -attribute vec4 a_color; \n\ - \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = u_MVPMatrix * a_position; \n\ - v_fragmentColor = a_color; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +attribute vec4 a_position; \n\ +attribute vec2 a_texCoord; \n\ +attribute vec4 a_color; \n\ + \n\ +#ifdef GL_ES \n\ +varying lowp vec4 v_fragmentColor; \n\ +varying mediump vec2 v_texCoord; \n\ +#else \n\ +varying vec4 v_fragmentColor; \n\ +varying vec2 v_texCoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ + v_fragmentColor = a_color; \n\ + v_texCoord = a_texCoord; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTexture_frag.h b/cocos2dx/shaders/ccShader_PositionTexture_frag.h index 4fc8f7ca66..93a8f0eda6 100644 --- a/cocos2dx/shaders/ccShader_PositionTexture_frag.h +++ b/cocos2dx/shaders/ccShader_PositionTexture_frag.h @@ -1,13 +1,38 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec2 v_texCoord; \n\ -uniform sampler2D u_texture; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = texture2D(u_texture, v_texCoord); \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +precision lowp float; \n\ +#endif \n\ + \n\ +varying vec2 v_texCoord; \n\ +uniform sampler2D CC_Texture0; \n\ + \n\ +void main() \n\ +{ \n\ + gl_FragColor = texture2D(CC_Texture0, v_texCoord); \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTexture_uColor_frag.h b/cocos2dx/shaders/ccShader_PositionTexture_uColor_frag.h index e1643a1bb5..a97d25077e 100644 --- a/cocos2dx/shaders/ccShader_PositionTexture_uColor_frag.h +++ b/cocos2dx/shaders/ccShader_PositionTexture_uColor_frag.h @@ -1,16 +1,41 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -uniform vec4 u_color; \n\ - \n\ -varying vec2 v_texCoord; \n\ - \n\ -uniform sampler2D u_texture; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = texture2D(u_texture, v_texCoord) * u_color; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +precision lowp float; \n\ +#endif \n\ + \n\ +uniform vec4 u_color; \n\ + \n\ +varying vec2 v_texCoord; \n\ + \n\ +uniform sampler2D CC_Texture0; \n\ + \n\ +void main() \n\ +{ \n\ + gl_FragColor = texture2D(CC_Texture0, v_texCoord) * u_color; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTexture_uColor_vert.h b/cocos2dx/shaders/ccShader_PositionTexture_uColor_vert.h index 8796e1c0a4..9d2bfd3e2d 100644 --- a/cocos2dx/shaders/ccShader_PositionTexture_uColor_vert.h +++ b/cocos2dx/shaders/ccShader_PositionTexture_uColor_vert.h @@ -1,18 +1,41 @@ -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ - \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ -#ifdef GL_ES \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = u_MVPMatrix * a_position; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +attribute vec4 a_position; \n\ +attribute vec2 a_texCoord; \n\ + \n\ +#ifdef GL_ES \n\ +varying mediump vec2 v_texCoord; \n\ +#else \n\ +varying vec2 v_texCoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ + v_texCoord = a_texCoord; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_PositionTexture_vert.h b/cocos2dx/shaders/ccShader_PositionTexture_vert.h index 6248c19333..1278ab0e80 100644 --- a/cocos2dx/shaders/ccShader_PositionTexture_vert.h +++ b/cocos2dx/shaders/ccShader_PositionTexture_vert.h @@ -1,17 +1,41 @@ -" \n\ -attribute vec4 a_position; \n\ -attribute vec2 a_texCoord; \n\ -uniform mat4 u_MVPMatrix; \n\ - \n\ -#ifdef GL_ES \n\ -varying mediump vec2 v_texCoord; \n\ -#else \n\ -varying vec2 v_texCoord; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = u_MVPMatrix * a_position; \n\ - v_texCoord = a_texCoord; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +attribute vec4 a_position; \n\ +attribute vec2 a_texCoord; \n\ + \n\ +#ifdef GL_ES \n\ +varying mediump vec2 v_texCoord; \n\ +#else \n\ +varying vec2 v_texCoord; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ + v_texCoord = a_texCoord; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_Position_uColor_frag.h b/cocos2dx/shaders/ccShader_Position_uColor_frag.h index 8b8615f5f6..d882c88f76 100644 --- a/cocos2dx/shaders/ccShader_Position_uColor_frag.h +++ b/cocos2dx/shaders/ccShader_Position_uColor_frag.h @@ -1,12 +1,37 @@ -" \n\ -#ifdef GL_ES \n\ -precision lowp float; \n\ -#endif \n\ - \n\ -varying vec4 v_fragmentColor; \n\ - \n\ -void main() \n\ -{ \n\ - gl_FragColor = v_fragmentColor; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +#ifdef GL_ES \n\ +precision lowp float; \n\ +#endif \n\ + \n\ +varying vec4 v_fragmentColor; \n\ + \n\ +void main() \n\ +{ \n\ + gl_FragColor = v_fragmentColor; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShader_Position_uColor_vert.h b/cocos2dx/shaders/ccShader_Position_uColor_vert.h index 6b2f92c6ae..c50e38b3f8 100644 --- a/cocos2dx/shaders/ccShader_Position_uColor_vert.h +++ b/cocos2dx/shaders/ccShader_Position_uColor_vert.h @@ -1,19 +1,43 @@ -" \n\ -attribute vec4 a_position; \n\ -uniform mat4 u_MVPMatrix; \n\ -uniform vec4 u_color; \n\ -uniform float u_pointSize; \n\ - \n\ -#ifdef GL_ES \n\ -varying lowp vec4 v_fragmentColor; \n\ -#else \n\ -varying vec4 v_fragmentColor; \n\ -#endif \n\ - \n\ -void main() \n\ -{ \n\ - gl_Position = u_MVPMatrix * a_position; \n\ - gl_PointSize = u_pointSize; \n\ - v_fragmentColor = u_color; \n\ -} \n\ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2011 Ricardo Quesada + * Copyright (c) 2012 Zynga Inc. + * + * 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. + */ + +" \n\ +attribute vec4 a_position; \n\ +uniform vec4 u_color; \n\ +uniform float u_pointSize; \n\ + \n\ +#ifdef GL_ES \n\ +varying lowp vec4 v_fragmentColor; \n\ +#else \n\ +varying vec4 v_fragmentColor; \n\ +#endif \n\ + \n\ +void main() \n\ +{ \n\ + gl_Position = CC_MVPMatrix * a_position; \n\ + gl_PointSize = u_pointSize; \n\ + v_fragmentColor = u_color; \n\ +} \n\ "; diff --git a/cocos2dx/shaders/ccShaders.cpp b/cocos2dx/shaders/ccShaders.cpp index a58819bb64..56ce1bf821 100644 --- a/cocos2dx/shaders/ccShaders.cpp +++ b/cocos2dx/shaders/ccShaders.cpp @@ -69,4 +69,9 @@ const GLchar * ccPositionTexture_uColor_vert = const GLchar * ccExSwitchMask_frag = #include "ccShaderEx_SwitchMask_frag.h" +const GLchar * ccPositionColorLengthTexture_frag = +#include "ccShader_PositionColorLengthTexture_frag.h" +const GLchar * ccPositionColorLengthTexture_vert = +#include "ccShader_PositionColorLengthTexture_vert.h" + NS_CC_END diff --git a/cocos2dx/shaders/ccShaders.h b/cocos2dx/shaders/ccShaders.h index 239007331a..f0bcfd4b42 100644 --- a/cocos2dx/shaders/ccShaders.h +++ b/cocos2dx/shaders/ccShaders.h @@ -55,6 +55,9 @@ extern CC_DLL const GLchar * ccPositionTextureColorAlphaTest_frag; extern CC_DLL const GLchar * ccPositionTexture_uColor_frag; extern CC_DLL const GLchar * ccPositionTexture_uColor_vert; +extern CC_DLL const GLchar * ccPositionColorLengthTexture_frag; +extern CC_DLL const GLchar * ccPositionColorLengthTexture_vert; + extern CC_DLL const GLchar * ccExSwitchMask_frag; // end of shaders group