- maybe_bind();
- glTexImage3D(target, level, ifmt, width, height, depth, border, fmt, type, data);
+ require_storage();
+
+ unsigned w = width;
+ unsigned h = height;
+ unsigned d = depth;
+ get_level_size(level, w, h, d);
+
+ Bind _bind(this, true);
+ glTexImage3D(target, level, ifmt, width, height, depth, 0, fmt, type, data);
+
+ allocated |= 1<<level;
+ if(gen_mipmap && level==0)
+ {
+ for(; (w || h || d); w>>=1, h>>=1, d>>=1, ++level) ;
+ allocated |= (1<<level)-1;
+ }
+}
+
+void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsigned ht, unsigned dp, PixelFormat fmt, DataType type, const void *data)
+{
+ require_storage();
+ allocate(level);
+
+ Bind _bind(this, true);
+ glTexSubImage3D(target, level, x, y, z, wd, ht, dp, fmt, type, data);