]> git.tdb.fi Git - libs/gl.git/blob - source/render/texturing.h
Rearrange soucre files into subdirectories
[libs/gl.git] / source / render / 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                 const Sampler *sampler;
20
21                 Attachment(unsigned, const Texture *, const Sampler *);
22         };
23
24         std::vector<Attachment> attachments;
25
26 public:
27         ~Texturing();
28
29         int find_free_unit(const std::string & = std::string()) const;
30         void attach(unsigned, const Texture &, const Sampler * = 0);
31         void attach(unsigned, const Sampler &);
32         void detach(unsigned);
33 private:
34         void set_attachment(unsigned, const Texture *, const Sampler *);
35 public:
36         const Texture *get_attached_texture(unsigned) const;
37         const Sampler *get_attached_sampler(unsigned) const;
38
39         void bind() const;
40
41         static void unbind();
42
43 private:
44         void bind_attachment(const Attachment &) const;
45         static void unbind_attachment(unsigned);
46 };
47
48 } // namespace GL
49 } // namespace Msp;
50
51 #endif