PDA

View Full Version : check if an uniform exists



Vexator
08-14-2006, 06:56 AM
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?

Relic
08-14-2006, 07:54 AM
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.