9 Texture1D::Texture1D():
13 void Texture1D::storage(PixelFormat fmt, unsigned wd, unsigned lv)
17 if(fmt!=format || wd!=width || (lv && lv!=levels))
18 throw incompatible_data("Texture1D::storage");
22 throw invalid_argument("Texture1D::storage");
26 levels = get_n_levels();
28 levels = min(levels, lv);
33 void Texture1D::image(unsigned level, const void *data)
35 return sub_image(level, 0, get_level_size(level), data);
38 void Texture1D::sub_image(unsigned level, int x, unsigned wd, const void *data)
41 throw invalid_operation("Texture1D::sub_image");
43 throw out_of_range("Texture1D::sub_image");
45 Texture1DBackend::sub_image(level, x, wd, data);
48 void Texture1D::image(const Graphics::Image &img, unsigned lv)
50 if(img.get_height()!=1)
51 throw incompatible_data("Texture1D::image");
53 storage(pixelformat_from_image(img, use_srgb_format), img.get_width(), lv);
54 image(0, img.get_pixels());
57 unsigned Texture1D::get_n_levels() const
60 for(unsigned s=width; s; s>>=1, ++n) ;
64 unsigned Texture1D::get_level_size(unsigned level) const
69 uint64_t Texture1D::get_data_size() const
71 return id ? width*get_pixel_size(storage_fmt) : 0;
75 Texture1D::Loader::Loader(Texture1D &t):
76 DataFile::DerivedObjectLoader<Texture1D, Texture::Loader>(t)
81 Texture1D::Loader::Loader(Texture1D &t, Collection &c):
82 DataFile::DerivedObjectLoader<Texture1D, Texture::Loader>(t, c)
87 void Texture1D::Loader::init()
89 add("raw_data", &Loader::raw_data);
90 add("storage", &Loader::storage);
91 add("storage", &Loader::storage_levels);
94 void Texture1D::Loader::raw_data(const string &data)
96 obj.image(0, data.data());
99 void Texture1D::Loader::storage(PixelFormat fmt, unsigned w)
104 void Texture1D::Loader::storage_levels(PixelFormat fmt, unsigned w, unsigned l)
106 obj.storage(fmt, w, l);