3 This file is part of libmspgl
4 Copyright © 2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
10 #include "texturing.h"
16 Texturing::~Texturing()
22 void Texturing::attach(unsigned attch, const Texture &tex)
24 set_attachment(attch, &tex, 0);
27 void Texturing::attach(unsigned attch, const Texture &tex, const TexEnv &env)
29 set_attachment(attch, &tex, &env);
32 void Texturing::detach(unsigned attch)
34 set_attachment(attch, 0, 0);
37 void Texturing::set_attachment(unsigned attch, const Texture *tex, const TexEnv *env)
39 if(attch>=TexUnit::get_n_units())
40 throw InvalidParameterValue("Invalid texture attachment");
42 if(attachments.size()<=attch)
43 attachments.resize(attch+1);
45 attachments[attch].tex = tex;
46 attachments[attch].env = env;
49 bind_attachment(attch);
52 void Texturing::bind_attachment(unsigned i) const
54 const Attachment &attch = attachments[i];
66 void Texturing::unbind_attachment(unsigned i)
73 void Texturing::bind() const
75 const Texturing *old = current();
78 for(unsigned i=0; i<attachments.size(); ++i)
82 for(unsigned i=attachments.size(); i<old->attachments.size(); ++i)
88 void Texturing::unbind()
90 const Texturing *old = current();
93 for(unsigned i=old->attachments.size(); i--;)
99 Texturing::Attachment::Attachment():