At the moment i just do:
someuniform1 = glGetUniformLocation(MyShaderName, "someuniform1");
someattribute1 = glGetAttribLocation(MyShaderName, "someattribute1");
But this method seems annoyingly repetitive, so i thought of using std::map:
Shaders[MyShaderName].Uniforms["someuniform1"] = glGetUniformLocation(MyShaderName, "someuniform1");
Shaders[MyShaderName].Attributes["someattribute1"] = glGetAttribLocation(MyShaderName, "someattribute1");
// i could add a function to remove the repetition of the two strings at both sides.
Is there any smarter/faster way of doing this? (to reduce repetition as much as possible).
--
Edit: I was thinking more about this idea, and i thought, wouldnt it be great if i just read the glsl source files, parse the uniform/attributes and set to my map automatically, without me need to write anything else than the glsl source!? Is this how the big boys do it?
Edit2: I am now parsing the GLSL shader files successfully, and using the std::map
method, i use single function call with one string param to get the address for uniforms/attributes at current enabled shader. in case i need more performance, i will cache the std::map
calls to other variables. But i would like to know if i am on the right track here... so please, any comments appreciated.