]> git.tdb.fi Git - gldbg.git/blob - flavors/gl/source/texturestate.h
More complete support for textures
[gldbg.git] / flavors / gl / source / texturestate.h
1 #ifndef TEXTURESTATE_H_
2 #define TEXTURESTATE_H_
3
4 #include <string>
5 #include <vector>
6 #include "opengl.h"
7 #include "autoconstptr.h"
8
9 struct TexImageState
10 {
11         unsigned width;
12         unsigned height;
13         unsigned depth;
14         GLenum internal_format;
15
16         TexImageState();
17
18         void set_1d(GLenum, unsigned);
19         void set_2d(GLenum, unsigned, unsigned);
20         void set_3d(GLenum, unsigned, unsigned, unsigned);
21         std::string describe() const;
22 };
23
24 extern GLenum texture_cube_faces[6];
25
26 struct TextureState
27 {
28         unsigned id;
29         GLenum target;
30         std::vector<TexImageState> images;
31         GLenum min_filter;
32         GLenum mag_filter;
33         GLenum wrap_s;
34         GLenum wrap_t;
35         GLenum wrap_r;
36         GLenum compare_mode;
37         GLenum compare_func;
38         bool generate_mipmap;
39
40         TextureState();
41
42         TexImageState &get_image(unsigned);
43         void set_image_1d(unsigned, GLenum, unsigned);
44         void set_image_2d(unsigned, GLenum, unsigned, unsigned);
45         void set_face_image_2d(GLenum, unsigned, GLenum, unsigned, unsigned);
46         void set_image_3d(unsigned, GLenum, unsigned, unsigned, unsigned);
47         void create_mipmaps(unsigned = 0);
48         void set_parameter(GLenum, const int *);
49         std::string describe() const;
50 };
51
52 struct TexUnitState
53 {
54         struct Binding
55         {
56                 bool enabled;
57                 AutoConstPtr<TextureState> current;
58
59                 Binding();
60                 std::string describe() const;
61         };
62
63         Binding binding_1d;
64         Binding binding_2d;
65         Binding binding_3d;
66         Binding binding_cube;
67
68         Binding *get_binding(GLenum);
69         const Binding *get_binding(GLenum) const;
70         void set_current_texture(GLenum, TextureState *);
71         TextureState *get_current_texture(GLenum);
72         const TextureState *get_current_texture(GLenum) const;
73         bool is_enabled(GLenum) const;
74         std::string describe_binding(GLenum) const;
75 };
76
77 #endif