When you load a vertex and fragment shader in OpenGL you need to pass in data such as the current viewport transform, camera transform and lighting data. You do this via Uniform
variables.
Each of these Uniforms is addressed via a location which in true OpenGL style is a GLuint
. It’s pretty slow to get the location of a Uniform so it’s advisable to cache the location before using the shader in anger. Here is the code to get the location of all ACTIVE uniforms in a compiled and linked shader program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
The docs for glGetActiveUniform document the types returned in type
but in general it’s not useful information during runtime.
Note this only finds active uniforms so if you have a uniform declared but you don’t use it it’s stripped by the shader compiler and will not appear.
Comments