+ throw invalid_operation("Texture3D::storage");
+ if(wd==0 || ht==0 || dp==0)
+ throw invalid_argument("Texture3D::storage");
+
+ set_format(fmt);
+ width = wd;
+ height = ht;
+ depth = dp;
+ levels = get_n_levels();
+ if(lv>0)
+ levels = min(levels, lv);
+}
+
+void Texture3D::allocate(unsigned level)
+{
+ if(width==0 || height==0 || depth==0)
+ throw invalid_operation("Texture3D::allocate");
+ if(level>=levels)
+ throw invalid_argument("Texture3D::allocate");
+ if(allocated&(1<<level))
+ return;
+
+ if(ARB_texture_storage)
+ {
+ Conditional<BindRestore> _bind(!ARB_direct_state_access, this);
+ if(ARB_direct_state_access)
+ glTextureStorage3D(id, levels, storage_fmt, width, height, depth);
+ else
+ glTexStorage3D(target, levels, storage_fmt, width, height, depth);
+ apply_swizzle();
+ allocated |= (1<<levels)-1;
+ }
+ else
+ image(level, 0);
+}
+
+void Texture3D::image(unsigned level, const void *data)
+{
+ if(width==0 || height==0 || depth==0)
+ throw invalid_operation("Texture3D::image");
+
+ unsigned w = width;
+ unsigned h = height;
+ unsigned d = depth;
+ get_level_size(level, w, h, d);
+
+ if(ARB_texture_storage)
+ return sub_image(level, 0, 0, 0, w, h, d, data);