]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Throw an exception if Texture*::allocate is called before storage
[libs/gl.git] / source / texturecube.cpp
index 19c3bf074b9a3557adf7668c4752f22bda3bcb8c..b9a8f5dd02b8cacb73f63df7bce028a5920035cd 100644 (file)
@@ -64,6 +64,8 @@ void TextureCube::storage(PixelFormat fmt, unsigned sz)
 
 void TextureCube::allocate(unsigned level)
 {
+       if(size==0)
+               throw invalid_operation("TextureCube::allocate");
        if(allocated&(1<<level))
                return;
 
@@ -96,7 +98,7 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
                return sub_image(face, level, 0, 0, s, s, fmt, type, data);
 
        BindRestore _bind(this);
-       glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
+       glTexImage2D(face, level, ifmt, s, s, 0, get_upload_format(fmt), type, data);
 
        // XXX Allocation should be tracked per-face, but we'll run out of bits
        allocated |= 1<<level;
@@ -116,7 +118,7 @@ void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y,
        BindRestore _bind(this);
        allocate(level);
 
-       glTexSubImage2D(face, level, x, y, wd, ht, fmt, type, data);
+       glTexSubImage2D(face, level, x, y, wd, ht, get_upload_format(fmt), type, data);
 
        if(gen_mipmap && level==0)
                auto_generate_mipmap();