1 #include <msp/gl/extensions/ext_texture_array.h>
3 #include "texture2darray.h"
10 Texture2DArray::Texture2DArray():
11 Texture3D(GL_TEXTURE_2D_ARRAY)
13 static Require _req(EXT_texture_array);
16 void Texture2DArray::layer_image(unsigned level, unsigned z, const void *data)
18 if(level>=levels || z>=depth)
19 throw out_of_range("Texture2DArray::layer_image");
21 LinAl::Vector<unsigned, 3> size = get_level_size(level);
22 sub_image(level, 0, 0, z, size.x, size.y, 1, data);
25 void Texture2DArray::layer_image(unsigned level, unsigned z, const Graphics::Image &img)
28 throw invalid_operation("Texture2DArray::layer_image");
30 unsigned w = img.get_width();
31 unsigned h = img.get_height();
32 if(w!=get_width() || h!=get_height())
33 throw incompatible_data("Texture2DArray::layer_image");
34 PixelFormat fmt = pixelformat_from_image(img);
35 if(get_components(fmt)!=get_components(format) || get_component_type(fmt)!=get_component_type(format))
36 throw incompatible_data("Texture2DArray::layer_image");
38 layer_image(level, z, img.get_pixels());
42 Texture2DArray::Loader::Loader(Texture2DArray &t):
43 DataFile::DerivedObjectLoader<Texture2DArray, Texture3D::Loader>(t)
48 Texture2DArray::Loader::Loader(Texture2DArray &t, Collection &c):
49 DataFile::DerivedObjectLoader<Texture2DArray, Texture3D::Loader>(t, c)
54 void Texture2DArray::Loader::init()
56 add("external_image", &Loader::external_image);
59 void Texture2DArray::Loader::external_image(unsigned z, const string &fn)
62 load_external_image(img, fn);
63 obj.layer_image(0, z, img);