]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Move srgb handling to storage_pixelformat_from_graphics
[libs/gl.git] / source / texturecube.cpp
index 37390a853612523e503889230f030f2a70d2b73d..576f1c718b3848aa043cb165b04a578f83500a70 100644 (file)
@@ -47,8 +47,10 @@ void TextureCube::allocate(unsigned level)
        if(allocated&(1<<level))
                return;
 
+       PixelFormat base_fmt = get_base_pixelformat(ifmt);
+       DataType type = get_alloc_type(base_fmt);
        for(unsigned i=0; i<6; ++i)
-               image(enumerate_faces(i), level, get_base_pixelformat(ifmt), UNSIGNED_BYTE, 0);
+               image(enumerate_faces(i), level, base_fmt, type, 0);
 }
 
 void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, DataType type, const void *data)
@@ -84,10 +86,7 @@ void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool s
                if(w!=h)
                        throw incompatible_data("TextureCube::image");
 
-               PixelFormat f = storage_pixelformat_from_graphics(img.get_format());
-               if(srgb)
-                       f = get_srgb_pixelformat(f);
-               storage(f, w);
+               storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w);
        }
        else if(w!=size || h!=size)
                throw incompatible_data("TextureCube::image");