+void TextureCube::image(const Graphics::Image &img, bool srgb)
+{
+ unsigned w = img.get_width();
+ unsigned h = img.get_height();
+
+ if(h!=w*6)
+ throw incompatible_data("TextureCube::image");
+ h /= 6;
+
+ PixelFormat fmt = pixelformat_from_graphics(img.get_format());
+ if(size==0)
+ {
+ unsigned l = (is_mipmapped(min_filter) ? mipmap_levels ? mipmap_levels : 0 : 1);
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, l);
+ }
+ else if(w!=size || h!=size)
+ throw incompatible_data("TextureCube::image");
+
+ PixelStore pstore = PixelStore::from_image(img);
+ BindRestore _bind_ps(pstore);
+
+ const char *cdata = reinterpret_cast<const char *>(img.get_data());
+ unsigned face_size = img.get_stride()*size;
+ for(unsigned i=0; i<6; ++i)
+ image(enumerate_faces(i), 0, fmt, UNSIGNED_BYTE, cdata+i*face_size);
+}
+
+unsigned TextureCube::get_n_levels() const
+{
+ unsigned n = 0;
+ for(unsigned s=size; s; s>>=1, ++n) ;
+ return n;
+}
+
+unsigned TextureCube::get_level_size(unsigned level) const