+ if(width==0 || height==0)
+ throw invalid_operation("Texture2D::sub_image");
+
+ Conditional<BindRestore> _bind(!ARB_direct_state_access, this);
+ allocate(level);
+
+ comp = get_upload_components(comp);
+ if(ARB_direct_state_access)
+ glTextureSubImage2D(id, level, x, y, wd, ht, comp, type, data);
+ else
+ glTexSubImage2D(target, level, x, y, wd, ht, comp, 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_image(img);
+ PixelComponents comp = get_components(fmt);
+ DataType type = get_component_type(fmt);