Hello!
I am using the following code while loading my shaders, before linking... The 3 glBindAttribLocation calls at the beginning do all the job (they actually work), but the following listing does not show any attribs, because glGetProgramiv (_program, GL_ACTIVE_ATTRIBUTES, &numActiveAttribs) always returns 0 (zero) in the variable passed by reference. How can that be? My attribs are definitely working, otherwise I would not be able to see my shading and textures, etc... So, why does glGetProgramiv with GL_ACTIVE_ATTRIBUTES behave so strange? Can anybody help with fixing it please? Thanks in advance!
glBindAttribLocation (_program, GLKVertexAttribPosition, "position");
glBindAttribLocation (_program, GLKVertexAttribNormal, "normal");
glBindAttribLocation (_program, GLKVertexAttribTexCoord0, "texcoord0");
NSLog(@"Listing all bindAttribs:");
GLint numActiveAttribs = -1;
GLint maxAttribNameLength = -1;
glGetProgramiv (_program, GL_ACTIVE_ATTRIBUTES, &numActiveAttribs);
glGetProgramiv (_program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttribNameLength);
for (int i = 0; i < numActiveAttribs; ++i) {
int nameLength = -1, size = -1;
GLenum type = GL_ZERO;
char name[maxAttribNameLength];
glGetActiveAttrib (_program, i, maxAttribNameLength, &nameLength, &size, &type, name);
GLuint location = glGetAttribLocation(_program, name);
NSLog (@"%i: %s", location, name);
}