11 Texturing::~Texturing()
17 void Texturing::attach(unsigned attch, const Texture &tex)
19 set_attachment(attch, &tex, 0);
22 void Texturing::attach(unsigned attch, const Texture &tex, const TexEnv &env)
24 set_attachment(attch, &tex, &env);
27 void Texturing::detach(unsigned attch)
29 set_attachment(attch, 0, 0);
32 void Texturing::set_attachment(unsigned attch, const Texture *tex, const TexEnv *env)
34 if(attch>=TexUnit::get_n_units())
35 throw out_of_range("Texturing::set_attachment");
37 if(attachments.size()<=attch)
38 attachments.resize(attch+1);
40 attachments[attch].tex = tex;
41 attachments[attch].env = env;
44 bind_attachment(attch);
47 void Texturing::bind_attachment(unsigned i) const
49 const Attachment &attch = attachments[i];
51 attch.tex->bind_to(i);
53 Texture::unbind_from(i);
55 attch.env->bind_to(i);
57 TexEnv::unbind_from(i);
60 void Texturing::unbind_attachment(unsigned i)
62 Texture::unbind_from(i);
63 TexEnv::unbind_from(i);
66 void Texturing::bind() const
68 const Texturing *old = current();
71 for(unsigned i=0; i<attachments.size(); ++i)
75 for(unsigned i=attachments.size(); i<old->attachments.size(); ++i)
81 void Texturing::unbind()
83 const Texturing *old = current();
86 for(unsigned i=old->attachments.size(); i--;)
92 Texturing::Attachment::Attachment():