Check if an uniform exists

in my programs i have uniform variables like

uniform sampler2D u_Texture0;
uniform sampler2D u_Texture1;
uniform sampler2D u_Texture2;

i’d like to check after a shader has been compiled and linked, how many textures it expects. i thought i could use glGetUniformLocation(…) to check if an uniform exists, but the spec does not specify a return value for the case that a uniform was queried which does not exist. other ideas?

Read the OpenGL 2.0 specs again.

The call to enumerate active uniforms in a linked program is glGetActiveUniform.
glGetUniformLocation will return -1 for all unreferenced uniforms. Non existing ones cannot be referenced, so will return -1 as well.
Calling glUniform on location -1 is a special case which is ignored without GL error.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.