1 #ifndef MSP_GL_TEXTURE3D_H_
2 #define MSP_GL_TEXTURE3D_H_
6 #include "pixelformat.h"
13 Three-dimensional texture. Consists of an array of texels in the shape of a
14 right cuboid. Texture coordinates have a principal range of [0, 1].
16 class Texture3D: public Texture
28 /** Defines storage structure for the texture. Must be called before an
29 image can be uploaded. Once storage is defined, it can't be changed. */
30 void storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp);
32 /** Allocates storage for the texture. The contents are initially
33 undefined. If storage has already been allocated, does nothing. */
34 void allocate(unsigned level);
36 /** Uploads an image to the texture. Storage must be defined beforehand.
37 The image data must have dimensions and format compatible with the defined
39 void image(unsigned level, PixelFormat fmt, DataType type, const void *data);
41 /** Updates a cuboid-shaped region of the texture. Storage must be defined
42 and allocated beforehand. The update region must be fully inside the
44 void sub_image(unsigned level,
45 int x, int y, int z, unsigned wd, unsigned ht, unsigned dp,
46 PixelFormat fmt, DataType type, const void *data);
48 /** Loads an image from a file and uploads it to the texture. If storage
49 has not been defined, it will be set to match the loaded image. To
50 construct a three-dimensional texture from a two-dimensional image, the
51 image is interpreted as an array of consecutive images. If dp is -1, the
52 texture's width and height are equal. If dp is -2, the texture's height and
53 depth are equal. Otherwise, dp must be positive and determines the
54 texture's depth. In all cases, the image's height must equal the texture's
55 height times its depth. */
56 void load_image(const std::string &fn, int dp = -1);
58 unsigned get_width() const { return width; }
59 unsigned get_height() const { return height; }
60 unsigned get_depth() const { return depth; }
62 void get_level_size(unsigned, unsigned &, unsigned &, unsigned &);