]> git.tdb.fi Git - libs/gl.git/blob - source/texunit.h
TexUnit's constructor shouldn't be public
[libs/gl.git] / source / 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 TexEnv;
10 class TexGen;
11 class Texture;
12
13 /**
14 Keeps track of texture unit related state.  Mostly for internal use.
15 */
16 class TexUnit
17 {
18 private:
19         unsigned index;
20         const Texture *texture;
21         const TexEnv *texenv;
22         const TexGen *texgen[4];
23
24         static std::vector<TexUnit> units;
25         static TexUnit *cur_unit;
26
27         TexUnit();
28
29 public:
30         unsigned get_index() const { return index; }
31         bool set_texture(const Texture *);
32         const Texture *get_texture() const { return texture; }
33         bool set_texenv(const TexEnv *);
34         const TexEnv *get_texenv() const { return texenv; }
35         bool set_texgen(unsigned, const TexGen *);
36         const TexGen *get_texgen(unsigned);
37         void bind();
38
39         static unsigned get_n_units();
40         static TexUnit &get_unit(unsigned);
41         static TexUnit &current();
42         static TexUnit *find_unit(const Texture *);
43         static TexUnit *find_unit(const TexEnv *);
44 };
45
46 } // namespace GL
47 } // namespace Msp
48
49 #endif