X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture2d.cpp;h=7ac1c5ec84f599fcef2285b94e8f5531c3631958;hb=c356a20547afae97b412da36e0b0a7d51e879401;hp=9b1c16ea120dbe6fe7d88c96f57dcfbfd386e79e;hpb=260ecf71f02d4b3397e4f6c80d96a7c4ba473185;p=libs%2Fgl.git diff --git a/source/core/texture2d.cpp b/source/core/texture2d.cpp index 9b1c16ea..7ac1c5ec 100644 --- a/source/core/texture2d.cpp +++ b/source/core/texture2d.cpp @@ -15,7 +15,7 @@ void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv) { if(width>0) { - if(fmt!=format || wd!=width || ht!=height || (lv && lv!=levels)) + if(fmt!=format || wd!=width || ht!=height || (lv && lv!=n_levels)) throw incompatible_data("Texture2D::storage"); return; } @@ -25,9 +25,9 @@ void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv) set_format(fmt); width = wd; height = ht; - levels = get_n_levels(); + n_levels = count_levels(max(width, height)); if(lv>0) - levels = min(levels, lv); + n_levels = min(n_levels, lv); allocate(); } @@ -42,7 +42,7 @@ void Texture2D::sub_image(unsigned level, unsigned x, unsigned y, unsigned wd, u { if(width==0 || height==0) throw invalid_operation("Texture2D::sub_image"); - if(level>=levels || x>width || x+wd>width || y>height || y+ht>height) + if(level>=n_levels || x>width || x+wd>width || y>height || y+ht>height) throw out_of_range("Texture2D::sub_image"); Texture2DBackend::sub_image(level, x, y, wd, ht, data); @@ -54,13 +54,6 @@ void Texture2D::image(const Graphics::Image &img, unsigned lv) image(0, img.get_pixels()); } -unsigned Texture2D::get_n_levels() const -{ - unsigned n = 0; - for(unsigned s=max(width, height); s; s>>=1, ++n) ; - return n; -} - LinAl::Vector Texture2D::get_level_size(unsigned level) const { unsigned w = width>>level; @@ -74,16 +67,6 @@ LinAl::Vector Texture2D::get_level_size(unsigned level) const return LinAl::Vector(w, h); } -Resource::AsyncLoader *Texture2D::load(IO::Seekable &io, const Resources *) -{ - return create_async_loader(io); -} - -uint64_t Texture2D::get_data_size() const -{ - return id ? width*height*get_pixel_size(format) : 0; -} - Texture2D::Loader::Loader(Texture2D &t): DataFile::DerivedObjectLoader(t)