2 #include "texture2darray.h"
9 void Texture2DArray::layer_image(unsigned level, unsigned z, const void *data)
11 if(level>=n_levels || z>=depth)
12 throw out_of_range("Texture2DArray::layer_image");
14 LinAl::Vector<unsigned, 3> size = get_level_size(level);
15 sub_image(level, 0, 0, z, size.x, size.y, 1, data);
18 void Texture2DArray::layer_image(unsigned level, unsigned z, const Graphics::Image &img)
21 throw invalid_operation("Texture2DArray::layer_image");
23 unsigned w = img.get_width();
24 unsigned h = img.get_height();
25 if(w!=get_width() || h!=get_height())
26 throw incompatible_data("Texture2DArray::layer_image");
27 PixelFormat fmt = pixelformat_from_image(img);
28 if(get_components(fmt)!=get_components(format) || get_component_type(fmt)!=get_component_type(format))
29 throw incompatible_data("Texture2DArray::layer_image");
31 layer_image(level, z, img.get_pixels());
35 Texture2DArray::Loader::Loader(Texture2DArray &t):
36 DataFile::DerivedObjectLoader<Texture2DArray, Texture3D::Loader>(t)
41 Texture2DArray::Loader::Loader(Texture2DArray &t, Collection &c):
42 DataFile::DerivedObjectLoader<Texture2DArray, Texture3D::Loader>(t, c)
47 void Texture2DArray::Loader::init()
49 add("external_image", &Loader::external_image);
52 void Texture2DArray::Loader::external_image(unsigned z, const string &fn)
55 load_external_image(img, fn);
56 obj.layer_image(0, z, img);