+ get_image(level).set_2d(ifmt, wd, ht);
+ if(level==0 && generate_mipmap)
+ create_mipmaps();
+}
+
+void TextureState::set_face_image_2d(GLenum face, unsigned level, GLenum ifmt, unsigned wd, unsigned ht)
+{
+ unsigned index = 0;
+ for(; (index<6 && texture_cube_faces[index]!=face); ++index) ;
+ if(index>=6)
+ return;
+
+ set_image_2d(level*6+index, ifmt, wd, ht);
+}
+
+void TextureState::set_image_3d(unsigned level, GLenum ifmt, unsigned wd, unsigned ht, unsigned dp)
+{
+ get_image(level).set_3d(ifmt, wd, ht, dp);
+ if(level==0 && generate_mipmap)
+ create_mipmaps();
+}
+
+void TextureState::create_mipmaps(unsigned face)
+{
+ unsigned stride = (target==GL_TEXTURE_CUBE_MAP ? 6 : 1);
+ if(face>=stride)
+ face = 0;
+
+ unsigned wd = images[face].width;
+ unsigned ht = images[face].height;
+ unsigned dp = images[face].depth;
+ for(unsigned i=1;; ++i)