throw invalid_operation("TextureCube::storage");
if(sz==0)
throw invalid_argument("TextureCube::storage");
+
+ if(MSP_sized_internal_formats)
+ fmt = get_sized_pixelformat(fmt);
require_pixelformat(fmt);
ifmt = fmt;
{
// TODO Only do this once all faces are created
auto_generate_mipmap();
- for(; s; s>>=1, ++level) ;
- allocated |= (1<<level)-1;
+ allocated |= (1<<get_n_levels())-1;
}
}
+void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y, unsigned wd, unsigned ht, PixelFormat fmt, DataType type, const void *data)
+{
+ if(size==0)
+ throw invalid_operation("TextureCube::sub_image");
+
+ allocate(level);
+
+ BindRestore _bind(this);
+ glTexSubImage2D(face, level, x, y, wd, ht, fmt, type, data);
+}
+
void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool srgb)
{
unsigned w = img.get_width();
image(enumerate_faces(i), 0, fmt, UNSIGNED_BYTE, cdata+i*face_size);
}
-unsigned TextureCube::get_level_size(unsigned level)
+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
{
return size>>level;
}