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