X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexturecube.cpp;h=2f36f33624cee007b2667daeb993caaf212e9a04;hb=f73e671dcb36c097647cddbf5b1eaaad2ffc9299;hp=ea29499732646897dd9e81c7080c8cc3bc9ff013;hpb=160e9eea29bd10034733d59507fa1bcca36be401;p=libs%2Fgl.git diff --git a/source/core/texturecube.cpp b/source/core/texturecube.cpp index ea294997..2f36f336 100644 --- a/source/core/texturecube.cpp +++ b/source/core/texturecube.cpp @@ -29,10 +29,6 @@ const unsigned TextureCube::orientations[12] = 1, 3 }; -TextureCube::TextureCube(): - size(0) -{ } - void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv) { if(size>0) @@ -53,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(data); + unsigned face_size = size*size*get_pixel_size(storage_fmt); + for(unsigned i=0; i<6; ++i) + image(static_cast(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); @@ -94,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(img.get_pixels()); - unsigned face_size = img.get_stride()*size; - for(unsigned i=0; i<6; ++i) - image(static_cast(i), 0, pixels+i*face_size); + image(0, img.get_pixels()); } unsigned TextureCube::get_n_levels() const @@ -137,11 +138,6 @@ Vector3 TextureCube::get_texel_direction(TextureCubeFace face, unsigned u, unsig return fv+s*sv+t*tv; } -uint64_t TextureCube::get_data_size() const -{ - return id ? size*size*6*get_pixel_size(storage_fmt) : 0; -} - TextureCube::Loader::Loader(TextureCube &t): DataFile::DerivedObjectLoader(t)