]> git.tdb.fi Git - libs/gl.git/blob - source/texture.h
Add vertex arrays and buffers
[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         ~Texture();
34
35         void bind() const;
36         void parameter(GLenum, int);
37         void parameter(GLenum, float);
38         void set_min_filter(TextureFilter f) { parameter(GL_TEXTURE_MIN_FILTER, f); }
39         void set_mag_filter(TextureFilter f) { parameter(GL_TEXTURE_MAG_FILTER, f); }
40         GLenum get_target() const            { return target; }
41         uint  get_id() const                 { return id; }
42
43         static void unbind();
44 protected:
45         uint   id;
46         GLenum target;
47
48         Texture();
49         Texture(const Texture &);
50         Texture &operator=(const Texture &);
51         void maybe_bind() const;
52 };
53
54 } // namespace GL
55 } // namespace Msp
56
57 #endif