PDA

View Full Version : Same shader on multiple objects w/ different uniforms



gbiv
12-12-2005, 02:45 PM
This is a simple question, is it possible to render multiple objects with the same shader BUT modify the value of a uniform between objects? For example:

myDisplay()
{
...
enbleShader("simple");
shader("simple")->setUniform("color")= blue;
drawQuad();
shader("simple")->setUniform("color")= red;
drawQuad();
shader("simple")->setUniform("color")= green;
drawQuad();
disableShader("simple");
...
}

Obviously this isn't exact code but hopefully it is clear enough to explain my question. I'm having problems implementing something I thought was easy but it's not working so I want to eliminate the obvious before diving into full debug mode...
thanks,
biv

Zulfiqar Malik
12-12-2005, 08:24 PM
Yes you can.

Fastian
12-15-2005, 01:27 AM
Yes. Consider OpenGL like a state machine. You set a shader and all the remaining draw calls will use that shader. If you change the shader state at some point, all the remaining calls after that will use the new states. Hope you get the point.

gbiv
12-15-2005, 12:55 PM
thanks. that's what I thought but I wanted to be sure. I think this has something to do w/ the scene graph API I'm using so I'll post there. Thanks for the "re-assurance" :)