static Require _req(ARB_texture_cube_map);
}
-void TextureCube::storage(PixelFormat fmt, unsigned sz)
+void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv)
{
if(size>0)
throw invalid_operation("TextureCube::storage");
set_internal_format(fmt);
size = sz;
+ levels = get_n_levels();
+ if(lv>0)
+ levels = min(levels, lv);
}
void TextureCube::allocate(unsigned level)
{
+ if(size==0)
+ throw invalid_operation("TextureCube::allocate");
+ if(level>=levels)
+ throw invalid_argument("TextureCube::allocate");
if(allocated&(1<<level))
return;
if(ARB_texture_storage)
{
BindRestore _bind(this);
- unsigned n_levels = (is_mipmapped(min_filter) ? get_n_levels() : 1);
- glTexStorage2D(target, n_levels, ifmt, size, size);
- allocated |= (1<<n_levels)-1;
+ glTexStorage2D(target, levels, ifmt, size, size);
+ allocated |= (1<<levels)-1;
}
else
{
PixelFormat fmt = pixelformat_from_graphics(img.get_format());
if(size==0)
- storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w);
+ {
+ unsigned l = (is_mipmapped(min_filter) ? mipmap_levels ? mipmap_levels : 0 : 1);
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, l);
+ }
else if(w!=size || h!=size)
throw incompatible_data("TextureCube::image");
void TextureCube::Loader::storage(PixelFormat fmt, unsigned s)
{
- if(srgb)
- fmt = get_srgb_pixelformat(fmt);
obj.storage(fmt, s);
}