ofShader, the shader program is being applied outside begin-end block

Hi,

I’m new in OF, I’ve been playing a bit with the Kinect and doing some experience with GLSL shaders on Linux.
I’m having a problem, that is, I cannot restrict my shader program to run over a specific mesh… I followed the shaders tutorial, but it seems the begin()-end() block is not working to me… I have no idea why, I guess I’m doing something stupid but I cannot realize what it is.

Expected: Apply the shader to the first mesh, and leave the second without any shader.
Actual: The shader is taking effect on both meshes (mesh and mesh2).

Here’s my code…

Thanks in advance!

Still getting stuck on this… the only thing that worked for me is to pass a uniform (an integer) to the shader and use it as a conditional to “chose” which mesh affect and how render it. But I know that is not the correct way.
… any clue? am I doing something wrong?

Not really sure. From a quick scan it looks like your mesh2 should be unaffected.

Have you tried distilling this down to something more minimal? Maybe just doing something like:

shader.begin();
shader.end();
mesh2.drawVertices();

And maybe making the shader something super-simple (like one that just colours everything red).

1 Like

Hi @admsyn, thanks for your reply! I wasn’t able to continue with this until this weekend. I finally moved to a different computer (from a oldie Ubuntu netbook to a Mountain Lion Macbook Pro). I had to update the shaders syntax from version 1.2 to 1.5 … also get rid of the ofAppGlutWindow declaration (that seemed to be necessary for Linux but was making GLSL to crash on my Mac).
With these changes, and on this new computer, the shaders are working fine as expected - respecting the blocks begin() & end(). I tried again on the old computer with any of these changes separately and I didn’t get any favorable result.
So I think this must be a bug on that specific hardware/GLSL version.
If anyone has the same problem and is interested on seeing the changes I made, here’s the commit:
https://github.com/gerardobort/openframeworks-kinect-demos/commit/f4866a9f2a605bd21c07639baceab63ba5f07777

Thanks!