- GLenum gl_fmt = get_gl_pixelformat(storage_fmt);
- if(ARB_texture_storage)
- {
- if(ARB_direct_state_access)
- glTextureStorage2D(id, levels, gl_fmt, size, size);
- else
- {
- bind_scratch();
- glTexStorage2D(target, levels, gl_fmt, size, size);
- }
- }
- else
- {
- 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(get_gl_cube_face(static_cast<TextureCubeFace>(j)), i, gl_fmt, lv_size, lv_size, 0, comp, type, 0);
- }
- glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
- }