X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture3d.cpp;h=36fdfa0f3b8f6b591fd19b7f4d4047fa45c0ba06;hp=5e1f9866e185e6ecdb047f167a26ffa8054d03ea;hb=03d3984ecd2c4e7c38b6a62b4b7a81bab69f8d40;hpb=3c46227c280bc4cd8a4487c648f2f080d5b4f7ea diff --git a/source/texture3d.cpp b/source/texture3d.cpp index 5e1f9866..36fdfa0f 100644 --- a/source/texture3d.cpp +++ b/source/texture3d.cpp @@ -33,7 +33,7 @@ Texture3D::Texture3D(): static Require _req(EXT_texture3D); } -void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp) +void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp, unsigned lv) { if(width>0) throw invalid_operation("Texture3D::storage"); @@ -44,26 +44,30 @@ void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp) width = wd; height = ht; depth = dp; + levels = get_n_levels(); + if(lv>0) + levels = min(levels, lv); } void Texture3D::allocate(unsigned level) { if(width==0 || height==0 || depth==0) throw invalid_operation("Texture3D::allocate"); + if(level>=levels) + throw invalid_argument("Texture3D::allocate"); if(allocated&(1<