Exemple #1
0
 /*
  * Handle situations where the application declares an array like
  *
  *   uniform vec4 myMatrix[4];
  *
  * then calls glGetUniformLocation(..., "myMatrix") and then infer the slot
  * numbers rather than explicitly calling glGetUniformLocation(...,
  * "myMatrix[0]"), etc.
  */
 T lookupUniformLocation(const T &key) {
     typename base_type::const_iterator it;
     it = base.upper_bound(key);
     if (it != base.begin()) {
         --it;
     } else {
         return (base[key] = key);
     }
     T t = it->second + (key - it->first);
     return t;
 }