views:

267

answers:

1

I'd like to get a list of all the uniforms & attribs used by a shader program object. glGetAttribLocation() & glGetUniformLocation() can be used to map a string to a location, but what I would really like is the list of strings without having to parse the glsl code.

Thanks NeARAZ!

Note: In OpenGL 2.0 glGetObjectParameteriv() is replaced by glGetProgramiv(). And the enum is GL_ACTIVE_UNIFORMS & GL_ACTIVE_ATTRIBUTES.

+7  A: 

Attributes:

// get count
glGetObjectParameterivA (shaderID, GL_OBJECT_ACTIVE_ATTRIBUTES, &count);
// for i in 0 to count:
glGetActiveAttrib (shaderID, i, bufSize, &length, &size, &type, name);
// ...

Uniforms:

// get count
glGetObjectParameteriv (shaderID, GL_OBJECT_ACTIVE_UNIFORMS, &count);
// for i in 0 to count:
glGetActiveUniform (shaderID, i, bufSize, &length, &size, &type, name);
// ...
NeARAZ