]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Simplify applying texture swizzling
[libs/gl.git] / source / texturecube.cpp
index bac60ffdd9612317ecfd3af6251ff78ef1aa3c93..8d194c42028bb6a4c6eb56cf2e9c0cb9567eba71 100644 (file)
@@ -78,6 +78,7 @@ void TextureCube::allocate(unsigned level)
        {
                BindRestore _bind(this);
                glTexStorage2D(target, levels, ifmt, size, size);
+               apply_swizzle();
                allocated |= (1<<levels)-1;
        }
        else
@@ -104,7 +105,10 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
        BindRestore _bind(this);
 
        if(!allocated)
+       {
                glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
+               apply_swizzle();
+       }
        glTexImage2D(face, level, ifmt, s, s, 0, get_upload_format(fmt), type, data);
 
        if(level==0)
@@ -271,6 +275,7 @@ void TextureCube::Loader::init()
        add("image_data", &Loader::image_data);
        add("raw_data", &Loader::raw_data);
        add("storage", &Loader::storage);
+       add("storage", &Loader::storage_levels);
 }
 
 void TextureCube::Loader::external_image(TextureCubeFace face, const string &fn)
@@ -301,6 +306,11 @@ void TextureCube::Loader::storage(PixelFormat fmt, unsigned s)
        obj.storage(fmt, s);
 }
 
+void TextureCube::Loader::storage_levels(PixelFormat fmt, unsigned s, unsigned l)
+{
+       obj.storage(fmt, s, l);
+}
+
 
 void operator>>(const LexicalConverter &conv, TextureCubeFace &face)
 {