X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture3d.cpp;h=0ee2e800086b2b940e634352be929da5b4cacd27;hb=3efe3bab1c8290bd49a957ebec0ad97e58a35fcf;hp=c901556aa52f7aa2b84357f3ce784bf3d440279c;hpb=260ecf71f02d4b3397e4f6c80d96a7c4ba473185;p=libs%2Fgl.git diff --git a/source/core/texture3d.cpp b/source/core/texture3d.cpp index c901556a..0ee2e800 100644 --- a/source/core/texture3d.cpp +++ b/source/core/texture3d.cpp @@ -15,7 +15,7 @@ void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp, { if(width>0) { - if(fmt!=format || wd!=width || ht!=height || dp!=depth || (lv && lv!=levels)) + if(fmt!=format || wd!=width || ht!=height || dp!=depth || (lv && lv!=n_levels)) throw incompatible_data("Texture3D::storage"); return; } @@ -26,9 +26,12 @@ void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp, width = wd; height = ht; depth = dp; - levels = get_n_levels(); + unsigned size = max(width, height); + if(!is_array()) + size = max(size, depth); + n_levels = count_levels(size); if(lv>0) - levels = min(levels, lv); + n_levels = min(n_levels, lv); allocate(); } @@ -43,7 +46,7 @@ void Texture3D::sub_image(unsigned level, unsigned x, unsigned y, unsigned z, un { if(width==0 || height==0 || depth==0) throw invalid_operation("Texture3D::sub_image"); - if(level>=levels || x>width || x+wd>width || y>height || y+ht>height || z>depth || z+dp>depth) + if(level>=n_levels || x>width || x+wd>width || y>height || y+ht>height || z>depth || z+dp>depth) throw out_of_range("Texture3D::sub_image"); Texture3DBackend::sub_image(level, x, y, z, wd, ht, dp, data); @@ -63,16 +66,6 @@ void Texture3D::image(const Graphics::Image &img, unsigned lv) image(0, img.get_pixels()); } -unsigned Texture3D::get_n_levels() const -{ - unsigned s = max(width, height); - if(!is_array()) - s = max(s, depth); - unsigned n = 0; - for(; s; s>>=1, ++n) ; - return n; -} - LinAl::Vector Texture3D::get_level_size(unsigned level) const { unsigned w = width>>level; @@ -91,11 +84,6 @@ LinAl::Vector Texture3D::get_level_size(unsigned level) const return LinAl::Vector(w, h, d); } -uint64_t Texture3D::get_data_size() const -{ - return id ? width*height*depth*get_pixel_size(storage_fmt) : 0; -} - Texture3D::Loader::Loader(Texture3D &t): DataFile::DerivedObjectLoader(t)