]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/texturecube.cpp
Enable creation of SPIR-V modules from GLSL source code
[libs/gl.git] / source / core / texturecube.cpp
index d006e383cc998af09fa478b18bb8bc4ce047ecfc..1c6c4962e46a1a3eb4b0c8817beed3dcfb726b9f 100644 (file)
@@ -54,7 +54,11 @@ TextureCube::TextureCube():
 void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv)
 {
        if(size>0)
-               throw invalid_operation("TextureCube::storage");
+       {
+               if(fmt!=format || sz!=size || (lv && lv!=levels))
+                       throw incompatible_data("TextureCube::storage");
+               return;
+       }
        if(sz==0)
                throw invalid_argument("TextureCube::storage");
 
@@ -79,7 +83,7 @@ void TextureCube::allocate(unsigned level)
                BindRestore _bind(this);
                glTexStorage2D(target, levels, storage_fmt, size, size);
                apply_swizzle();
-               allocated |= (1<<levels)-1;
+               allocated |= (64<<levels)-1;
        }
        else
        {
@@ -169,17 +173,12 @@ void TextureCube::image(TextureCubeFace face, const Graphics::Image &img)
 {
        unsigned w = img.get_width();
        unsigned h = img.get_height();
-       PixelFormat fmt = pixelformat_from_image(img);
-       if(size==0)
-       {
-               if(w!=h)
-                       throw incompatible_data("TextureCube::image");
-
-               storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w);
-       }
-       else if(w!=size || h!=size)
+       if(w!=h)
                throw incompatible_data("TextureCube::image");
 
+       PixelFormat fmt = pixelformat_from_image(img);
+       storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w);
+
        PixelStore pstore = PixelStore::from_image(img);
        BindRestore _bind_ps(pstore);