After linking and enabling the shader program, use the following code to display the list of active uniforms:
- Start by querying for the number of active uniform variables:
GLint numUniforms = 0; glGetProgramInterfaceiv( handle, GL_UNIFORM, GL_ACTIVE_RESOURCES, &numUniforms);
- Loop through each uniform index and query for the length of the name, the type, the location, and the block index:
GLenum properties[] = {GL_NAME_LENGTH, GL_TYPE, GL_LOCATION, GL_BLOCK_INDEX}; std::cout << "Active uniforms" << std::endl; for( int i = 0; i < numUniforms; ++i ) { GLint results[4]; glGetProgramResourceiv(handle, GL_UNIFORM, i, 4, properties, 4, NULL, results); if( results[3] != -1 ) continue; // Skip uniforms in blocks GLint nameBufSize ...