GLint maxUniformLen;
GLint numUniforms;
GLint index;
glGetProgramiv(this->_program, GL_ACTIVE_UNIFORMS, &numUniforms);
glGetProgramiv(this->_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLen);
GLchar* uniformName = (GLchar*)malloc(sizeof(GLchar)*maxUniformLen);
for(index = 0; index < numUniforms; index++)
{
GLint size;
GLenum type;
GLint location;
GLint length;
glGetActiveUniform(this->_program, index, maxUniformLen, &length, &size, &type, uniformName);
location = glGetUniformLocation(this->_program, uniformName);
switch(type)
{
case GL_FLOAT:
//
break;
case GL_FLOAT_VEC2:
//
break;
case GL_FLOAT_VEC3:
//
break;
case GL_FLOAT_VEC4:
//
break;
case GL_INT:
//
break;
//.....all type
default:
//
break;
}
}
free(uniformName);
时间: 2024-10-09 23:21:40