mirror of https://github.com/axmolengine/axmol.git
issue #1555:fix a bug about CCGLProgram
This commit is contained in:
parent
6661f2c88d
commit
5fd56370d8
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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(); \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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_);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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__);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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\
|
||||
";
|
|
@ -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\
|
||||
";
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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\
|
||||
";
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue