X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexturecube.cpp;h=743eb986247eb95318c98490179b3fdb95683980;hb=4a6c595b4d954b6cf69c6388a43b2b66f84d8c0a;hp=24d02f4022b2aeac380410ea481a2e392181f8af;hpb=f35535633aab06e80f0666d8551431364654c6dc;p=libs%2Fgl.git diff --git a/source/texturecube.cpp b/source/texturecube.cpp index 24d02f40..743eb986 100644 --- a/source/texturecube.cpp +++ b/source/texturecube.cpp @@ -86,10 +86,7 @@ void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool s if(w!=h) throw incompatible_data("TextureCube::image"); - PixelFormat f = storage_pixelformat_from_graphics(img.get_format()); - if(srgb) - f = get_srgb_pixelformat(f); - storage(f, w); + storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w); } else if(w!=size || h!=size) throw incompatible_data("TextureCube::image"); @@ -100,6 +97,30 @@ void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool s image(face, 0, fmt, UNSIGNED_BYTE, img.get_data()); } +void TextureCube::image(const Graphics::Image &img, bool srgb) +{ + unsigned w = img.get_width(); + unsigned h = img.get_height(); + + if(h!=w*6) + throw incompatible_data("TextureCube::image"); + h /= 6; + + PixelFormat fmt = pixelformat_from_graphics(img.get_format()); + if(size==0) + storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w); + else if(w!=size || h!=size) + throw incompatible_data("TextureCube::image"); + + PixelStore pstore = PixelStore::from_image(img); + BindRestore _bind_ps(pstore); + + const char *cdata = reinterpret_cast(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); +} + unsigned TextureCube::get_level_size(unsigned level) { return size>>level;