PDA

View Full Version : Are uniform values saved when switching shaders?



TomCooksey
08-15-2008, 07:39 AM
Lets say I have 2 shader programs, A & B, and do the following:

1) Use program A
2) Set uniforms for program A
3) Render something
4) Use program B
5) Set uniforms for program B
6) Render something else

If I now want to render something with program A again, do I need to re-set all the uniforms it uses, or will the uniforms be restored automatically? The GL ES 2.0 spec doesn't mention it at all and the GL 2.0 spec only mentions that uniform values are stored as part of the program state (in section 2.15.5 - Required State).

Xmas
08-15-2008, 09:04 AM
Yes, uniform values are part of the program state. A uniform of a program will keep its value until you change it.

Phippu
04-05-2010, 06:11 PM
Great, thanks a lot for that question!