1 #ifndef MSP_GL_TEXTURE3D_H_
2 #define MSP_GL_TEXTURE3D_H_
11 Three-dimensional texture. Consists of an array of texels in the shape of a
12 right cuboid. Texture coordinates have a principal range of [0, 1].
14 class Texture3D: public Texture
17 class Loader: public Msp::DataFile::DerivedObjectLoader<Texture3D, Texture::Loader>
21 Loader(Texture3D &, Collection &);
25 void raw_data(const std::string &);
26 void storage(PixelFormat, unsigned, unsigned, unsigned);
41 /** Defines storage structure for the texture. Must be called before an
42 image can be uploaded. Once storage is defined, it can't be changed. */
43 void storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp);
45 /** Allocates storage for the texture. The contents are initially
46 undefined. If storage has already been allocated, does nothing. */
47 void allocate(unsigned level);
49 /** Uploads an image to the texture. Storage must be defined beforehand.
50 The image data must have dimensions and format compatible with the defined
52 void image(unsigned level, PixelFormat fmt, DataType type, const void *data);
54 /** Updates a cuboid-shaped region of the texture. Storage must be defined
55 and allocated beforehand. The update region must be fully inside the
57 void sub_image(unsigned level,
58 int x, int y, int z, unsigned wd, unsigned ht, unsigned dp,
59 PixelFormat fmt, DataType type, const void *data);
61 /** Loads an image from a file and uploads it to the texture. If storage
62 has not been defined, it will be set to match the loaded image. To
63 construct a three-dimensional texture from a two-dimensional image, the
64 image is interpreted as an array of consecutive images. If dp is -1, the
65 texture's width and height are equal. If dp is -2, the texture's height and
66 depth are equal. Otherwise, dp must be positive and determines the
67 texture's depth. In all cases, the image's height must equal the texture's
68 height times its depth.
70 Deprecated in favor of the base class version.*/
71 void load_image(const std::string &fn, int dp = -1);
73 using Texture::load_image;
75 /** Uploads an image to the texture. If storage has not been defined, it
76 will be set to match the image. In this case the image will be treated as
77 a stack of square layers and its height must be divisible by its width.
78 Otherwise the image must be compatible with the defined storage.
80 If srgb is true and storage is determined by this call, then an sRGB pixel
81 format will be used. */
82 virtual void image(const Graphics::Image &, bool = false);
84 unsigned get_width() const { return width; }
85 unsigned get_height() const { return height; }
86 unsigned get_depth() const { return depth; }
88 void get_level_size(unsigned, unsigned &, unsigned &, unsigned &);
91 virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
92 virtual UInt64 get_data_size() const;
93 virtual void unload() { }