Does this mean that the item does not exist in the map? I was unable to find a documented answer showing that this was true.
Here is where I add to the map:
void Shader::addAttribute(const string attribute)
{
attributeList[attribute] = glGetAttribLocation(program, attribute.c_str());
}
I add to the map with:
shader.addAttribute("position");
Here is where I retrieve data from the map:
//An indexer that returns the location of the attribute
GLuint Shader::operator [](const string attribute)
{
return attributeList[attribute];
}
When I print the value in a debug log, I get “location is -1”
The value of whatever key you’re inserting into the map must be -1.
For:
What you’ve done here is you’ve assigned the value of
0to a key of5A map works by keys and values. It doesn’t look like you quite understand how they operate. Normally you would do something like this:
You’ve inserted a
-1into you map in this call:Because,
glGetAttribLocationreturns -1 when, as Benjamin stated above, “If the named attribute variable is not an active attribute in the specified program object or if name starts with the reserved prefix ‘gl‘, a value of -1 is returned.”_. you should be doing something like the following: