X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture2d.cpp;h=44ee6406420e85f261c988f5e8b14f678c90cfe3;hp=8d6e8471edb72574340e6e870514bfb652a13113;hb=03d3984ecd2c4e7c38b6a62b4b7a81bab69f8d40;hpb=3c46227c280bc4cd8a4487c648f2f080d5b4f7ea diff --git a/source/texture2d.cpp b/source/texture2d.cpp index 8d6e8471..44ee6406 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -46,7 +46,7 @@ Texture2D::~Texture2D() set_manager(0); } -void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht) +void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv) { if(width>0) throw invalid_operation("Texture2D::storage"); @@ -56,26 +56,30 @@ void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht) set_internal_format(fmt); width = wd; height = ht; + levels = get_n_levels(); + if(lv>0) + levels = min(levels, lv); } void Texture2D::allocate(unsigned level) { if(width==0 || height==0) throw invalid_operation("Texture2D::allocate"); + if(level>=levels) + throw invalid_argument("Texture2D::allocate"); if(allocated&(1<