mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Added support for ETC2/EAC compressed textures. Changed the CompressedFormat enum names to capitalize the format names (e.g. "PVR1rgba4" instead of "pvr1rgba4".) Improved sRGB support for compressed textures.
--HG-- branch : minor
This commit is contained in:
@@ -32,12 +32,13 @@ bool DDSHandler::canParse(const filesystem::FileData *data)
|
||||
return dds::isCompressedDDS(data->getData(), data->getSize());
|
||||
}
|
||||
|
||||
uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format)
|
||||
uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedData::SubImage> &images, size_t &dataSize, CompressedData::Format &format, bool &sRGB)
|
||||
{
|
||||
if (!dds::isDDS(filedata->getData(), filedata->getSize()))
|
||||
throw love::Exception("Could not decode compressed data (not a DDS file?)");
|
||||
|
||||
CompressedData::Format texformat = CompressedData::FORMAT_UNKNOWN;
|
||||
bool isSRGB = false;
|
||||
|
||||
uint8 *data = nullptr;
|
||||
dataSize = 0;
|
||||
@@ -48,7 +49,7 @@ uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
// Attempt to parse the dds file.
|
||||
dds::Parser parser(filedata->getData(), filedata->getSize());
|
||||
|
||||
texformat = convertFormat(parser.getFormat());
|
||||
texformat = convertFormat(parser.getFormat(), isSRGB);
|
||||
|
||||
if (texformat == CompressedData::FORMAT_UNKNOWN)
|
||||
throw love::Exception("Could not parse compressed data: Unsupported format.");
|
||||
@@ -96,11 +97,14 @@ uint8 *DDSHandler::parse(filesystem::FileData *filedata, std::vector<CompressedD
|
||||
}
|
||||
|
||||
format = texformat;
|
||||
sRGB = isSRGB;
|
||||
return data;
|
||||
}
|
||||
|
||||
CompressedData::Format DDSHandler::convertFormat(dds::Format ddsformat)
|
||||
CompressedData::Format DDSHandler::convertFormat(dds::Format ddsformat, bool &sRGB)
|
||||
{
|
||||
sRGB = false;
|
||||
|
||||
switch (ddsformat)
|
||||
{
|
||||
case dds::FORMAT_DXT1:
|
||||
@@ -124,7 +128,8 @@ CompressedData::Format DDSHandler::convertFormat(dds::Format ddsformat)
|
||||
case dds::FORMAT_BC7:
|
||||
return CompressedData::FORMAT_BC7;
|
||||
case dds::FORMAT_BC7srgb:
|
||||
return CompressedData::FORMAT_BC7SRGB;
|
||||
sRGB = true;
|
||||
return CompressedData::FORMAT_BC7;
|
||||
default:
|
||||
return CompressedData::FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user