X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture2d.cpp;h=b3caf509ec3108b1d418c8298186d1e795d2cb03;hb=4ae2ffa3057af9524a84ba322c0db32d6fcae8f2;hp=6e7d97202f341cc12e2a76d9e94b92f840c3ff94;hpb=0d765be40336decc966932e0143fe9496f3eab4b;p=libs%2Fgl.git diff --git a/source/core/texture2d.cpp b/source/core/texture2d.cpp index 6e7d9720..b3caf509 100644 --- a/source/core/texture2d.cpp +++ b/source/core/texture2d.cpp @@ -50,7 +50,11 @@ Texture2D::~Texture2D() 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"); @@ -160,10 +164,7 @@ void Texture2D::image(const Graphics::Image &img, unsigned lv, bool from_buffer) 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);