But with the new version of cocos2d-x things have changed…
The GLProgram class was replaced by an abstract Program class.
From the “how to migrate” guide I didn’t really understand how I can change my code in the new version.
I’m not very keen in this low level stuff so i don’t understand how to do it!
I noticed that the Program class has a constructor that accept the two shader and vertex files that i was passing to the old GLProgram so I assume I can do it in some similar way.
Do I have to specialize the abstract Program class? If so, what methods do I have to implement?
It seems very hard
Can you post your vertex and fragment shader code too, or at the very least a section of them that contains all the attributes you’re using (the ones you’re passing to bindAttribLocation)? It would help figure out what it is you’re trying to do. Check this post to see if it helps in any way.
Also, are you using cocos2d-x 4.0 release, or the latest source from github? The latest code on github has some significant changes related to how the you use the shaders, along with bug fixes.
I’m using the release version.
I managed to adapt my code as your link showed but I think I’m using some variables that are no longer declared: error: 'CC_MVPMatrix' undeclared
Since I more or less copy-pasted those file without knowing what they really did I’m stuck
I’m sorry for my im-noob-pls-help post
Am I missing something?
I Also tried to ply with the sin frequency and amplitude but nothing changes.
I also get this error in console:
cocos2d: ERROR: compileProgram: failed to link program OpenGL error 0x0501 in /home/carlo/Repos/illuminaticrewthegame/cocos2d/cocos/renderer/backend/opengl/TextureGL.cpp updateData 207
I don’t think it is related because I was getting it also before re-enabling my GLProgram but I post it anyways, maybe it has something to do
I was using the stable version and I tried to change it to the one on github but, again, nothing changes
Using the modified code I posted, this is what I get when I copy the scene to a RenderTexture, and place the sprite from the RenderTexture back into the same scene:
From the code you initially posted, I assumed you already knew how to do this, since you’re using a RenderTexture. Render whatever you need to a RenderTexture, then apply the ProgramState to that, which is what your sample code seemed to be doing.