Add support for luminance flag. Fixes issue 126.
This commit is contained in:
parent
acc7dee80f
commit
0b2e6d633d
@ -662,8 +662,14 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask
|
||||
nvCheck((gmask & amask) == 0);
|
||||
nvCheck((bmask & amask) == 0);
|
||||
|
||||
this->pf.flags = DDPF_RGB;
|
||||
|
||||
if (rmask > 0 && gmask == 0 && bmask == 0)
|
||||
{
|
||||
this->pf.flags = DDPF_LUMINANCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->pf.flags = DDPF_RGB;
|
||||
}
|
||||
if (amask != 0) {
|
||||
this->pf.flags |= DDPF_ALPHAPIXELS;
|
||||
}
|
||||
@ -816,9 +822,9 @@ bool DirectDrawSurface::isSupported() const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (header.pf.flags & DDPF_RGB)
|
||||
else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE))
|
||||
{
|
||||
// All RGB formats are supported now.
|
||||
// All RGB and luminance formats are supported now.
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -937,7 +943,7 @@ void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap)
|
||||
|
||||
img->allocate(w, h);
|
||||
|
||||
if (header.pf.flags & DDPF_RGB)
|
||||
if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE))
|
||||
{
|
||||
readLinearImage(img);
|
||||
}
|
||||
@ -1172,7 +1178,7 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
|
||||
}
|
||||
else
|
||||
{
|
||||
nvDebugCheck(header.pf.flags & DDPF_RGB);
|
||||
nvDebugCheck((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE));
|
||||
|
||||
// Align pixels to bytes.
|
||||
uint byteCount = (header.pf.bitcount + 7) / 8;
|
||||
@ -1242,6 +1248,7 @@ void DirectDrawSurface::printInfo() const
|
||||
printf("Pixel Format:\n");
|
||||
printf("\tFlags: 0x%.8X\n", header.pf.flags);
|
||||
if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n");
|
||||
if (header.pf.flags & DDPF_LUMINANCE) printf("\t\DDPF_LUMINANCE\n");
|
||||
if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n");
|
||||
if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n");
|
||||
if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n");
|
||||
|
@ -143,6 +143,7 @@ int main(int argc, char *argv[])
|
||||
bool nocuda = false;
|
||||
bool silent = false;
|
||||
bool bc1n = false;
|
||||
bool luminance = false;
|
||||
nvtt::Format format = nvtt::Format_BC1;
|
||||
|
||||
const char * externalCompressor = NULL;
|
||||
@ -195,6 +196,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
format = nvtt::Format_RGB;
|
||||
}
|
||||
else if (strcmp("-lumi", argv[i]) == 0)
|
||||
{
|
||||
luminance = true;
|
||||
format = nvtt::Format_RGB;
|
||||
}
|
||||
else if (strcmp("-bc1", argv[i]) == 0)
|
||||
{
|
||||
format = nvtt::Format_BC1;
|
||||
@ -286,6 +292,7 @@ int main(int argc, char *argv[])
|
||||
printf(" -fast \tFast compression.\n");
|
||||
printf(" -nocuda \tDo not use cuda compressor.\n");
|
||||
printf(" -rgb \tRGBA format\n");
|
||||
printf(" -lumi \tLUMINANCE format\n");
|
||||
printf(" -bc1 \tBC1 format (DXT1)\n");
|
||||
printf(" -bc1n \tBC1 normal map format (DXT1nm)\n");
|
||||
printf(" -bc1a \tBC1 format with binary alpha (DXT1a)\n");
|
||||
@ -398,6 +405,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
nvtt::CompressionOptions compressionOptions;
|
||||
compressionOptions.setFormat(format);
|
||||
if (luminance)
|
||||
{
|
||||
compressionOptions.setPixelFormat(8, 0xff, 0, 0, 0);
|
||||
}
|
||||
if (fast)
|
||||
{
|
||||
compressionOptions.setQuality(nvtt::Quality_Fastest);
|
||||
|
Loading…
Reference in New Issue
Block a user