From 8ae77aa7c04f0f6ccd3e9ee05ef1b0734ef703d0 Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Wed, 1 Sep 2021 16:39:25 +0200 Subject: [PATCH] - removed useless casting on CTexture ~ updated TEXTURE_FORMAT.md documentation to reflect real format Signed-off-by: Alexis Maiquez --- docs/textures/TEXTURE_FORMAT.md | 23 +++++++++++++++++------ src/WallpaperEngine/Assets/CTexture.cpp | 17 +++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/textures/TEXTURE_FORMAT.md b/docs/textures/TEXTURE_FORMAT.md index 7201592..8d634d9 100644 --- a/docs/textures/TEXTURE_FORMAT.md +++ b/docs/textures/TEXTURE_FORMAT.md @@ -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 diff --git a/src/WallpaperEngine/Assets/CTexture.cpp b/src/WallpaperEngine/Assets/CTexture.cpp index 955a2af..f832e6e 100644 --- a/src/WallpaperEngine/Assets/CTexture.cpp +++ b/src/WallpaperEngine/Assets/CTexture.cpp @@ -203,37 +203,29 @@ void CTexture::parseHeader (char* fileData) fileData = reinterpret_cast (pointer); // get the position of what comes after the texture data char* afterFileData = fileData + 9; + pointer = reinterpret_cast (fileData + 9); if (memcmp (fileData, "TEXB0003", 9) == 0) { this->m_header->containerVersion = ContainerVersion::TEXB0003; // get back the pointer and use it - pointer = reinterpret_cast (afterFileData); pointer ++; this->m_header->freeImageFormat = static_cast (*pointer++); - // set back the pointer - fileData = reinterpret_cast (pointer); } else if(memcmp (fileData, "TEXB0002", 9) == 0) { this->m_header->containerVersion = ContainerVersion::TEXB0002; - // get back the pointer and use it - pointer = reinterpret_cast (afterFileData); + // skip 4 bytes pointer ++; - // set back the pointer - fileData = reinterpret_cast (pointer); } else if (memcmp (fileData, "TEXB0001", 9) == 0) { this->m_header->containerVersion = ContainerVersion::TEXB0001; - // get back the pointer and use it - pointer = reinterpret_cast (afterFileData); + // skip 4 bytes pointer ++; - // set back the pointer - fileData = reinterpret_cast (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 (fileData); - // read the number of mipmaps available this->m_header->mipmapCount = *pointer ++;