Guest User

Untitled

a guest
Sep 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. -(void)getUniforms
  2. {
  3. GLint maxUniformLength;
  4. GLint numberOfUniforms;
  5. char *uniformName;
  6.  
  7. // Get the number of uniforms and the max length of their names
  8. glGetProgramiv(_program, GL_ACTIVE_UNIFORMS, &numberOfUniforms);
  9. glGetProgramiv(_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLength);
  10.  
  11. _uniformArray = malloc(numberOfUniforms * sizeof(Uniform));
  12. _uniformArraySize = numberOfUniforms;
  13.  
  14. for(int i = 0; i < numberOfUniforms; i++)
  15. {
  16. GLint size;
  17. GLenum type;
  18. GLint location;
  19. // Get the Uniform Info
  20. uniformName = malloc(sizeof(char) * maxUniformLength);
  21. glGetActiveUniform(_program, i, maxUniformLength, NULL, &size, &type, uniformName);
  22. _uniformArray[i].Name = uniformName;
  23. // Get the uniform location
  24. location = glGetUniformLocation(_program, uniformName);
  25. _uniformArray[i].Location = location;
  26. }
  27. }
Add Comment
Please, Sign In to add comment