]> git.tdb.fi Git - libs/gl.git/blob - source/texgen.h
Enhance the extension generator to support different APIs
[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         ~TexGen();
35
36         void set_mode(TexGenMode);
37         void set_plane(const Vector4 &);
38
39         void bind_to(TexCoordComponent c) const { bind_to(0, c); }
40         void bind_to(unsigned, TexCoordComponent) const;
41
42         static const TexGen *current(TexCoordComponent c) { return current(0, c); }
43         static const TexGen *current(unsigned, TexCoordComponent);
44         static void unbind_from(TexCoordComponent c) { unbind_from(0, c); }
45         static void unbind_from(unsigned, TexCoordComponent);
46 private:
47         static unsigned coord_index(TexCoordComponent);
48 };
49
50 } // namespace GL
51 } // namespace Msp
52
53 #endif