]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/texturecube.cpp
Remove support for array size specialization from the engine as well
[libs/gl.git] / source / core / texturecube.cpp
index 9aec4b1d19640f699adbf8c2596a7e14555b6200..0e0a1fc9178dca4ebd8b4cfc55bd52185b5e5b51 100644 (file)
@@ -49,17 +49,25 @@ void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv)
        allocate();
 }
 
+void TextureCube::image(unsigned level, const void *data)
+{
+       const char *pixels = static_cast<const char *>(data);
+       unsigned face_size = size*size*get_pixel_size(storage_fmt);
+       for(unsigned i=0; i<6; ++i)
+               image(static_cast<TextureCubeFace>(i), level, pixels+i*face_size);
+}
+
 void TextureCube::image(TextureCubeFace face, unsigned level, const void *data)
 {
        unsigned lsz = get_level_size(level);
        return sub_image(face, level, 0, 0, lsz, lsz, data);
 }
 
-void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y, unsigned wd, unsigned ht, const void *data)
+void TextureCube::sub_image(TextureCubeFace face, unsigned level, unsigned x, unsigned y, unsigned wd, unsigned ht, const void *data)
 {
        if(size==0)
                throw invalid_operation("TextureCube::sub_image");
-       if(level>=levels)
+       if(level>=levels || x>size || x+wd>size || y>size || y+ht>size)
                throw out_of_range("TextureCube::sub_image");
 
        TextureCubeBackend::sub_image(face, level, x, y, wd, ht, data);
@@ -90,10 +98,7 @@ void TextureCube::image(const Graphics::Image &img, unsigned lv)
        else if(w!=size || h!=size)
                throw incompatible_data("TextureCube::image");
 
-       const char *pixels = reinterpret_cast<const char *>(img.get_pixels());
-       unsigned face_size = img.get_stride()*size;
-       for(unsigned i=0; i<6; ++i)
-               image(static_cast<TextureCubeFace>(i), 0, pixels+i*face_size);
+       image(0, img.get_pixels());
 }
 
 unsigned TextureCube::get_n_levels() const