From aab78de27cf070dac1d5b07120e871415d45687c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 25 Oct 2012 12:54:16 +0000 Subject: Better fix for #32837: DDS compressed textures now no longer need to be flipped when saving, rather we flip the compressed texture during load. The code used here comes from the chromium O3D project: http://src.chromium.org/chrome/trunk/o3d/core/cross/bitmap_dds.cc Also made it only load compressed for power-of-two resolution images, it doesn't seem to work for other resolutions, just falls back to non-compressed then. --- source/blender/imbuf/intern/dds/dds_api.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/imbuf/intern/dds/dds_api.cpp') diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 68b7013c31f..5459cffe590 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include // printf #include @@ -162,20 +163,19 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colo rect[i] = col; } - if (ibuf->dds_data.fourcc != FOURCC_DDS) + if (ibuf->dds_data.fourcc != FOURCC_DDS) { ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf->dds_data.size); + + /* flip compressed texture */ + FlipDXTCImage(dds.width(), dds.height(), dds.mipmapCount(), dds.fourCC(), ibuf->dds_data.data); + } else { ibuf->dds_data.data = NULL; ibuf->dds_data.size = 0; } - /* DDS images can be flipped compared to the Blender standard, however we - * do not unflip them because we also don't flip compressed textures. If - * we would flip those we'd need to uncompress, flip and recompress them, - * and so losing the speed benefit that you get from using them. Users are - * expected to save DDS image in OpenGL compatible format. */ - - /* IMB_flipy(ibuf); */ + /* flip uncompressed texture */ + IMB_flipy(ibuf); } return(ibuf); -- cgit v1.2.3