function FreeCardTool:setNodeGray(node) local vertShaderByteArray = " ".. "attribute vec4 a_position; " .. "attribute vec2 a_texCoord; " .. "attribute vec4 a_color; ".. "#ifdef GL_ES ".. "varying lowp vec4 v_fragmentColor; ".. "varying mediump vec2 v_texCoord; ".. "#else " .. "varying vec4 v_fragmentColor; " .. "varying vec2 v_texCoord; ".. "#endif ".. "void main() ".. "{ " .. "gl_Position = CC_PMatrix * a_position; ".. "v_fragmentColor = a_color; ".. "v_texCoord = a_texCoord; ".. "}" local flagShaderByteArray = "#ifdef GL_ES " .. "precision mediump float; " .. "#endif " .. "varying vec4 v_fragmentColor; " .. "varying vec2 v_texCoord; " .. "void main(void) " .. "{ " .. "vec4 c = texture2D(CC_Texture0, v_texCoord); " .. "gl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g +0.0722*c.b); ".. "gl_FragColor.w = c.w; ".. "}" local glProgram = cc.GLProgram:createWithByteArrays(vertShaderByteArray,flagShaderByteArray) glProgram:bindAttribLocation(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION) glProgram:bindAttribLocation(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR) glProgram:bindAttribLocation(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_FLAG_TEX_COORDS) glProgram:link() glProgram:updateUniforms() node:setGLProgram( glProgram ) end
虽然是参数node不过暂时发现只对sprite有效,对文本竟然没有效果