]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturing.h
Add a Texturing class to encapsulate the state of multiple texturing units
[libs/gl.git] / source / texturing.h
diff --git a/source/texturing.h b/source/texturing.h
new file mode 100644 (file)
index 0000000..c51782b
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2010  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_TEXTURING_H_
+#define MSP_GL_TEXTURING_H_
+
+#include <vector>
+#include "bindable.h"
+
+namespace Msp {
+namespace GL {
+
+class TexEnv;
+class Texture;
+
+class Texturing: public Bindable<Texturing>
+{
+private:
+       struct Attachment
+       {
+               const Texture *tex;
+               const TexEnv *env;
+
+               Attachment();
+       };
+
+       std::vector<Attachment> attachments;
+
+public:
+       ~Texturing();
+
+       void attach(unsigned, const Texture &);
+       void attach(unsigned, const Texture &, const TexEnv &);
+       void detach(unsigned);
+private:
+       void set_attachment(unsigned, const Texture *, const TexEnv *);
+       void bind_attachment(unsigned) const;
+
+       static void unbind_attachment(unsigned);
+
+public:
+       void bind() const;
+
+       static void unbind();
+};
+
+} // namespace GL
+} // namespace Msp;
+
+#endif