X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture3d.cpp;h=ed5619cb4aed30f567cf7e3e063a7ad05f60fd27;hp=85b3f075f5096e47d92800ad734958189d0f0fa1;hb=aa9873652630db493b5bd9faee4117e9c30ef226;hpb=1955e583d7eeeb0a2ff054d90c3694f575d9a08d diff --git a/source/texture3d.cpp b/source/texture3d.cpp index 85b3f075..ed5619cb 100644 --- a/source/texture3d.cpp +++ b/source/texture3d.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "bindable.h" #include "error.h" @@ -32,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"); @@ -43,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<