After linking and enabling the shader program, use the following code to display the list of active attributes:
- Start by querying for the number of active attributes:
GLint numAttribs; glGetProgramInterfaceiv(programHandle, GL_PROGRAM_INPUT,
GL_ACTIVE_RESOURCES, &numAttribs);
- Loop through each attribute, query for the length of the name, the type, and the attribute location, and print the results to standard out:
GLenum properties[] = {GL_NAME_LENGTH, GL_TYPE, GL_LOCATION}; std::cout << "Active attributes" << std::endl; for( int i = 0; i < numAttribs; ++i ) { GLint results[3]; glGetProgramResourceiv(programHhandle, GL_PROGRAM_INPUT,
i, 3, properties, 3, NULL, results); GLint nameBufSize = results[0] + 1; char * name = new char[nameBufSize]; glGetProgramResourceName(programHandle,
GL_PROGRAM_INPUT, i, nameBufSize, NULL, name);
printf("%-5d %s (%s)n", results[2], name,
getTypeString(results[1])); delete [] name; }