//染灰色
void GameTools::GrayShaderProgram(Node * node)
{
do{
const 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\
}";
GLProgram* pProgram = new GLProgram();
pProgram->initWithByteArrays(
ccPositionTextureColor_noMVP_vert
, pszFragSource);
node->setGLProgram(pProgram);
pProgram->release();
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->link();
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->updateUniforms();
CHECK_GL_ERROR_DEBUG();
} while (0);
}