X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexturecube.cpp;h=b0887ca85b1e4fca0e88769da87e4621f0d3af54;hb=9087cc0a372b9c739f15398c7a22c0a6eb5041bb;hp=833ef28f0ebd78add08ccfae4c8555df87dff288;hpb=b2c8b2238877f76cdea184cca70336b15ddb78d9;p=libs%2Fgl.git diff --git a/source/texturecube.cpp b/source/texturecube.cpp index 833ef28f..b0887ca8 100644 --- a/source/texturecube.cpp +++ b/source/texturecube.cpp @@ -45,50 +45,52 @@ unsigned TextureCube::orientations[12] = TextureCube::TextureCube(): Texture(GL_TEXTURE_CUBE_MAP), - ifmt(RGB), size(0), allocated(0) { static Require _req(ARB_texture_cube_map); } -void TextureCube::storage(PixelFormat fmt, unsigned sz) +void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv) { if(size>0) throw invalid_operation("TextureCube::storage"); if(sz==0) throw invalid_argument("TextureCube::storage"); - if(MSP_sized_internal_formats) - fmt = get_sized_pixelformat(fmt); - require_pixelformat(fmt); - - ifmt = fmt; + set_internal_format(fmt); size = sz; + levels = get_n_levels(); + if(lv>0) + levels = min(levels, lv); } void TextureCube::allocate(unsigned level) { - if(allocated&(1<=levels) + throw invalid_argument("TextureCube::allocate"); + if(allocated&(64<(img.get_data()); unsigned face_size = img.get_stride()*size; for(unsigned i=0; i<6; ++i) - image(enumerate_faces(i), 0, fmt, UNSIGNED_BYTE, cdata+i*face_size); + image(enumerate_faces(i), 0, comp, type, cdata+i*face_size); } unsigned TextureCube::get_n_levels() const @@ -254,6 +277,7 @@ void TextureCube::Loader::init() add("image_data", &Loader::image_data); add("raw_data", &Loader::raw_data); add("storage", &Loader::storage); + add("storage", &Loader::storage_levels); } void TextureCube::Loader::external_image(TextureCubeFace face, const string &fn) @@ -276,16 +300,19 @@ void TextureCube::Loader::image_data(TextureCubeFace face, const string &data) void TextureCube::Loader::raw_data(TextureCubeFace face, const string &data) { - obj.image(face, 0, get_base_pixelformat(obj.ifmt), UNSIGNED_BYTE, data.data()); + obj.image(face, 0, get_components(obj.ifmt), get_component_type(obj.ifmt), data.data()); } void TextureCube::Loader::storage(PixelFormat fmt, unsigned s) { - if(srgb) - fmt = get_srgb_pixelformat(fmt); obj.storage(fmt, s); } +void TextureCube::Loader::storage_levels(PixelFormat fmt, unsigned s, unsigned l) +{ + obj.storage(fmt, s, l); +} + void operator>>(const LexicalConverter &conv, TextureCubeFace &face) {