]> git.tdb.fi Git - libs/gl.git/blob - source/texture.h
Add files
[libs/gl.git] / source / texture.h
1 #ifndef MSP_GL_TEXTURE_H_
2 #define MSP_GL_TEXTURE_H_
3
4 #include <GL/gl.h>
5 #include "types.h"
6
7 namespace Msp {
8 namespace GL {
9
10 enum TextureFilter
11 {
12         NEAREST                = GL_NEAREST,
13         LINEAR                 = GL_LINEAR,
14         NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST,
15         NEAREST_MIPMAP_LINEAR  = GL_NEAREST_MIPMAP_LINEAR,
16         LINEAR_MIPMAP_NEAREST  = GL_LINEAR_MIPMAP_NEAREST,
17         LINEAR_MIPMAP_LINEAR   = GL_LINEAR_MIPMAP_LINEAR
18 };
19
20 enum TextureFormat
21 {
22         LUMINANCE8,
23         LUMINANCE8_ALPHA8,
24         RGB8,
25         RGBA8,
26         BGR8,
27         BGRA8
28 };
29
30 class Texture
31 {
32 public:
33         void bind() const;
34         void parameter(GLenum, int);
35         void parameter(GLenum, float);
36         void set_min_filter(TextureFilter f) { parameter(GL_TEXTURE_MIN_FILTER, f); }
37         void set_mag_filter(TextureFilter f) { parameter(GL_TEXTURE_MAG_FILTER, f); }
38         uint  get_id() const                 { return id; }
39         sizei get_width(int =0) const;
40         sizei get_height(int =0) const;
41         sizei get_depth(int =0) const;
42         ~Texture();
43 protected:
44         uint   id;
45         GLenum target;
46
47         Texture();
48
49         static const Texture *bound;
50 };
51
52 } // namespace GL
53 } // namespace Msp
54
55 #endif