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);
27 void storage_levels(PixelFormat, unsigned, unsigned, unsigned, unsigned);
42 /** Defines storage structure for the texture. If lv is zero, the number
43 of mipmap levels is automatically determined from storage dimensions.
45 Must be called before an image can be uploaded. Once storage is defined,
46 it can't be changed. */
47 void storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp, unsigned lv = 0);
49 DEPRECATED void storage(PixelComponents c, unsigned w, unsigned h, unsigned d, unsigned l = 0)
50 { storage(make_pixelformat(c, UNSIGNED_BYTE), w, h, d, l); }
52 /** Allocates storage for the texture. The contents are initially
53 undefined. If storage has already been allocated, does nothing. */
54 void allocate(unsigned level);
56 /** Uploads an image to the texture. Storage must be defined beforehand.
57 The image data must have dimensions and format compatible with the defined
59 void image(unsigned level, PixelComponents, DataType type, const void *data);
61 /** Updates a cuboid-shaped region of the texture. Storage must be defined
62 and allocated beforehand. The update region must be fully inside the
64 void sub_image(unsigned level,
65 int x, int y, int z, unsigned wd, unsigned ht, unsigned dp,
66 PixelComponents comp, DataType type, const void *data);
68 /** Uploads an image to the texture. If storage has not been defined, it
69 will be set to match the image. In this case the image will be treated as
70 a stack of square layers and its height must be divisible by its width.
71 Otherwise the image must be compatible with the defined storage.
73 If srgb is true and storage is determined by this call, then an sRGB pixel
74 format will be used. */
75 virtual void image(const Graphics::Image &, unsigned, bool = false);
79 unsigned get_width() const { return width; }
80 unsigned get_height() const { return height; }
81 unsigned get_depth() const { return depth; }
83 unsigned get_n_levels() const;
84 void get_level_size(unsigned, unsigned &, unsigned &, unsigned &) const;
87 virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
88 virtual UInt64 get_data_size() const;
89 virtual void unload() { }