m1m8

Bind Attributes

Oct 3rd, 2019
787
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. std::map <const char*, GLint> shaderMap;
  2.  
  3. void TheShader::BindAttributes(const char* attribute)
  4. {
  5.     auto it = shaderMap.find(attribute);
  6.  
  7.     //add vertex attribute to the map if it can't be found
  8.     if (it == shaderMap.end())
  9.     {
  10.         shaderMap[attribute] = glGetAttribLocation(m_shaderProgramID, attribute);
  11.     }
  12. }
  13.  
  14. void TheShader::BindUniform(const char* attribute)
  15. {
  16.     auto it = shaderMap.find(attribute);
  17.  
  18.     //add uniform data to the map if it can't be found
  19.     if (it == shaderMap.end())
  20.     {
  21.         shaderMap[attribute] = glGetUniformLocation(m_shaderProgramID, attribute);
  22.     }
  23. }
RAW Paste Data