- 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);
- DataType 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;
- }
+ const char *pixels = static_cast<const char *>(data);
+ unsigned face_size = size*size*get_pixel_size(storage_fmt);
+ for(unsigned i=0; i<6; ++i)
+ image(static_cast<TextureCubeFace>(i), level, pixels+i*face_size);