X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture2d.cpp;h=dac671fdfa52fcae265d088b2cb9d14f918a9a56;hb=ffe1debbd757d20f7250fd8572c2c46cd901f559;hp=7ce18d00a9fa075b5df6b2a5ea1dac741411165f;hpb=1955e583d7eeeb0a2ff054d90c3694f575d9a08d;p=libs%2Fgl.git diff --git a/source/texture2d.cpp b/source/texture2d.cpp index 7ce18d00..dac671fd 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -46,7 +46,7 @@ Texture2D::~Texture2D() set_manager(0); } -void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht) +void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv) { if(width>0) throw invalid_operation("Texture2D::storage"); @@ -56,24 +56,30 @@ void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht) set_internal_format(fmt); width = wd; height = ht; + levels = get_n_levels(); + if(lv>0) + levels = min(levels, lv); } void Texture2D::allocate(unsigned level) { + if(width==0 || height==0) + throw invalid_operation("Texture2D::allocate"); + if(level>=levels) + throw invalid_argument("Texture2D::allocate"); if(allocated&(1<(pixel_buffer.map(WRITE_ONLY)); + pixel_buffer.storage(n_bytes); + mapped_address = reinterpret_cast(pixel_buffer.map()); } else if(phase==2) {