]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/texture1d.cpp
Allow repeated storage calls with the same parameters
[libs/gl.git] / source / core / texture1d.cpp
index 1e90b6f7264d56d1f37c32afc9255157eca743b3..d472527c92322f4d05b0fe39640f7f91905133a9 100644 (file)
@@ -22,7 +22,11 @@ Texture1D::Texture1D():
 void Texture1D::storage(PixelFormat fmt, unsigned wd, unsigned lv)
 {
        if(width>0)
-               throw invalid_operation("Texture1D::storage");
+       {
+               if(fmt!=format || wd!=width || (lv && lv!=levels))
+                       throw incompatible_data("Texture1D::storage");
+               return;
+       }
        if(wd==0)
                throw invalid_argument("Texture1D::storage");
 
@@ -126,10 +130,7 @@ void Texture1D::image(const Graphics::Image &img, unsigned lv)
 
        unsigned w = img.get_width();
        PixelFormat fmt = pixelformat_from_image(img);
-       if(width==0)
-               storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, lv);
-       else if(w!=width)
-               throw incompatible_data("Texture1D::image");
+       storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, lv);
 
        image(0, img.get_pixels());
 }