]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturing.cpp
Use a type registry to manage postprocessor types for pipeline templates
[libs/gl.git] / source / texturing.cpp
index db8ee65359a87993fe707fd0182bda4f210e1f51..77bb15435c7391a62a0298ea653f6699417eb55f 100644 (file)
@@ -7,6 +7,8 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
+bool Texturing::legacy_used = true;
+
 Texturing::~Texturing()
 {
        if(current()==this)
@@ -31,17 +33,21 @@ void Texturing::set_attachment(unsigned attch, const Texture *tex)
        if(attachments.size()<=attch)
                attachments.resize(attch+1);
 
-       attachments[attch].tex = tex;
+       attachments[attch] = tex;
 
        if(current()==this)
-               bind_attachment(attch);
+               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) const
+void Texturing::bind_attachment(unsigned i, bool legacy) const
 {
-       const Attachment &attch = attachments[i];
-       if(attch.tex)
-               attch.tex->bind_to(i);
+       if(const Texture *tex = attachments[i])
+               tex->bind_to(i, legacy);
        else
                Texture::unbind_from(i);
 }
@@ -51,13 +57,14 @@ void Texturing::unbind_attachment(unsigned i)
        Texture::unbind_from(i);
 }
 
-void Texturing::bind() const
+void Texturing::bind(bool legacy) const
 {
        const Texturing *old = current();
-       if(set_current(this))
+       if(set_current(this) || legacy!=legacy_used)
        {
+               legacy_used = legacy;
                for(unsigned i=0; i<attachments.size(); ++i)
-                       bind_attachment(i);
+                       bind_attachment(i, legacy);
                if(old)
                {
                        for(unsigned i=attachments.size(); i<old->attachments.size(); ++i)
@@ -76,10 +83,5 @@ void Texturing::unbind()
        }
 }
 
-
-Texturing::Attachment::Attachment():
-       tex(0)
-{ }
-
 } // namespace GL
 } // namespace Msp;