X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexturecube.cpp;h=743eb986247eb95318c98490179b3fdb95683980;hb=d2efbd8a32efa2a3ee8542efc846277af19d63e0;hp=576f1c718b3848aa043cb165b04a578f83500a70;hpb=e079d5a878e83dc0baffcec66a57659c885cd593;p=libs%2Fgl.git diff --git a/source/texturecube.cpp b/source/texturecube.cpp index 576f1c71..743eb986 100644 --- a/source/texturecube.cpp +++ b/source/texturecube.cpp @@ -97,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;