- PixelFormat base_fmt = get_base_pixelformat(ifmt);
- image(level, base_fmt, get_alloc_type(base_fmt), 0);
+ if(ARB_texture_storage)
+ {
+ unsigned n_levels = (is_mipmapped(min_filter) ? get_n_levels() : 1);
+ if(ARB_direct_state_access)
+ glTextureStorage2D(id, n_levels, ifmt, width, height);
+ else
+ {
+ BindRestore _bind(this);
+ glTexStorage2D(target, n_levels, ifmt, width, height);
+ }
+ allocated |= (1<<n_levels)-1;
+ }
+ else
+ {
+ PixelFormat base_fmt = get_base_pixelformat(ifmt);
+ image(level, base_fmt, get_alloc_type(base_fmt), 0);
+ }