- removed useless casting on CTexture

~ updated TEXTURE_FORMAT.md documentation to reflect real format

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2021-09-01 16:39:25 +02:00
parent d9c12d0b58
commit 8ae77aa7c0
2 changed files with 20 additions and 20 deletions

View File

@ -8,15 +8,26 @@ Wallpaper engine uses a custom texture storage format converted by resourcecompi
| __Padding__ | 1 byte | Null terminator for string |
| __Extra file type indicator?__ | 8 bytes | TEXI0001 |
| __Padding__ | 1 byte | Null terminator for string |
| __Texture type__ | 1 byte | 4 => DXT5? 0 => JPEG? |
| __Unknown data__ | 15 bytes | To be reversed |
| __Texture type__ | 4 bytes | 0 => ARGB8888, 4 => DXT5, 6 => DXT3, 7 => DXT1, 8 => RG88, 9 => R8 |
| __Texture flags__ | 4 bytes | Flags for the texture (1 => Interpolation, 2 => ClampUVs, 4 => IsGif) |
| __Texture Width__ | 4 bytes | Texture's full width |
| __Texture Height__ | 4 bytes | Texture's full height |
| __Width__ | 4 bytes | Image's width |
| __Height__ | 4 bytes | Image's height |
| __Unknown data__ | 5 bytes | To be reversed |
| __Container version__ | 8 bytes | TEXB0003 |
| __Unknown data__ | 4 bytes | To be reversed |
| __Container version__ | 8 bytes | TEXB0003/TEXB0002/TEXB0001 |
| __Padding__ | 1 byte | Null terminator for string |
| __Unknown data__ | 8 bytes | To be reversed |
| __Mip map levels__ | 4 bytes | The number of mipmaps stored for this texture |
| __Texture information__ | x bytes | Varies depending on the container version |
## TEXB0003
| __Unknown data__ | 4 bytes | To be reversed |
| __Free image format__ | 4 bytes | The type of file this texture is based off the FREEIMAGE library |
| __Mip map levels__ | 4 bytes | The number of mipmap levels stored for this texture |
| __Mipmap entry__ | x bytes | See Mipmap entries |
## TEXB0002 and TEXB0001
| __Unknown data__ | 4 bytes | To be reversed |
| __Mip map levels__ | 4 bytes | The number of mipmap levels stored for this texture |
| __Mipmap entry__ | x bytes | See Mipmap entries |
## Mipmap entries

View File

@ -203,37 +203,29 @@ void CTexture::parseHeader (char* fileData)
fileData = reinterpret_cast <char*> (pointer);
// get the position of what comes after the texture data
char* afterFileData = fileData + 9;
pointer = reinterpret_cast <uint32_t*> (fileData + 9);
if (memcmp (fileData, "TEXB0003", 9) == 0)
{
this->m_header->containerVersion = ContainerVersion::TEXB0003;
// get back the pointer and use it
pointer = reinterpret_cast <uint32_t*> (afterFileData);
pointer ++;
this->m_header->freeImageFormat = static_cast<FREE_IMAGE_FORMAT> (*pointer++);
// set back the pointer
fileData = reinterpret_cast <char*> (pointer);
}
else if(memcmp (fileData, "TEXB0002", 9) == 0)
{
this->m_header->containerVersion = ContainerVersion::TEXB0002;
// get back the pointer and use it
pointer = reinterpret_cast <uint32_t*> (afterFileData);
// skip 4 bytes
pointer ++;
// set back the pointer
fileData = reinterpret_cast <char*> (pointer);
}
else if (memcmp (fileData, "TEXB0001", 9) == 0)
{
this->m_header->containerVersion = ContainerVersion::TEXB0001;
// get back the pointer and use it
pointer = reinterpret_cast <uint32_t*> (afterFileData);
// skip 4 bytes
pointer ++;
// set back the pointer
fileData = reinterpret_cast <char*> (pointer);
}
else
{
@ -255,9 +247,6 @@ void CTexture::parseHeader (char* fileData)
throw std::runtime_error ("RG88 format is not supported yet");
}
// get back an integer pointer
pointer = reinterpret_cast <uint32_t*> (fileData);
// read the number of mipmaps available
this->m_header->mipmapCount = *pointer ++;