10 bool Texturing::legacy_used = true;
12 Texturing::~Texturing()
18 void Texturing::attach(unsigned attch, const Texture &tex)
20 set_attachment(attch, &tex);
23 void Texturing::detach(unsigned attch)
25 set_attachment(attch, 0);
28 void Texturing::set_attachment(unsigned attch, const Texture *tex)
30 if(attch>=TexUnit::get_n_units())
31 throw out_of_range("Texturing::set_attachment");
33 if(attachments.size()<=attch)
34 attachments.resize(attch+1);
36 attachments[attch] = tex;
39 bind_attachment(attch, legacy_used);
42 const Texture *Texturing::get_attached_texture(unsigned i) const
44 return i<attachments.size() ? attachments[i] : 0;
47 void Texturing::bind_attachment(unsigned i, bool legacy) const
49 if(const Texture *tex = attachments[i])
50 tex->bind_to(i, legacy);
52 Texture::unbind_from(i);
55 void Texturing::unbind_attachment(unsigned i)
57 Texture::unbind_from(i);
60 void Texturing::bind(bool legacy) const
62 const Texturing *old = current();
63 if(set_current(this) || legacy!=legacy_used)
66 for(unsigned i=0; i<attachments.size(); ++i)
67 bind_attachment(i, legacy);
70 for(unsigned i=attachments.size(); i<old->attachments.size(); ++i)
76 void Texturing::unbind()
78 const Texturing *old = current();
81 for(unsigned i=old->attachments.size(); i--;)