自定义着色器无法使用
-- 顶点shaderlocal vertex = [[
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;
}
]]
-- 片段shader
local fragment= [[
#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 = c;
}
]]
local pProgram = cc.GLProgram:createWithByteArrays(vertex , fragment)
-- img为sprite
img:setGLProgram(pProgram)
调用img:setGLProgram(pProgram)后会导致img无法显示
页:
[1]