Skip to content

Instantly share code, notes, and snippets.

@krsmedlund
Last active December 17, 2015 17:49
Show Gist options
  • Save krsmedlund/5648392 to your computer and use it in GitHub Desktop.
Save krsmedlund/5648392 to your computer and use it in GitHub Desktop.
GLint nUniforms, nAttributes;
GLchar* label = new GLchar[128];
GLenum type;
GLsizei length(0);
GLint size(0);
glGetProgramiv(m_programId, GL_ACTIVE_UNIFORMS, &nUniforms);
std::cout << "\tActive uniforms ("<< yellow << nUniforms << "): ";
for (int i=0; i < nUniforms; ++i)
{
glGetActiveUniform(m_programId, i, 128, &length, &size, &type, label);
if (!length)
std::cerr << "Failed to read shader uniforms\n";
GLint loc = glGetUniformLocation(m_programId, label);
if (loc == -1)
std::cerr << "Can't find uniform location\n";
std::cout << label << " #" << loc << ":" << type;
if (i < nUniforms-1) std::cout << ", ";
}
std::cout << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment