Original Post
I started recently making use of shaders in my project (DirectX, HLSL) and I'm having trouble figuring out how best (when and where) to set the various constants that the shaders depend on. I've only got like, two of them that I've made so far but I have stuff like effect->SetSomeConstant("SomeConstant", SOME_BIT_OF_INFORMATION_THAT_IS_NEVER_AVAILABLE_WHEN_I_WANT_IT) scattered absolutely everwhere. I'm vaguely envisioning some kind of callback system where I say MagicalMysteryBoxOfShaders->SetShaderConstant("SomeConstant", SOME_BIT_OF_INFORMATION_THAT_HOPEFULLY_IS_HANDY_NOW) and it loops through a list of pointers and updates them all (probably each frame). Is this a good idea? How do you do it? If I go ahead with this is there anything else that I could use this kind of system for (so I can design it somewhat generically) or am I going to have all this functionality (callbacks?) sitting around just to update shaders?