- // TODO Only do this once all faces are created
- auto_generate_mipmap();
- allocated |= (1<<get_n_levels())-1;
+ 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;