]> git.tdb.fi Git - libs/gl.git/blob - source/core/texunit.h
6253d8d914f52c85f7f9eec6a4beae0fcd733722
[libs/gl.git] / source / core / texunit.h
1 #ifndef MSP_GL_TEXUNIT_H_
2 #define MSP_GL_TEXUNIT_H_
3
4 #include <vector>
5
6 namespace Msp {
7 namespace GL {
8
9 class Sampler;
10 class Texture;
11
12 /**
13 Keeps track of texture unit related state.  Intended for internal use.
14 */
15 class TexUnit
16 {
17 private:
18         unsigned index;
19         const Texture *texture;
20         const Sampler *sampler;
21
22         static std::vector<TexUnit> units;
23         static TexUnit *cur_unit;
24
25         TexUnit();
26
27 public:
28         unsigned get_index() const { return index; }
29         bool set_texture(const Texture *);
30         const Texture *get_texture() const { return texture; }
31         bool set_sampler(const Sampler *);
32         const Sampler *get_sampler() const { return sampler; }
33         void bind();
34
35         static unsigned get_n_units();
36         static TexUnit &get_unit(unsigned);
37         static TexUnit &current();
38         static TexUnit *find_unit(const Texture *);
39 };
40
41 } // namespace GL
42 } // namespace Msp
43
44 #endif