for(int i=0; i<=size*2; ++i)
factors[i] /= sum;
- blur_shdata_common.uniform1_array("factors[0]", size*2+1, &factors.front());
+ blur_shdata_common.uniform1_array("factors", size*2+1, &factors.front());
}
void Bloom::set_strength(float s)
int Program::get_uniform_location(const string &n) const
{
+ if(n[n.size()-1]==']')
+ throw invalid_argument("Program::get_uniform_location");
+
UniformMap::const_iterator i = uniforms.find(n);
if(i==uniforms.end())
- {
- if(n[n.size()-1]==']')
- {
- string::size_type open_bracket = n.rfind('[');
- if(open_bracket!=string::npos)
- {
- /* The requested name looks like an array. glGetActiveUniform only
- gives us the first element of the array, so try to look that up and
- add an offset. */
- unsigned offset = lexical_cast<unsigned>(n.substr(open_bracket+1, n.size()-2-open_bracket));
- i = uniforms.find(n.substr(0, open_bracket));
- if(i!=uniforms.end() && i->second.block->bind_point<0 && offset<i->second.size)
- return i->second.location+offset;
- }
- }
return -1;
- }
return i->second.block->bind_point<0 ? i->second.location : -1;
}
void ProgramData::uniform(const string &name, Uniform *uni)
{
+ if(name[name.size()-1]==']')
+ throw invalid_argument("ProgramData::uniform");
+
SlotMap::iterator i = uniform_slots.find(name);
if(i!=uniform_slots.end())
{