X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture3d.cpp;h=6515946bb2bba5885dd6dd6d5c425438804cc400;hb=cd446554e998204eaba22504b7b28227feb8edbb;hp=7edc908098c73ed0866ff6d9733874f4efa7993d;hpb=7e9e15a12fb398798f2719545cc8553354c1e389;p=libs%2Fgl.git diff --git a/source/texture3d.cpp b/source/texture3d.cpp index 7edc9080..6515946b 100644 --- a/source/texture3d.cpp +++ b/source/texture3d.cpp @@ -22,12 +22,13 @@ Texture3D::Texture3D(): Texture(GL_TEXTURE_3D), width(0), height(0), - depth(0) + depth(0), + allocated(0) { static RequireVersion _ver(1, 2); } -void Texture3D::storage(PixelFormat f, unsigned w, unsigned h, unsigned d, int b) +void Texture3D::storage(PixelFormat f, unsigned w, unsigned h, unsigned d) { if(width>0) throw InvalidState("Textures storage may only be specified once"); @@ -38,18 +39,45 @@ void Texture3D::storage(PixelFormat f, unsigned w, unsigned h, unsigned d, int b height = h; depth = d; ifmt = f; - border = b; image(0, ifmt, UNSIGNED_BYTE, 0); } -void Texture3D::image(int level, PixelFormat fmt, DataType type, const void *data) +void Texture3D::allocate(unsigned level) { - if(width==0) - throw InvalidState("Texture storage has not been specified"); + if(allocated&(1<>=1, h>>=1, d>>=1, ++level) ; + allocated |= (1<>= level; + h >>= level; + d >>= level; + + if(!w && (h || d)) + w = 1; + if(!h && (w || d)) + h = 1; + if(!d && (w || h)) + d = 1; +} + } // namespace GL } // namespace Msp