]> git.tdb.fi Git - libs/gl.git/blob - source/texture.h
Add Id tags and copyright notices to files
[libs/gl.git] / source / texture.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_TEXTURE_H_
9 #define MSP_GL_TEXTURE_H_
10
11 #include <GL/gl.h>
12 #include "types.h"
13
14 namespace Msp {
15 namespace GL {
16
17 enum TextureFilter
18 {
19         NEAREST                = GL_NEAREST,
20         LINEAR                 = GL_LINEAR,
21         NEAREST_MIPMAP_NEAREST = GL_NEAREST_MIPMAP_NEAREST,
22         NEAREST_MIPMAP_LINEAR  = GL_NEAREST_MIPMAP_LINEAR,
23         LINEAR_MIPMAP_NEAREST  = GL_LINEAR_MIPMAP_NEAREST,
24         LINEAR_MIPMAP_LINEAR   = GL_LINEAR_MIPMAP_LINEAR
25 };
26
27 enum TextureFormat
28 {
29         LUMINANCE8,
30         LUMINANCE8_ALPHA8,
31         RGB8,
32         RGBA8,
33         BGR8,
34         BGRA8
35 };
36
37 class Texture
38 {
39 public:
40         ~Texture();
41
42         void bind() const;
43         void parameter(GLenum, int);
44         void parameter(GLenum, float);
45         void set_min_filter(TextureFilter f) { parameter(GL_TEXTURE_MIN_FILTER, f); }
46         void set_mag_filter(TextureFilter f) { parameter(GL_TEXTURE_MAG_FILTER, f); }
47         GLenum get_target() const            { return target; }
48         uint  get_id() const                 { return id; }
49
50         static void unbind();
51 protected:
52         uint   id;
53         GLenum target;
54
55         Texture();
56         Texture(const Texture &);
57         Texture &operator=(const Texture &);
58         void maybe_bind() const;
59 };
60
61 } // namespace GL
62 } // namespace Msp
63
64 #endif