- if(size==0)
- throw invalid_operation("TextureCube::image");
-
- unsigned s = get_level_size(level);
- if(s==0)
- throw out_of_range("TextureCube::image");
-
- if(ARB_texture_storage)
- return sub_image(face, level, 0, 0, s, s, data);
-
- BindRestore _bind(this);
-
- if(!allocated)
- {
- glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
- apply_swizzle();
- }
-
- PixelComponents comp = get_components(storage_fmt);
- GLenum type = get_gl_type(get_component_type(storage_fmt));
- glTexImage2D(face, level, storage_fmt, s, s, 0, comp, type, data);
-
- if(level==0)
- {
- allocated |= 1<<get_face_index(face);
- if((allocated&63)==63)
- {
- allocated |= 64;
- if(auto_gen_mipmap)
- {
- generate_mipmap();
- allocated |= (64<<levels)-1;
- }
- }
- }
- else if(!(allocated&(64<<level)))
- {
- for(unsigned i=0; i<6; ++i)
- if(enumerate_faces(i)!=face)
- glTexImage2D(enumerate_faces(i), level, storage_fmt, s, s, 0, comp, type, 0);
-
- allocated |= 64<<level;
- }
-}
-
-void TextureCube::image(TextureCubeFace face, unsigned level, PixelComponents comp, DataType type, const void *data)
-{
- if(comp!=get_components(format) || type!=get_component_type(format))
- throw incompatible_data("TextureCube::image");
- image(face, level, data);