本文整理汇总了C++中CCGLProgram类的典型用法代码示例。如果您正苦于以下问题:C++ CCGLProgram类的具体用法?C++ CCGLProgram怎么用?C++ CCGLProgram使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCGLProgram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTexture
bool SpriteBlur::initWithTexture(CCTexture2D* texture, const CCRect& rect)
{
if( CCSprite::initWithTexture(texture, rect) )
{
CCSize s = getTexture()->getContentSizeInPixels();
blur_ = ccp(1/s.width, 1/s.height);
sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0;
GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(
CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString();
CCGLProgram* pProgram = new CCGLProgram();
pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource);
setShaderProgram(pProgram);
pProgram->release();
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->link();
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->updateUniforms();
CHECK_GL_ERROR_DEBUG();
subLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "substract");
blurLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "blurSize");
CHECK_GL_ERROR_DEBUG();
return true;
}
return false;
}
示例2: CCGLProgram
void SpriteBlur::initProgram()
{
GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(
CCFileUtils::sharedFileUtils()->fullPathForFilename("Shaders/example_Blur.fsh").c_str())->getCString();
CCGLProgram* pProgram = new CCGLProgram();
pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource);
setShaderProgram(pProgram);
pProgram->release();
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->link();
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->updateUniforms();
CHECK_GL_ERROR_DEBUG();
subLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "substract");
blurLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "blurSize");
CHECK_GL_ERROR_DEBUG();
ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex );
ccBlendFunc blend = getBlendFunc();
ccGLBlendFunc(blend.src, blend.dst);
getShaderProgram()->use();
getShaderProgram()->setUniformsForBuiltins();
getShaderProgram()->setUniformLocationWith2f(blurLocation, blur_.x, blur_.y);
getShaderProgram()->setUniformLocationWith4fv(subLocation, sub_, 1);
ccGLBindTexture2D( getTexture()->getName());
}
示例3: CC_BREAK_IF
bool EXGraySprite::initWithTexture( cocos2d::CCTexture2D* pTexture, const cocos2d::CCRect& tRect )
{
do{
CC_BREAK_IF(!CCSprite::initWithTexture(pTexture, tRect));
GLchar* pszFragSource =
"#ifdef GL_ES \n \
precision mediump float; \n \
#endif \n \
uniform sampler2D u_texture; \n \
varying vec2 v_texCoord; \n \
varying vec4 v_fragmentColor; \n \
void main(void) \n \
{ \n \
// Convert to greyscale using NTSC weightings \n \
vec4 col = texture2D(u_texture, v_texCoord); \n \
float grey = dot(col.rgb, vec3(0.299, 0.587, 0.114)); \n \
gl_FragColor = vec4(grey, grey, grey, col.a); \n \
}";
CCGLProgram* pProgram = new CCGLProgram();
pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, pszFragSource);
this->setShaderProgram(pProgram);
pProgram->release();
CHECK_GL_ERROR_DEBUG();
this->getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
this->getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
this->getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
CHECK_GL_ERROR_DEBUG();
this->getShaderProgram()->link();
CHECK_GL_ERROR_DEBUG();
this->getShaderProgram()->updateUniforms();
CHECK_GL_ERROR_DEBUG();
return true;
} while (0);
return false;
}
示例4: CCLOGERROR
bool TextureSprite::init(std::string &texFileName, CCPointVector &vertices)
{
/// Load the texture from file
if (texFileName.length() == 0) {
CCLOGERROR("Invalid texture filename (empty string)");
return false;
}
CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(texFileName.c_str());
if (!texture) {
CCLOGERROR("ERROR: Can't load texture: '%s'", texFileName.c_str());
return false;
}
setTexture(texture);
/// Enable texture repeat. Horizontal and vertical repeat enabled by default.
setRepeat(true, true);
/// Create the shader program
CCGLProgram *shader = CCShaderCache::sharedShaderCache()->programForKey(settings::kShader_PositionTexture_uColor_uTime);
mColorLocation = glGetUniformLocation(shader->getProgram(), "u_color");
mTimeLocation = glGetUniformLocation(shader->getProgram(), "u_time");
setShaderProgram(shader);
addPolygon(vertices);
/* Seems that there's no need to call the init method again when the app is back to foreground (like CCDrawNode.cpp).
* Only reload shaders is mandatory (see proj.android/jni/hellolua/main.cpp).
*/
/*
#if CC_ENABLE_CACHE_TEXTURE_DATA > 0
CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
callfuncO_selector(TextureSprite::listenBackToForeground),
EVENT_COME_TO_FOREGROUND,
NULL);
#endif
*/
return true;
}
示例5: CCGLProgram
void ShaderNode::loadShaderVertex(const char *vert, const char *frag)
{
CCGLProgram *shader = new CCGLProgram();
shader->initWithVertexShaderFilename(vert, frag);
shader->addAttribute("aVertex", kCCVertexAttrib_Position);
shader->link();
shader->updateUniforms();
m_uniformCenter = glGetUniformLocation(shader->getProgram(), "center");
m_uniformResolution = glGetUniformLocation(shader->getProgram(), "resolution");
m_uniformTime = glGetUniformLocation(shader->getProgram(), "time");
this->setShaderProgram(shader);
shader->release();
}
示例6: programForKey
void CCShaderCache::reloadDefaultShaders()
{
// reset all programs and reload them
// Position Texture Color shader
CCGLProgram *p = programForKey(kCCShader_PositionTextureColor);
p->reset();
loadDefaultShader(p, kCCShaderType_PositionTextureColor);
// Position Texture Color alpha test
p = programForKey(kCCShader_PositionTextureColorAlphaTest);
p->reset();
loadDefaultShader(p, kCCShaderType_PositionTextureColorAlphaTest);
//
// Position, Color shader
//
p = programForKey(kCCShader_PositionColor);
p->reset();
loadDefaultShader(p, kCCShaderType_PositionColor);
//
// Position Texture shader
//
p = programForKey(kCCShader_PositionTexture);
p->reset();
loadDefaultShader(p, kCCShaderType_PositionTexture);
//
// Position, Texture attribs, 1 Color as uniform shader
//
p = programForKey(kCCShader_PositionTexture_uColor);
p->reset();
loadDefaultShader(p, kCCShaderType_PositionTexture_uColor);
//
// Position Texture A8 Color shader
//
p = programForKey(kCCShader_PositionTextureA8Color);
p->reset();
loadDefaultShader(p, kCCShaderType_PositionTextureA8Color);
//
// Position and 1 color passed as a uniform (to simulate glColor4ub )
//
p = programForKey(kCCShader_Position_uColor);
p->reset();
loadDefaultShader(p, kCCShaderType_Position_uColor);
}
示例7: glStencilMask
void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane)
{
GLint planeMask = 0x1 << plane;
glStencilMask(planeMask);
glStencilFunc(GL_NEVER, 0, planeMask);
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
ccDrawSolidRect(CCPointZero, ccpFromSize(CCDirector::sharedDirector()->getWinSize()), ccc4f(1, 1, 1, 1));
glStencilFunc(GL_NEVER, planeMask, planeMask);
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, _alphaThreshold);
#else
CCGLProgram *program = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kCCUniformAlphaTestValue);
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
m_pSprite->setShaderProgram(program);
#endif
glFlush();
}
示例8: CCGLProgram
void LightLayer::initProgram()
{
std::string sharderStr = CCFileUtils::getInstance()->fullPathForFilename("Shaders/shader_spot.fsh");
GLchar * fragSource = (GLchar*)CCString::createWithContentsOfFile(sharderStr.c_str())->getCString();
sharderStr = CCFileUtils::getInstance()->fullPathForFilename("Shaders/shader_very_pos_color.vsh");
GLchar * vertexSource = (GLchar*)CCString::createWithContentsOfFile(sharderStr.c_str())->getCString();
CCGLProgram* pProgram = new CCGLProgram();
pProgram->initWithVertexShaderByteArray(vertexSource, fragSource);
setShaderProgram(pProgram);
pProgram->release();
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->link();
CHECK_GL_ERROR_DEBUG();
getShaderProgram()->updateUniforms();
CHECK_GL_ERROR_DEBUG();
_spotLocation = glGetUniformLocation(getShaderProgram()->getProgram(), "v_spot_pos");
_innerColor = glGetUniformLocation(getShaderProgram()->getProgram(), "v_spot_innerColor");
_spotInnerRadius = glGetUniformLocation(getShaderProgram()->getProgram(), "v_spot_innerRadius");
_spotOuterRadius = glGetUniformLocation(getShaderProgram()->getProgram(), "v_spot_outerRadius");
CHECK_GL_ERROR_DEBUG();
_spotPoint = CCPoint(100, 100);
}
示例9: tolua_CCGLProgram_CCGLProgram_setUniformLocationWith4f00
static int tolua_CCGLProgram_CCGLProgram_setUniformLocationWith4f00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"CCGLProgram",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isnumber(tolua_S,5,0,&tolua_err) ||
!tolua_isnumber(tolua_S,6,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,7,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
CCGLProgram* self = (CCGLProgram*) tolua_tousertype(tolua_S,1,0);
int location = ((int) tolua_tonumber(tolua_S,2,0));
float f1 = ((float) tolua_tonumber(tolua_S,3,0));
float f2 = ((float) tolua_tonumber(tolua_S,4,0));
float f3 = ((float) tolua_tonumber(tolua_S,5,0));
float f4 = ((float) tolua_tonumber(tolua_S,6,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUniformLocationWith4f'", NULL);
#endif
{
self->setUniformLocationWith4f(location,f1,f2,f3,f4);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'setUniformLocationWith4f'.",&tolua_err);
return 0;
#endif
}
示例10: CC_NODE_DRAW_SETUP
void ShaderNode::draw()
{
CC_NODE_DRAW_SETUP();
//传递uniform变量
CCGLProgram* shader = getShaderProgram();
shader->setUniformLocationWith2f(m_uniformResolution, m_resolution.x,
m_resolution.y);
shader->setUniformLocationWith1i(m_uniformTex0, 0);
glUniform1f(m_uniformTime, m_time);
//获取attribute变量
CCSize size = this->getContentSize();
float w = size.width;
float h = size.height;
ccGLBindTexture2D(m_texture); //绑定纹理到槽位
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, w, h, 0); //截取屏幕数据到纹理
glEnableVertexAttribArray(m_attributePosition);
glDisableVertexAttribArray(m_attributeColor);
//传递attribute变量
GLfloat vertices[12] = {
0, 0, //左下0
w, 0, //右下1
w, h, //右上2
0, 0, //左下0
0, h, //左上3
w, h, //右上2
};
glVertexAttribPointer(m_attributePosition, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glVertexAttrib4fv(m_attributeColor, color);
//绘制
glDrawArrays(GL_TRIANGLES, 0, 6);
}
示例11: CCGLProgram
void QRSprite::loadShaderVertex(const char *vert, const char *frag)
{
CCGLProgram *shader = new CCGLProgram();
shader->initWithVertexShaderByteArray(vert, frag);
shader->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
shader->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
shader->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
shader->link();
shader->updateUniforms();
this->setShaderProgram(shader);
shader->release();
}
示例12: setBatchNodeAlphaTestValue
void BatchNodeManager::setBatchNodeAlphaTestValue(float _value)
{
CCGLProgram* alphashader = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest);
CHECK_GL_ERROR_DEBUG();
alphashader->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag);
alphashader->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
alphashader->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
alphashader->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
alphashader->link();
alphashader->updateUniforms();
unsigned loc = glGetUniformLocation(alphashader->getProgram(), kCCUniformAlphaTestValue);
CHECK_GL_ERROR_DEBUG();
alphashader->setUniformLocationWith1f(loc, _value);
CHECK_GL_ERROR_DEBUG();
}
示例13: CCLOG
bool Assets::reloadCustomShaders()
{
CCLOG("reload custom shaders");
CCGLProgram *shader = CCShaderCache::sharedShaderCache()->programForKey(settings::kShader_PositionTexture_uColor_uTime);
shader->reset();
shader->initWithVertexShaderFilename("shaders/shader_PositionTexture_uColor_uTime.vsh", "shaders/shader_PositionTexture_uColor_uTime.fsh");
shader->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
shader->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
shader->link();
shader->updateUniforms();
/// TODO
CHECK_GL_ERROR_DEBUG();
return true;
}
示例14: CCGLProgram
void CCShaders::loadCustomShader(const string& key) {
if(!CCShaderCache::sharedShaderCache()->programForKey(key.c_str())) {
// load shader
CCGLProgram* p = new CCGLProgram();
p->autorelease();
LOAD_PROGRAM_IF(flash);
LOAD_PROGRAM_IF(blur);
// add attribute
if(false) {
// non-default situation
} else {
p->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
p->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
p->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
}
// link it
p->link();
// add custom uniform
if(key == kCCShader_flash) {
ADD_UNIFORM(flashColor);
ADD_UNIFORM(flashTime);
} else if(key == kCCShader_blur) {
ADD_UNIFORM(blurSize);
ADD_UNIFORM(blurSubtract);
}
// add standard uniforms
p->updateUniforms();
// add program
CCShaderCache::sharedShaderCache()->addProgram(p, key.c_str());
}
}
示例15: setTouchEnabled
bool SceneNode::initWithTexture(std::string textureName)
{
//enable touch
setTouchEnabled( true );
//set projection is 2D (default is 3D). if use 3D projection, projection error accumulation may cause ripple effect mess.
CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);
//get adaptedViewport. adaptedViewport is calculated by cocos2d-x
//so long as we use this adaptedViewport, we just writting code based on designResolutionSize, no need to worry about the screen adaptation.
glGetIntegerv(GL_VIEWPORT,adaptedViewport);
//get screenSize
//screenSize is the real size of simulator/device screen
screenSize=CCEGLView::sharedOpenGLView()->getFrameSize();
CCLOG("screenSize:%f,%f",screenSize.width,screenSize.height);
//get winSize
//winSize is equals to designResolutionSize. we only need to writting code based on designResolutionSize (and forget the real screenSize).
winSize=CCDirector::sharedDirector()->getWinSize();
CCLOG("winSize:%f,%f",winSize.width,winSize.height);
//determine bufferTexSize based on winSize
bufferTexSize=CCSize(winSize.width*0.4,winSize.height*0.4);
//use bufferTexSize to calculate step_s and step_t
step_s=1.0/bufferTexSize.width;
step_t=1.0/bufferTexSize.height;
//create textures
texBackGround = CCTextureCache::sharedTextureCache()->addImage(textureName.c_str()) ;
bufferTexSource=createCCTexture2DWithSize(bufferTexSize,kCCTexture2DPixelFormat_RGBA8888,0.5,0.5,0.5,1);
bufferTexDest=createCCTexture2DWithSize(bufferTexSize,kCCTexture2DPixelFormat_RGBA8888,0.5,0.5,0.5,1);
bufferTexTemp=createCCTexture2DWithSize(bufferTexSize,kCCTexture2DPixelFormat_RGBA8888,0.5,0.5,0.5,1);
//set texture params
ccGLBindTexture2D(bufferTexSource->getName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//GL_NEAREST
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);//GL_NEAREST
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
ccGLBindTexture2D(bufferTexDest->getName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
ccGLBindTexture2D(bufferTexTemp->getName());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//create shaders
//updateRipple shader
{
GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathForFilename("updateRipple.fsh").c_str())->getCString();
CCGLProgram* pProgram = new CCGLProgram();
pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource);
//bind attribute
pProgram->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
pProgram->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
pProgram->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
//link (must after bindAttribute)
pProgram->link();
//get cocos2d-x build-in uniforms
pProgram->updateUniforms();
//get my own uniforms
map<string,GLint> myUnifoMap;
myUnifoMap["texSource"] =glGetUniformLocation(pProgram->getProgram(),"texSource");
myUnifoMap["texDest"] = glGetUniformLocation(pProgram->getProgram(),"texDest");
myUnifoMap["step_s"] = glGetUniformLocation(pProgram->getProgram(),"step_s");
myUnifoMap["step_t"] = glGetUniformLocation(pProgram->getProgram(),"step_t");
myUnifoMap["touchPos_winSpace"] = glGetUniformLocation(pProgram->getProgram(),"touchPos_winSpace");
myUnifoMap["touchValid"] = glGetUniformLocation(pProgram->getProgram(),"touchValid");
myUnifoMap["winSize"] = glGetUniformLocation(pProgram->getProgram(),"winSize");
myUnifoMap["bufferTexSize"] = glGetUniformLocation(pProgram->getProgram(),"bufferTexSize");
//make program_updateRipple
program_updateRipple.myUnifoMap=myUnifoMap;
program_updateRipple.setProgram(pProgram);
//program can be released
pProgram->release();
//check gl error
CHECK_GL_ERROR_DEBUG();
}
//renderRipple shader
{
GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathForFilename("renderRipple.fsh").c_str())->getCString();
CCGLProgram* pProgram = new CCGLProgram();
pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource);
//bind attribute
pProgram->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
pProgram->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
pProgram->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
//link (must after bindAttribute)
pProgram->link();
//get cocos2d-x build-in uniforms
pProgram->updateUniforms();
//get my own uniforms
map<string,GLint> myUnifoMap;
myUnifoMap["texSource"] = glGetUniformLocation(pProgram->getProgram(),"texSource");
myUnifoMap["step_s"] = glGetUniformLocation(pProgram->getProgram(),"step_s");
myUnifoMap["step_t"] = glGetUniformLocation(pProgram->getProgram(),"step_t");
//make program_renderRipple
program_renderRipple.myUnifoMap=myUnifoMap;
program_renderRipple.setProgram(pProgram);
//program can be released
pProgram->release();
//check gl error
CHECK_GL_ERROR_DEBUG();
//.........这里部分代码省略.........