I would like to set up a light properties structure in the vertex shader - something like
uniform vec4 ambientColors;
and then specify a light in the shader
Finally, I want to assign light properties from within the app program with
But this doesn’t work. It seems the uniform declaration of a structure member isn’t acceptable. Is this the case or am I missing something?
Remember: a struct doesn’t define variables; it is just a prototype.
Using C++ lingo
Foo::bar is a non-static member of the class
Foo. It therefore does not name a variable. However,
stuff.bar is a variable. It’s the use of a prototype that creates variables.
Uniforms are first and foremost variables. Therefore, a uniform cannot be inside of a prototype definition.
However, a uniform’s type can be a struct:
uniform Foo stuff;
stuff.bar is now a uniform variable. It has a specific uniform location. See the OpenGL Wiki for further details.
Thank you, Alfonse. That clears it up totally.