However i got a problem, with some (no moving) “sprites” its worked fine, but with others (moving or not), maybe the shader has altered the position of sprite so it dose not show correctly.
I have the position moving problem too. the distance of offset seems like random.
As below: the button should be on the point A, but it moves to point B. The response area of the button remains on point A.
I re-check the default GLProgram of Sprite. It turn out to be SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP( what is it? it’s a key of a GLProgram, u can search in project libcocos2d.) rather than SHADER_NAME_POSITION_TEXTURE_COLOR witch is the default shader in cocos2dx_2.x.
The difference of them is that SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP shader use the vect file ccShader_PositionTextureColor_noMVP.vert in the folder {cocos2dx_3.x_root}\cocos\renderer. So, replace the gray.vsh.zip file with the ccShader_PositionTextureColor_noMVP.vert file. Everything will be OK!
@yuye I downloaded the files and copied the sample code, try them on another version (version 3.1.1), badly, it doesn’t work, crash when i execute the sample code(platform: Win 7 64 bit ). I have poor knowledge about OpenGL, and I just wanna make the sprite gray. can you show me what should I do? thx.
@C_U_Again Actually there is a sample test EffectGreyScale in cpp-tests now. If you just wanna do a quick test for greying sprites, you can check it in ShaderTest2.cpp.
Edit: you can see shaders used in function GLProgramCache::loadDefaultGLProgram. Each of the ccXXXXXX_vert and ccXXXXXX_frag constant strings are defined in the various .vert/.frag files, two of which were noted above.
@stevetranby, Hey, I’m still confused about the “Reload Default GL Program”, why it calls reset() then load those default GL program? And why there is no p->reset() between line 285 and 286?