|
马上注册,下载996引擎,与更多游戏开发者交流。
您需要 登录 才可以下载或查看,没有账号?注册
×
-- 顶点shader
local 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无法显示 |
|