Skip to main content
GameDev.net gamedev.net
🔒 Locked

GLSL Array/Struct Parameter Enumeration

Started by cmdkeen Dec 8, 2005 at 12:02 PM 0 replies 2.7k views
Original Post
cmdkeen
cmdkeen
Hi, after creating an GLSL program I enumerate it's parameters using a simple "hacky" approach using glGetActiveUniformARB with increasing indices until I get an OpenGL error. Thus I have a list of all parameters of the current shader.


int index = 0;
while(true) {
   GLsizei size, length;
   GLenum type = 0;
   GLchar name[NAME_SIZE];
   glGetActiveUniformARB(program, index, NAME_SIZE, &length, &size, &type, name);
   
   if( type == 0 ) {
      break;
   }
   else {
      // add to parameter list
   }
   
   ++index;
}
This way I can successfully get all primitve parameters (int, vec2, samplers, ...). But I do not get array and struct parameters. Thus if I my shader contains the following paramters:

struct Foo {
   vec2 xy;
};

uniform vec4 someColor;
uniform Foo foo;
uniform vec4[3] arr;
I will only find "someColor". Is there a way to enumerate parameters of complex types, too? I could not even find information about enumerating GLSL parameters, so maybe my aprroach is a bit hacky.. but still I consider it important that my program is able to find all shader parameters automatically. (And I'd prefer not having to parse the whole shaders.. ;)) thanks in advance, sheijk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.