]> git.tdb.fi Git - libs/gl.git/blob - source/texgen.h
Always bind textures in a specific texture unit
[libs/gl.git] / source / texgen.h
1 #ifndef MSP_GL_TEXGEN_H_
2 #define MSP_GL_TEXGEN_H_
3
4 #include "gl.h"
5 #include "vector.h"
6
7 namespace Msp {
8 namespace GL {
9
10 enum TexCoordComponent
11 {
12         SCOORD = GL_S,
13         TCOORD = GL_T,
14         RCOORD = GL_R,
15         QCOORD = GL_Q
16 };
17
18 enum TexGenMode
19 {
20         EYE_LINEAR = GL_EYE_LINEAR,
21         OBJECT_LINEAR = GL_OBJECT_LINEAR,
22         REFLECTION_MAP = GL_REFLECTION_MAP,
23         NORMAL_MAP = GL_NORMAL_MAP
24 };
25
26 class TexGen
27 {
28 private:
29         TexGenMode mode;
30         Vector4 plane;
31
32 public:
33         TexGen();
34
35         void set_mode(TexGenMode);
36         void set_plane(const Vector4 &);
37
38         void bind_to(TexCoordComponent c) const { bind_to(0, c); }
39         void bind_to(unsigned, TexCoordComponent) const;
40
41         static const TexGen *current(TexCoordComponent c) { return current(0, c); }
42         static const TexGen *current(unsigned, TexCoordComponent);
43         static void unbind_from(TexCoordComponent c) { unbind_from(0, c); }
44         static void unbind_from(unsigned, TexCoordComponent);
45 private:
46         static unsigned coord_index(TexCoordComponent);
47 };
48
49 } // namespace GL
50 } // namespace Msp
51
52 #endif