Cleaned up DXT1 support

This commit is contained in:
Robert Osfield 2011-04-14 15:22:43 +00:00
parent 5fb7f69108
commit 2648723c83
3 changed files with 11 additions and 16 deletions

View File

@ -633,18 +633,7 @@ void Image::setInternalTextureFormat(GLint internalFormat)
void Image::setPixelFormat(GLenum pixelFormat) void Image::setPixelFormat(GLenum pixelFormat)
{ {
if (_pixelFormat==pixelFormat) return; // do nothing if the same. _pixelFormat = pixelFormat;
if (_pixelFormat==0 || computeNumComponents(_pixelFormat)==computeNumComponents(pixelFormat))
{
// if the two formats have the same number of componets then
// we can do a straight swap.
_pixelFormat = pixelFormat;
}
else
{
OSG_WARN<<"Image::setPixelFormat(..) - warning, attempt to reset the pixel format with a different number of components."<<std::endl;
}
} }
void Image::setDataType(GLenum dataType) void Image::setDataType(GLenum dataType)
@ -1256,6 +1245,7 @@ bool Image::isImageTranslucent() const
case(GL_BGR): case(GL_BGR):
return false; return false;
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT):
return false;
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT):
case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):

View File

@ -173,6 +173,8 @@ bool CompressedImageTranslucent(size_t width, size_t height, GLenum format, void
switch(format) switch(format)
{ {
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT):
return false;
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT):
{ {
const DXT1TexelsBlock *texelsBlock = reinterpret_cast<const DXT1TexelsBlock*>(imageData); const DXT1TexelsBlock *texelsBlock = reinterpret_cast<const DXT1TexelsBlock*>(imageData);
@ -209,10 +211,13 @@ bool CompressedImageTranslucent(size_t width, size_t height, GLenum format, void
} }
return false; return false;
} }
case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT):
return true; return true;
case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
return true; return true;
default: default:
break; break;
} }

View File

@ -924,10 +924,10 @@ public:
ReaderWriterDDS() ReaderWriterDDS()
{ {
supportsExtension("dds","DDS image format"); supportsExtension("dds","DDS image format");
supportsOption("dds_dxt1_rgb","set the pixel format of DXT1 encoded images to be RGB"); supportsOption("dds_dxt1_rgb","Set the pixel format of DXT1 encoded images to be RGB variant of DXT1");
supportsOption("dds_dxt1_rgba","set the pixel format of DXT1 encoded images to be RGBA"); supportsOption("dds_dxt1_rgba","Set the pixel format of DXT1 encoded images to be RGBA variant of DXT1");
supportsOption("dds_dxt1_detect_rgba","For DXT1 encode images set the pixel format according to presence of transparent pixels."); supportsOption("dds_dxt1_detect_rgba","For DXT1 encode images set the pixel format according to presence of transparent pixels");
supportsOption("dds_flip","flip the image about the horizontl axis"); supportsOption("dds_flip","Flip the image about the horizontl axis");
} }
virtual const char* className() const virtual const char* className() const