-
- if(ARB_texture_storage)
- return sub_image(level, 0, 0, size.x, size.y, data);
-
- bind_scratch();
-
- if(!allocated)
- {
- glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
- apply_swizzle();
- }
-
- GLenum fmt = get_gl_pixelformat(storage_fmt);
- GLenum comp = get_gl_components(get_components(storage_fmt));
- GLenum type = get_gl_type(get_component_type(storage_fmt));
- glTexImage2D(target, level, fmt, size.x, size.y, 0, comp, type, data);
-
- allocated |= 1<<level;
- if(auto_gen_mipmap && level==0)
- {
- generate_mipmap();
- allocated |= (1<<levels)-1;
- }
-}
-
-void Texture2D::image(unsigned level, PixelComponents comp, DataType type, const void *data)
-{
- if(comp!=get_components(format) || type!=get_component_type(format))
- throw incompatible_data("Texture2D::image");
- image(level, data);
+ return sub_image(level, 0, 0, size.x, size.y, data);