]> git.tdb.fi Git - libs/gl.git/blob - source/texture2d.h
Use DevIL for loading images
[libs/gl.git] / source / texture2d.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_TEXTURE2D_H_
9 #define MSP_GL_TEXTURE2D_H_
10
11 #include <string>
12 #include "pixelformat.h"
13 #include "texture.h"
14
15 namespace Msp {
16 namespace GL {
17
18 /**
19 Two-dimensional texture class.  This is the most common type of texture.
20 */
21 class Texture2D: public Texture
22 {
23 private:
24         PixelFormat ifmt;
25         sizei width;
26         sizei height;
27         int border;
28
29 public:
30         Texture2D();
31
32         /**
33         Defines the texture storage.  This function may only be successfully called
34         once.
35         */
36         void storage(PixelFormat fmt, sizei wd, sizei ht, int brd);
37         
38         /**
39         Uploads an image to the texture.  storage() must have been called prior to
40         this, and the image must have dimensions conforming to the specified
41         storage.
42         */
43         void image(int level, PixelFormat fmt, GLenum type, const void *data);
44
45         /**
46         Uploads a sub-image into the texture.  Unlike full image upload, there are
47         no constraints on the size of the sub-image.
48         */
49         void sub_image(int level, int x, int y, sizei wd, sizei ht, PixelFormat fmt, GLenum type, const void *data);
50
51         /**
52         Loads an image from a file and uploads it to the texture.  If storage() has
53         not been called, the storage format will be set to match the loaded image.
54         */
55         void load_image(const std::string &fn);
56
57         sizei get_width() const  { return width; }
58         sizei get_height() const { return height; }
59 };
60
61 } // namespace GL
62 } // namespace Msp
63
64 #endif