- if(attachments.size()<=attch)
- attachments.resize(attch+1);
-
- attachments[attch] = tex;
-
- if(current()==this)
- bind_attachment(attch, legacy_used);
-}
-
-const Texture *Texturing::get_attached_texture(unsigned i) const
-{
- return i<attachments.size() ? attachments[i] : 0;
-}
-
-void Texturing::bind_attachment(unsigned i, bool legacy) const
-{
- if(const Texture *tex = attachments[i])
- tex->bind_to(i, legacy);
+ if(tex)
+ {
+ vector<Attachment>::iterator i;
+ for(i=attachments.begin(); (i!=attachments.end() && i->unit<=unit); ++i)
+ if(i->unit==unit)
+ {
+ i->texture = tex;
+ if(current()==this)
+ tex->bind_to(unit);
+ return;
+ }
+
+ attachments.insert(i, Attachment(unit, tex));
+ if(current()==this)
+ tex->bind_to(unit);
+ }