- for(unsigned i=0; i<6; ++i)
- image_(enumerate_faces(i), level, 0);
- }
-}
-
-void TextureCube::image(TextureCubeFace face, unsigned level, const void *data)
-{
- if(size==0)
- throw invalid_operation("TextureCube::image");
- if(level>=levels)
- throw out_of_range("TextureCube::image");
-
- if(ARB_texture_storage)
- {
- unsigned lsz = get_level_size(level);
- return sub_image(face, level, 0, 0, lsz, lsz, data);
- }
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(target, id);
-
- image_(face, level, data);
-
- if(auto_gen_mipmap && level==0 && (allocated&63)==63)
- {
- generate_mipmap_();
- allocated |= (64<<levels)-1;
- }
-
- glBindTexture(target, 0);
-}
-
-void TextureCube::image_(TextureCubeFace face, unsigned level, const void *data)
-{
- if(!allocated)
- {
+ bind_scratch();
+ GLenum comp = get_gl_components(get_components(storage_fmt));
+ GLenum type = get_gl_type(get_component_type(storage_fmt));
+ for(unsigned i=0; i<levels; ++i)
+ {
+ unsigned lv_size = get_level_size(i);
+ for(unsigned j=0; j<6; ++j)
+ glTexImage2D(enumerate_faces(j), i, gl_fmt, lv_size, lv_size, 0, comp, type, 0);
+ }