void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv)
{
if(width>0)
- throw invalid_operation("Texture2D::storage");
+ {
+ if(fmt!=format || wd!=width || ht!=height || (lv && lv!=levels))
+ throw incompatible_data("Texture2D::storage");
+ return;
+ }
if(wd==0 || ht==0)
throw invalid_argument("Texture2D::storage");
unsigned w = img.get_width();
unsigned h = img.get_height();
PixelFormat fmt = pixelformat_from_image(img);
- if(width==0)
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, lv);
- else if(w!=width || h!=height || (lv && lv!=levels))
- throw incompatible_data("Texture2D::image");
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, lv);
PixelStore pstore = PixelStore::from_image(img);
BindRestore _bind_ps(pstore);
void Texture2D::Loader::raw_data(const string &data)
{
+ if(obj.manager)
+ {
+ obj.set_manager(0);
+ if(!obj.id)
+ obj.generate_id();
+ }
obj.image(0, data.data());
}