]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/texturing.h
Rearrange soucre files into subdirectories
[libs/gl.git] / source / render / texturing.h
diff --git a/source/render/texturing.h b/source/render/texturing.h
new file mode 100644 (file)
index 0000000..0da3eae
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef MSP_GL_TEXTURING_H_
+#define MSP_GL_TEXTURING_H_
+
+#include <vector>
+#include "bindable.h"
+
+namespace Msp {
+namespace GL {
+
+class Texture;
+
+class Texturing: public Bindable<Texturing>
+{
+private:
+       struct Attachment
+       {
+               unsigned unit;
+               const Texture *texture;
+               const Sampler *sampler;
+
+               Attachment(unsigned, const Texture *, const Sampler *);
+       };
+
+       std::vector<Attachment> attachments;
+
+public:
+       ~Texturing();
+
+       int find_free_unit(const std::string & = std::string()) const;
+       void attach(unsigned, const Texture &, const Sampler * = 0);
+       void attach(unsigned, const Sampler &);
+       void detach(unsigned);
+private:
+       void set_attachment(unsigned, const Texture *, const Sampler *);
+public:
+       const Texture *get_attached_texture(unsigned) const;
+       const Sampler *get_attached_sampler(unsigned) const;
+
+       void bind() const;
+
+       static void unbind();
+
+private:
+       void bind_attachment(const Attachment &) const;
+       static void unbind_attachment(unsigned);
+};
+
+} // namespace GL
+} // namespace Msp;
+
+#endif