- glTexImage2D(target, level, ifmt, width, height, border, fmt, type, data);
+void Texture2D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
+{
+ if(width==0 || height==0)
+ throw invalid_operation("Texture2D::image");
+
+ unsigned w = width;
+ unsigned h = height;
+ get_level_size(level, w, h);
+
+ Bind _bind(this, true);
+ glTexImage2D(target, level, ifmt, w, h, 0, fmt, type, data);
+
+ allocated |= 1<<level;
+ if(gen_mipmap && level==0)
+ {
+ for(; (w || h); w>>=1, h>>=1, ++level) ;
+ allocated |= (1<<level)-1;
+ }