From 436f02ab9cdf58d8b68f124be0d974a5de0d9308 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 30 Jun 2012 04:34:34 +0000 Subject: Finally committing support for compressed textures on the GPU (DDS+DXT). This patch started out as a patch by me, then cleaned up by Kupoman during his work on Cucumber. One important thing to keep in mind when using this feature is that you'll need to flip your textures vertically (both the GIMP and Photoshop DDS tools I've seen have support for this on export). This is a quirk in using a texture format originally made for DirectX/DirectDraw, and flipping the compressed data is a real headache. Another quick fix for this issue is to change the Y value for the Size in the Mapping panel in the Texture properties to -1 (default is 1). --- source/blender/imbuf/intern/dds/dds_api.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (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 071d94c2076..fba326f7865 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -123,6 +123,8 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) ibuf->ftype = DDS; ibuf->profile = IB_PROFILE_SRGB; + ibuf->dds_data.fourcc = dds.fourCC(); + ibuf->dds_data.nummipmaps = dds.mipmapCount(); if ((flags & IB_test) == 0) { if (!imb_addrectImBuf(ibuf)) return(ibuf); @@ -136,10 +138,18 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) cp[0] = pixel.r; /* set R component of col */ cp[1] = pixel.g; /* set G component of col */ cp[2] = pixel.b; /* set B component of col */ - if (bits_per_pixel == 32) + if (dds.hasAlpha()) cp[3] = pixel.a; /* set A component of col */ rect[i] = col; } + + if (ibuf->dds_data.fourcc != FOURCC_DDS) + ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf->dds_data.size); + else { + ibuf->dds_data.data = NULL; + ibuf->dds_data.size = 0; + } + IMB_flipy(ibuf); } -- cgit v1.2.3