Added support for explitly requesting DXT1a and DXT1c compression

This commit is contained in:
Robert Osfield 2011-04-11 19:11:25 +00:00
parent f0f31e4a8c
commit e7e860b742
4 changed files with 41 additions and 2 deletions

View File

@ -447,7 +447,9 @@ class OSG_EXPORT Texture : public osg::StateAttribute
USE_S3TC_DXT3_COMPRESSION,
USE_S3TC_DXT5_COMPRESSION,
USE_RGTC1_COMPRESSION,
USE_RGTC2_COMPRESSION
USE_RGTC2_COMPRESSION,
USE_S3TC_DXT1c_COMPRESSION,
USE_S3TC_DXT1a_COMPRESSION
};
/** Sets the internal texture format mode. Note: If the texture format is

View File

@ -1299,6 +1299,36 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
else internalFormat = image.getInternalTextureFormat();
break;
case(USE_S3TC_DXT1c_COMPRESSION):
if (extensions->isTextureCompressionS3TCSupported())
{
switch(image.getPixelFormat())
{
case(3):
case(4):
case(GL_RGB):
case(GL_RGBA): internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; break;
default: internalFormat = image.getInternalTextureFormat(); break;
}
}
else internalFormat = image.getInternalTextureFormat();
break;
case(USE_S3TC_DXT1a_COMPRESSION):
if (extensions->isTextureCompressionS3TCSupported())
{
switch(image.getPixelFormat())
{
case(3):
case(4):
case(GL_RGB):
case(GL_RGBA): internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
default: internalFormat = image.getInternalTextureFormat(); break;
}
}
else internalFormat = image.getInternalTextureFormat();
break;
case(USE_S3TC_DXT3_COMPRESSION):
if (extensions->isTextureCompressionS3TCSupported())
{

View File

@ -177,7 +177,8 @@ struct DDSURFACEDESC2
//
// Structure of a DXT-1 compressed texture block
// see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/Opaque_and_1_Bit_Alpha_Textures.asp
// see page "Opaque and 1-Bit Alpha Textures (Direct3D 9)" on http://msdn.microsoft.com
// url at time of writing http://msdn.microsoft.com/en-us/library/bb147243(v=VS.85).aspx
//
struct DXT1TexelsBlock
{

View File

@ -307,6 +307,12 @@ void NVTTProcessor::compress(osg::Image& image, osg::Texture::InternalFormatMode
else
format = nvtt::Format_DXT1;
break;
case osg::Texture::USE_S3TC_DXT1c_COMPRESSION:
format = nvtt::Format_DXT1;
break;
case osg::Texture::USE_S3TC_DXT1a_COMPRESSION:
format = nvtt::Format_DXT1a;
break;
case osg::Texture::USE_S3TC_DXT3_COMPRESSION:
format = nvtt::Format_DXT3;
break;