1 #ifndef MSP_GL_TEXTURE2D_H_
2 #define MSP_GL_TEXTURE2D_H_
5 #include <msp/graphics/image.h>
7 #include "pixelformat.h"
14 Two-dimensional texture class. This is the most common type of texture.
16 class Texture2D: public Texture
19 class Loader: public Texture::Loader
24 void image_data(const std::string &);
25 void raw_data(const std::string &);
26 void storage(PixelFormat, unsigned, unsigned);
27 void storage_b(PixelFormat, unsigned, unsigned, unsigned);
40 Defines the texture storage. This function may only be successfully called
43 void storage(PixelFormat fmt, unsigned wd, unsigned ht);
45 /** Allocates texture storage. If storage has already been allocated, this
46 function does nothing. */
47 void allocate(unsigned level);
49 /** Uploads an image to the texture. storage() must have been called prior to
50 this, and the image must have dimensions conforming to the specified
51 storage. For level>0, mipmapping rules apply to the image dimensions. */
52 void image(unsigned level, PixelFormat fmt, DataType type, const void *data);
55 Uploads a sub-image into the texture. Unlike full image upload, there are
56 no constraints on the size of the sub-image.
58 void sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht, PixelFormat fmt, DataType type, const void *data);
61 Loads an image from a file and uploads it to the texture. If storage() has
62 not been called, the storage format will be set to match the loaded image.
64 void load_image(const std::string &fn);
66 unsigned get_width() const { return width; }
67 unsigned get_height() const { return height; }
70 void image(const Graphics::Image &);
71 void require_storage();
72 void get_level_size(unsigned, unsigned &, unsigned &);