]> git.tdb.fi Git - libs/gl.git/blob - source/texturing.h
Add a texunit statement which automatically determines the unit number
[libs/gl.git] / source / texturing.h
1 #ifndef MSP_GL_TEXTURING_H_
2 #define MSP_GL_TEXTURING_H_
3
4 #include <vector>
5 #include "bindable.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Texture;
11
12 class Texturing: public Bindable<Texturing>
13 {
14 private:
15         struct Attachment
16         {
17                 unsigned unit;
18                 const Texture *texture;
19
20                 Attachment(unsigned, const Texture *);
21         };
22
23         std::vector<Attachment> attachments;
24
25 public:
26         ~Texturing();
27
28         int find_free_unit(const std::string & = std::string()) const;
29         void attach(unsigned, const Texture &);
30         void detach(unsigned);
31 private:
32         void set_attachment(unsigned, const Texture *);
33 public:
34         const Texture *get_attached_texture(unsigned) const;
35
36         void bind() const;
37
38         static void unbind();
39 };
40
41 } // namespace GL
42 } // namespace Msp;
43
44 #endif