X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture3d.cpp;h=ed5619cb4aed30f567cf7e3e063a7ad05f60fd27;hp=4cba3afccbfade39750ef6ec00cd890182142b58;hb=aa9873652630db493b5bd9faee4117e9c30ef226;hpb=3e17c84968553e58cb09d397cafaead82e51d478 diff --git a/source/texture3d.cpp b/source/texture3d.cpp index 4cba3afc..ed5619cb 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,24 +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<