9 void Texture1D::storage(PixelFormat fmt, unsigned wd, unsigned lv)
13 if(fmt!=format || wd!=width || (lv && lv!=levels))
14 throw incompatible_data("Texture1D::storage");
18 throw invalid_argument("Texture1D::storage");
22 levels = get_n_levels();
24 levels = min(levels, lv);
29 void Texture1D::image(unsigned level, const void *data)
31 return sub_image(level, 0, get_level_size(level), data);
34 void Texture1D::sub_image(unsigned level, int x, unsigned wd, const void *data)
37 throw invalid_operation("Texture1D::sub_image");
39 throw out_of_range("Texture1D::sub_image");
41 Texture1DBackend::sub_image(level, x, wd, data);
44 void Texture1D::image(const Graphics::Image &img, unsigned lv)
46 if(img.get_height()!=1)
47 throw incompatible_data("Texture1D::image");
49 storage(pixelformat_from_image(img, use_srgb_format), img.get_width(), lv);
50 image(0, img.get_pixels());
53 unsigned Texture1D::get_n_levels() const
56 for(unsigned s=width; s; s>>=1, ++n) ;
60 unsigned Texture1D::get_level_size(unsigned level) const
65 uint64_t Texture1D::get_data_size() const
67 return id ? width*get_pixel_size(storage_fmt) : 0;
71 Texture1D::Loader::Loader(Texture1D &t):
72 DataFile::DerivedObjectLoader<Texture1D, Texture::Loader>(t)
77 Texture1D::Loader::Loader(Texture1D &t, Collection &c):
78 DataFile::DerivedObjectLoader<Texture1D, Texture::Loader>(t, c)
83 void Texture1D::Loader::init()
85 add("raw_data", &Loader::raw_data);
86 add("storage", &Loader::storage);
87 add("storage", &Loader::storage_levels);
90 void Texture1D::Loader::raw_data(const string &data)
92 obj.image(0, data.data());
95 void Texture1D::Loader::storage(PixelFormat fmt, unsigned w)
100 void Texture1D::Loader::storage_levels(PixelFormat fmt, unsigned w, unsigned l)
102 obj.storage(fmt, w, l);