if(info.block->bind_point>=0)
throw invalid_argument("DefaultUniformBlock::attach");
- uniforms[info.location] = &uni;
+ attach(info.location, uni);
}
void DefaultUniformBlock::attach(int index, const Uniform &uni)
{
+ if(index<0)
+ return;
+
+ if(static_cast<unsigned>(index)>=uniforms.size())
+ uniforms.resize(index+1, 0);
uniforms[index] = &uni;
}
if(index>=0)
throw invalid_argument("DefaultUniformBlock::apply");
- for(map<int, const Uniform *>::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
- i->second->apply(i->first);
+ for(unsigned i=0; i<uniforms.size(); ++i)
+ if(uniforms[i])
+ uniforms[i]->apply(i);
}
class DefaultUniformBlock: public UniformBlock
{
private:
- std::map<int, const Uniform *> uniforms;
+ std::vector<const Uniform *> uniforms;
public:
DefaultUniformBlock();