Changed: code simplification for s3tc_compressor_lib

This commit is contained in:
kervala 2010-08-27 20:21:15 +02:00
parent 1ff44fdb50
commit a1fcd412b1

View file

@ -34,7 +34,6 @@ static void compressMipMap(uint8 *pixSrc, sint width, sint height, vector<uint8
dest.ddpf.dwSize = sizeof(CS3TCCompressor::DDS_PIXELFORMAT); dest.ddpf.dwSize = sizeof(CS3TCCompressor::DDS_PIXELFORMAT);
dest.ddpf.dwFlags = DDPF_FOURCC; dest.ddpf.dwFlags = DDPF_FOURCC;
dest.dwCaps = DDSCAPS_TEXTURE; dest.dwCaps = DDSCAPS_TEXTURE;
dest.dwLinearSize = std::max(4, width) * std::max(4, height);
// Setting flags // Setting flags
int flags = squish::kColourIterativeClusterFit; // for best quality int flags = squish::kColourIterativeClusterFit; // for best quality
@ -44,7 +43,6 @@ static void compressMipMap(uint8 *pixSrc, sint width, sint height, vector<uint8
case DXT1A: case DXT1A:
flags |= squish::kDxt1; flags |= squish::kDxt1;
dest.ddpf.dwFourCC = MAKEFOURCC('D','X', 'T', '1'); dest.ddpf.dwFourCC = MAKEFOURCC('D','X', 'T', '1');
dest.dwLinearSize /= 2;
break; break;
case DXT3: case DXT3:
flags |= squish::kDxt3; flags |= squish::kDxt3;
@ -59,8 +57,8 @@ static void compressMipMap(uint8 *pixSrc, sint width, sint height, vector<uint8
// Encoding // Encoding
//=========== //===========
// resize dest. // resize dest.
uint32 encodeSz = squish::GetStorageRequirements(width, height, flags); dest.dwLinearSize = squish::GetStorageRequirements(width, height, flags);
compdata.resize(encodeSz); compdata.resize(dest.dwLinearSize);
// Go! // Go!
float weight[3] = {0.3086f, 0.6094f, 0.0820f}; float weight[3] = {0.3086f, 0.6094f, 0.0820f};
squish::CompressImage(pixSrc, width, height, &(*compdata.begin()), flags, weight); squish::CompressImage(pixSrc, width, height, &(*compdata.begin()), flags, weight);