+ if(width==0 || height==0)
+ throw invalid_operation("Texture2D::sub_image");
+
+ Conditional<BindRestore> _bind(!ARB_direct_state_access, this);
+ allocate(level);
+
+ fmt = get_upload_format(fmt);
+ if(ARB_direct_state_access)
+ glTextureSubImage2D(id, level, x, y, wd, ht, fmt, type, data);
+ else
+ glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
+
+ if(auto_gen_mipmap && level==0)
+ generate_mipmap();
+}
+
+void Texture2D::image(const Graphics::Image &img, unsigned lv, bool srgb)
+{
+ image(img, lv, srgb, false);
+}
+
+void Texture2D::image(const Graphics::Image &img, unsigned lv, bool srgb, bool from_buffer)
+{
+ unsigned w = img.get_width();
+ unsigned h = img.get_height();
+ PixelFormat fmt = pixelformat_from_graphics(img.get_format());