void glGetActiveAttrib( GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
- The same can be done for uniforms.
- You can query for the maximum string length, so the hard coded 16 is probably not best.
- Type: GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_FLOAT_MAT2, GL_FLOAT_MAT3, or GL_FLOAT_MAT4
- size: the size of the unit in the type of unit.
void PrintAttribs(GLuint prog) {
int count;
glGetProgramiv(prog, GL_ACTIVE_ATTRIBUTES, &count);
printf("Active Attributes: %d\n", count);
GLint size; // size of the variable
GLenum type; // type of the variable (float, vec3 or mat4, etc)
const GLsizei bufSize = 16; // maximum name length
GLchar name[bufSize]; // variable name in GLSL
GLsizei length; // name length
for (int i = 0; i < count; i++)
{
glGetActiveAttrib(prog, (GLuint)i, bufSize, &length, &size, &type, name);
cout << "Attribute " << i << " is " << type
<< " and is called " << name << endl;
}
return;
}