Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)getUniforms
- {
- GLint maxUniformLength;
- GLint numberOfUniforms;
- char *uniformName;
- // Get the number of uniforms and the max length of their names
- glGetProgramiv(_program, GL_ACTIVE_UNIFORMS, &numberOfUniforms);
- glGetProgramiv(_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLength);
- _uniformArray = malloc(numberOfUniforms * sizeof(Uniform));
- _uniformArraySize = numberOfUniforms;
- for(int i = 0; i < numberOfUniforms; i++)
- {
- GLint size;
- GLenum type;
- GLint location;
- // Get the Uniform Info
- uniformName = malloc(sizeof(char) * maxUniformLength);
- glGetActiveUniform(_program, i, maxUniformLength, NULL, &size, &type, uniformName);
- _uniformArray[i].Name = uniformName;
- // Get the uniform location
- location = glGetUniformLocation(_program, uniformName);
- _uniformArray[i].Location = location;
- }
- }
Add Comment
Please, Sign In to add comment