SHARE
TWEET

Untitled

a guest Oct 21st, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void ES2::ShaderVariant::cache_attribute_locations()
  2. {
  3.     OPTICK_EVENT();
  4.  
  5.     assert(program_id > 0);
  6.  
  7.     int count = 0;
  8.     glGetProgramiv(program_id, GL_ACTIVE_ATTRIBUTES, &count);
  9.  
  10.     GLint size;
  11.     GLenum type;
  12.     const GLsizei buffer_size = 32;
  13.     GLchar name[buffer_size];
  14.     GLsizei length;
  15.  
  16.     for (int i = 0; i < count; ++i)
  17.     {
  18.         glGetActiveAttrib(program_id, (GLuint)i, buffer_size, &length, &size, &type, name);
  19.  
  20.         int location = glGetAttribLocation(program_id, name);
  21.         attribute_cache[std::string(name, length)] = location;
  22.     }
  23. }
  24.  
  25. void ES2::ShaderVariant::cache_uniform_locations()
  26. {
  27.     OPTICK_EVENT();
  28.  
  29.     assert(program_id > 0);
  30.  
  31.     int count = 0;
  32.     glGetProgramiv(program_id, GL_ACTIVE_UNIFORMS, &count);
  33.  
  34.     GLint size;
  35.     GLenum type;
  36.     const GLsizei buffer_size = 32;
  37.     GLchar name[buffer_size];
  38.     GLsizei length;
  39.  
  40.     for (int i = 0; i < count; ++i)
  41.     {
  42.         glGetActiveUniform(program_id, (GLuint)i, buffer_size, &length, &size, &type, name);
  43.  
  44.         int location = glGetUniformLocation(program_id, name);
  45.         uniform_cache[std::string(name, length)] = location;
  46.     }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top