1 #ifndef MSP_GL_TEXTURE3D_H_
2 #define MSP_GL_TEXTURE3D_H_
5 #include <msp/linal/vector.h>
12 Three-dimensional texture. Consists of an array of texels in the shape of a
13 right cuboid. Texture coordinates have a principal range of [0, 1].
15 class Texture3D: public Texture
18 class Loader: public Msp::DataFile::DerivedObjectLoader<Texture3D, Texture::Loader>
22 Loader(Texture3D &, Collection &);
26 void raw_data(const std::string &);
27 void storage(PixelFormat, unsigned, unsigned, unsigned);
28 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);
57 void allocate_(unsigned);
60 /** Updates the contents of the entire texture. Storage must be defined
61 beforehand. The image data must have dimensions and format matching the
63 void image(unsigned level, const void *data);
66 void image_(unsigned, const void *);
69 DEPRECATED void image(unsigned level, PixelComponents comp, DataType type, const void *data);
71 /** Updates a cuboid-shaped region of the texture. Storage must be defined
72 beforehand. The image data must be in a format mathing the defined storage
73 and the update region must be fully inside the texture. */
74 void sub_image(unsigned level, int x, int y, int z, unsigned wd, unsigned ht, unsigned dp, const void *data);
76 DEPRECATED void sub_image(unsigned level,
77 int x, int y, int z, unsigned wd, unsigned ht, unsigned dp,
78 PixelComponents comp, DataType type, const void *data);
80 /** Updates the contents of the entire texture from an image. If storage
81 has not been defined, it will be set to match the image. In this case the
82 image will be treated as a stack of square layers and its height must be
83 divisible by its width. Otherwise the image must match the defined
85 virtual void image(const Graphics::Image &, unsigned = 0);
89 unsigned get_width() const { return width; }
90 unsigned get_height() const { return height; }
91 unsigned get_depth() const { return depth; }
93 unsigned get_n_levels() const;
94 LinAl::Vector<unsigned, 3> get_level_size(unsigned) const;
97 virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
98 virtual UInt64 get_data_size() const;
99 virtual void unload() { }