diff --git a/VTFLib/VTFFile.cpp b/VTFLib/VTFFile.cpp index c6dc4e7..7650a2b 100644 --- a/VTFLib/VTFFile.cpp +++ b/VTFLib/VTFFile.cpp @@ -1426,6 +1426,25 @@ vlBool CVTFFile::Load( IO::Readers::IReader *Reader, vlBool bHeaderOnly ) return vlTrue; } + // Between different branches of Source Engine games + // the ATI formats are shifted in the ImageFormats enum + // and will crash VTFLib if a old branch ATI were to + // try and load, given they are the same identical format + // we can just set it to VTFLib's ATI enum to load it correctly. + // The numbers we change from are source internal formats + // and can be safely changed. If a problem ever does arise... + // Blame valve and pray to the rat gods for salvation. + if ( this->Header->ImageFormat == IMAGE_FORMAT_ATI2N_OLD ) + { + this->Header->ImageFormat = IMAGE_FORMAT_ATI2N; + this->OldATIFormat = true; + } + if ( this->Header->ImageFormat == IMAGE_FORMAT_ATI1N_OLD ) + { + this->Header->ImageFormat = IMAGE_FORMAT_ATI1N; + this->OldATIFormat = true; + } + // work out how big out buffers need to be this->uiImageBufferSize = this->ComputeImageSize( this->Header->Width, this->Header->Height, this->Header->Depth, this->Header->MipCount, this->Header->ImageFormat ) * this->GetFaceCount() * this->GetFrameCount(); @@ -1722,11 +1741,26 @@ vlBool CVTFFile::Save( IO::Writers::IWriter *Writer ) const throw 0; // Write the header. + + auto format = this->Header->ImageFormat; + + if ( format == IMAGE_FORMAT_ATI2N && OldATIFormat ) + { + this->Header->ImageFormat = IMAGE_FORMAT_ATI2N_OLD; + } + + if ( format == IMAGE_FORMAT_ATI1N && OldATIFormat ) + { + this->Header->ImageFormat = IMAGE_FORMAT_ATI1N_OLD; + } + if ( Writer->Write( this->Header, this->Header->HeaderSize ) != this->Header->HeaderSize ) { throw 0; } + this->Header->ImageFormat = format; + if ( this->GetSupportsResources() ) { for ( vlUInt i = 0; i < this->Header->ResourceCount; i++ ) @@ -3840,7 +3874,7 @@ inline vlSingle CVTFFile::FP16ToFP32( vlUInt16 input ) if ( fp16.uiExponent == 31 ) { - if ( fp16.uiMantissa == 0 ) // Check for Infinity + if ( fp16.uiMantissa == 0 ) // Check for Infinity return sMaxFloat16Bits * ( ( fp16.uiSign == 1 ) ? -1.0f : 1.0f ); else if ( fp16.uiMantissa != 0 ) // Check for NaN return 0.0f; @@ -4126,7 +4160,7 @@ vlBool ConvertTemplated( vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUIn // default value transform if ( uiSourceRMask && uiDestRMask ) { - if ( DestInfo.uiRBitsPerPixel < SourceInfo.uiRBitsPerPixel ) // downsample + if ( DestInfo.uiRBitsPerPixel < SourceInfo.uiRBitsPerPixel ) // downsample DR = Shrink( SR, SourceInfo.uiRBitsPerPixel, DestInfo.uiRBitsPerPixel ); else if ( DestInfo.uiRBitsPerPixel > SourceInfo.uiRBitsPerPixel ) // upsample DR = Expand( SR, SourceInfo.uiRBitsPerPixel, DestInfo.uiRBitsPerPixel ); @@ -4136,7 +4170,7 @@ vlBool ConvertTemplated( vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUIn if ( uiSourceGMask && uiDestGMask ) { - if ( DestInfo.uiGBitsPerPixel < SourceInfo.uiGBitsPerPixel ) // downsample + if ( DestInfo.uiGBitsPerPixel < SourceInfo.uiGBitsPerPixel ) // downsample DG = Shrink( SG, SourceInfo.uiGBitsPerPixel, DestInfo.uiGBitsPerPixel ); else if ( DestInfo.uiGBitsPerPixel > SourceInfo.uiGBitsPerPixel ) // upsample DG = Expand( SG, SourceInfo.uiGBitsPerPixel, DestInfo.uiGBitsPerPixel ); @@ -4146,7 +4180,7 @@ vlBool ConvertTemplated( vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUIn if ( uiSourceBMask && uiDestBMask ) { - if ( DestInfo.uiBBitsPerPixel < SourceInfo.uiBBitsPerPixel ) // downsample + if ( DestInfo.uiBBitsPerPixel < SourceInfo.uiBBitsPerPixel ) // downsample DB = Shrink( SB, SourceInfo.uiBBitsPerPixel, DestInfo.uiBBitsPerPixel ); else if ( DestInfo.uiBBitsPerPixel > SourceInfo.uiBBitsPerPixel ) // upsample DB = Expand( SB, SourceInfo.uiBBitsPerPixel, DestInfo.uiBBitsPerPixel ); @@ -4156,7 +4190,7 @@ vlBool ConvertTemplated( vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth, vlUIn if ( uiSourceAMask && uiDestAMask ) { - if ( DestInfo.uiABitsPerPixel < SourceInfo.uiABitsPerPixel ) // downsample + if ( DestInfo.uiABitsPerPixel < SourceInfo.uiABitsPerPixel ) // downsample DA = Shrink( SA, SourceInfo.uiABitsPerPixel, DestInfo.uiABitsPerPixel ); else if ( DestInfo.uiABitsPerPixel > SourceInfo.uiABitsPerPixel ) // upsample DA = Expand( SA, SourceInfo.uiABitsPerPixel, DestInfo.uiABitsPerPixel ); diff --git a/VTFLib/VTFFile.h b/VTFLib/VTFFile.h index 5f4d691..e5dae66 100644 --- a/VTFLib/VTFFile.h +++ b/VTFLib/VTFFile.h @@ -82,19 +82,19 @@ extern "C" #pragma pack( 1 ) typedef struct tagSVTFCreateOptions { - vlUInt uiVersion[2]; //!< Output image version. - VTFImageFormat ImageFormat; //!< Output image output storage format. + vlUInt uiVersion[2]; //!< Output image version. + VTFImageFormat ImageFormat; //!< Output image output storage format. - vlUInt uiFlags; //!< Output image header flags. - vlUInt uiStartFrame; //!< Output image start frame. - vlSingle sBumpScale; //!< Output image bump scale. - vlSingle sReflectivity[3]; //!< Output image reflectivity. (Only used if bReflectivity is false.) + vlUInt uiFlags; //!< Output image header flags. + vlUInt uiStartFrame; //!< Output image start frame. + vlSingle sBumpScale; //!< Output image bump scale. + vlSingle sReflectivity[3]; //!< Output image reflectivity. (Only used if bReflectivity is false.) vlBool bMipmaps; //!< Generate MIPmaps. (Space is always allocated.) VTFMipmapFilter MipmapFilter; //!< MIP map re-size filter. - vlBool bThumbnail; //!< Generate thumbnail image. - vlBool bReflectivity; //!< Compute image reflectivity. + vlBool bThumbnail; //!< Generate thumbnail image. + vlBool bReflectivity; //!< Compute image reflectivity. vlBool bResize; //!< Resize the input image. VTFResizeMethod ResizeMethod; //!< New size compution method. @@ -102,15 +102,15 @@ extern "C" vlUInt uiResizeWidth; //!< New width after re-size if method is RESIZE_SET. vlUInt uiResizeHeight; //!< New height after re-size if method is RESIZE_SET. - vlBool bResizeClamp; //!< Clamp re-size size. - vlUInt uiResizeClampWidth; //!< Maximum width to re-size to. - vlUInt uiResizeClampHeight; //!< Maximum height to re-size to. + vlBool bResizeClamp; //!< Clamp re-size size. + vlUInt uiResizeClampWidth; //!< Maximum width to re-size to. + vlUInt uiResizeClampHeight; //!< Maximum height to re-size to. - vlBool bGammaCorrection; //!< Gamma correct input image. - vlSingle sGammaCorrection; //!< Gamma correction to apply. + vlBool bGammaCorrection; //!< Gamma correct input image. + vlSingle sGammaCorrection; //!< Gamma correction to apply. - vlBool bSphereMap; //!< Generate a sphere map for six faced environment maps. - vlBool bSRGB; //!< Texture is in the SRGB color space. + vlBool bSphereMap; //!< Generate a sphere map for six faced environment maps. + vlBool bSRGB; //!< Texture is in the SRGB color space. } SVTFCreateOptions; #pragma pack() @@ -165,14 +165,16 @@ namespace VTFLib class VTFLIB_API CVTFFile { private: - SVTFHeader *Header; // VTF header + SVTFHeader *Header; // VTF header - vlUInt uiImageBufferSize; // Size of VTF image data buffer - vlByte *lpImageData; // VTF image buffer + vlUInt uiImageBufferSize; // Size of VTF image data buffer + vlByte *lpImageData; // VTF image buffer vlUInt uiThumbnailBufferSize; // Size of VTF thumbnail image data buffer vlByte *lpThumbnailImageData; // VTF thumbnail image buffer + bool OldATIFormat = false; + public: CVTFFile(); //!< Default constructor @@ -381,21 +383,21 @@ namespace VTFLib vlUInt GetMinorVersion() const; //!< Returns the VTF file minor version number. bool SetVersion( vlUInt major, vlUInt minor ); - vlUInt GetSize() const; //!< Returns the VTF file size in bytes. + vlUInt GetSize() const; //!< Returns the VTF file size in bytes. - vlUInt GetWidth() const; //!< Returns the width of the image in pixels from the VTF header. - vlUInt GetHeight() const; //!< Returns the height of the image in pixels from the VTF header. - vlUInt GetDepth() const; //!< Returns the depth of the image in pixels from the VTF header. + vlUInt GetWidth() const; //!< Returns the width of the image in pixels from the VTF header. + vlUInt GetHeight() const; //!< Returns the height of the image in pixels from the VTF header. + vlUInt GetDepth() const; //!< Returns the depth of the image in pixels from the VTF header. - vlUInt GetFrameCount() const; //!< Returns the frame count from the VTF header. - vlUInt GetFaceCount() const; //!< Returns the face count from the VTF header. - vlUInt GetMipmapCount() const; //!< Returns the number of MIP levels in the image from the VTF header. + vlUInt GetFrameCount() const; //!< Returns the frame count from the VTF header. + vlUInt GetFaceCount() const; //!< Returns the face count from the VTF header. + vlUInt GetMipmapCount() const; //!< Returns the number of MIP levels in the image from the VTF header. vlUInt GetStartFrame() const; //!< Returns the start frame from the VTF header. vlVoid SetStartFrame( vlUInt uiStartFrame ); //!< Sets the start frame in the VTF header. - vlUInt GetFlags() const; //!< Returns the image flags from the VTF header. - vlVoid SetFlags( vlUInt uiFlags ); //!< Sets the image flags in the VTF header. + vlUInt GetFlags() const; //!< Returns the image flags from the VTF header. + vlVoid SetFlags( vlUInt uiFlags ); //!< Sets the image flags in the VTF header. //! Check if a specific flag is set in the VTF header. /*! @@ -476,10 +478,10 @@ namespace VTFLib vlVoid SetData( vlUInt uiFrame, vlUInt uiFace, vlUInt uiSlice, vlUInt uiMipmapLevel, vlByte *lpData ); public: - vlBool GetHasThumbnail() const; //!< Returns if a the current VTF image image contains a thumbnail version. + vlBool GetHasThumbnail() const; //!< Returns if a the current VTF image image contains a thumbnail version. - vlUInt GetThumbnailWidth() const; //!< Returns the width in pixels of the current images thumbnail. - vlUInt GetThumbnailHeight() const; //!< Returns the heught in pixels of the current images thumbnail. + vlUInt GetThumbnailWidth() const; //!< Returns the width in pixels of the current images thumbnail. + vlUInt GetThumbnailHeight() const; //!< Returns the heught in pixels of the current images thumbnail. VTFImageFormat GetThumbnailFormat() const; //!< Returns the image format of the current images thumbnail. @@ -503,7 +505,7 @@ namespace VTFLib vlVoid SetThumbnailData( vlByte *lpData ); public: - vlBool GetSupportsResources() const; //!< Returns true if the current VTF file version supports resources. + vlBool GetSupportsResources() const; //!< Returns true if the current VTF file version supports resources. vlUInt GetResourceCount() const; //!< Returns the number of resources contained within the VTF file. vlUInt GetResourceType( vlUInt uiIndex ) const; //!< Returns the resource type; @@ -620,6 +622,10 @@ namespace VTFLib vlBool SetVTFAlpha( unsigned char alpha ); + vlVoid UseOldATIFormat( bool has ) { this->OldATIFormat = has; } + + vlBool HasOldATIFormat() { return this->OldATIFormat; } + public: //! Get VTFImageFormat info. /*! diff --git a/VTFLib/VTFFormat.h b/VTFLib/VTFFormat.h index 21370b1..5b55906 100644 --- a/VTFLib/VTFFormat.h +++ b/VTFLib/VTFFormat.h @@ -14,15 +14,15 @@ // ============================================================ /*! \file VTFFormat.h - \brief Structures and enumerations relating to the VTF file format. - + \brief Structures and enumerations relating to the VTF file format. + Contains's structures and enumerations relating to the VTF file format. - + Disk file format for VTF files is as follows: - VTF Header (80 bytes) - Low Res Image (size varies) - Image Data (size varies) - + Image Data is stored as follows: - For each MIP images (starting with the smallest and getting larger) - For each frame @@ -37,455 +37,471 @@ #include "stdafx.h" #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // VTF version numbers (current version is 7.5) //--------------------------------------------- -#define VTF_MAJOR_VERSION 7 //!< VTF major version number -#define VTF_MINOR_VERSION 6 //!< VTF minor version number -#define VTF_MINOR_VERSION_DEFAULT 3 +#define VTF_MAJOR_VERSION 7 //!< VTF major version number +#define VTF_MINOR_VERSION 6 //!< VTF minor version number +#define VTF_MINOR_VERSION_DEFAULT 3 #define VTF_MINOR_VERSION_MIN_SPHERE_MAP 1 #define VTF_MINOR_VERSION_MIN_VOLUME 2 #define VTF_MINOR_VERSION_MIN_RESOURCE 3 -#define VTF_MINOR_VERSION_MIN_NO_SPHERE_MAP 5 +#define VTF_MINOR_VERSION_MIN_NO_SPHERE_MAP 5 -//! Image data formats VTFLib supports. -/*! - Image data formats supported by VTFLib. Details show colour channel order, plus number - of bits per-pixel. - \note "Bluescreen" alpha uses any pixel with an pixel of R0, G0, B255 as transparent. -*/ -typedef enum tagVTFImageFormat -{ - IMAGE_FORMAT_RGBA8888 = 0, //!< = Red, Green, Blue, Alpha - 32 bpp - IMAGE_FORMAT_ABGR8888, //!< = Alpha, Blue, Green, Red - 32 bpp - IMAGE_FORMAT_RGB888, //!< = Red, Green, Blue - 24 bpp - IMAGE_FORMAT_BGR888, //!< = Blue, Green, Red - 24 bpp - IMAGE_FORMAT_RGB565, //!< = Red, Green, Blue - 16 bpp - IMAGE_FORMAT_I8, //!< = Luminance - 8 bpp - IMAGE_FORMAT_IA88, //!< = Luminance, Alpha - 16 bpp - IMAGE_FORMAT_P8, //!< = Paletted - 8 bpp - IMAGE_FORMAT_A8, //!< = Alpha- 8 bpp - IMAGE_FORMAT_RGB888_BLUESCREEN, //!< = Red, Green, Blue, "BlueScreen" Alpha - 24 bpp - IMAGE_FORMAT_BGR888_BLUESCREEN, //!< = Red, Green, Blue, "BlueScreen" Alpha - 24 bpp - IMAGE_FORMAT_ARGB8888, //!< = Alpha, Red, Green, Blue - 32 bpp - IMAGE_FORMAT_BGRA8888, //!< = Blue, Green, Red, Alpha - 32 bpp - IMAGE_FORMAT_DXT1, //!< = DXT1 compressed format - 4 bpp - IMAGE_FORMAT_DXT3, //!< = DXT3 compressed format - 8 bpp - IMAGE_FORMAT_DXT5, //!< = DXT5 compressed format - 8 bpp - IMAGE_FORMAT_BGRX8888, //!< = Blue, Green, Red, Unused - 32 bpp - IMAGE_FORMAT_BGR565, //!< = Blue, Green, Red - 16 bpp - IMAGE_FORMAT_BGRX5551, //!< = Blue, Green, Red, Unused - 16 bpp - IMAGE_FORMAT_BGRA4444, //!< = Red, Green, Blue, Alpha - 16 bpp - IMAGE_FORMAT_DXT1_ONEBITALPHA, //!< = DXT1 compressed format with 1-bit alpha - 4 bpp - IMAGE_FORMAT_BGRA5551, //!< = Blue, Green, Red, Alpha - 16 bpp - IMAGE_FORMAT_UV88, //!< = 2 channel format for DuDv/Normal maps - 16 bpp - IMAGE_FORMAT_UVWQ8888, //!< = 4 channel format for DuDv/Normal maps - 32 bpp - IMAGE_FORMAT_RGBA16161616F, //!< = Red, Green, Blue, Alpha - 64 bpp - IMAGE_FORMAT_RGBA16161616, //!< = Red, Green, Blue, Alpha signed with mantissa - 64 bpp - IMAGE_FORMAT_UVLX8888, //!< = 4 channel format for DuDv/Normal maps - 32 bpp - IMAGE_FORMAT_R32F, //!< = Luminance - 32 bpp - IMAGE_FORMAT_RGB323232F, //!< = Red, Green, Blue - 96 bpp - IMAGE_FORMAT_RGBA32323232F, //!< = Red, Green, Blue, Alpha - 128 bpp - - IMAGE_FORMAT_NV_NULL = 33, //!< = 0 bpp - - IMAGE_FORMAT_ATI2N, //!< = Red, Green BC5 compressed format - 8 bpp - IMAGE_FORMAT_ATI1N, //!< = Red BC4 compressed format - 4 bpp - - IMAGE_FORMAT_BC7 = 70, //!< = Red, Green, Blue, Alpha BC7 compressed format - 8 bpp - /* - XBox: - IMAGE_FORMAT_X360_DST16, - IMAGE_FORMAT_X360_DST24, - IMAGE_FORMAT_X360_DST24F, - IMAGE_FORMAT_LINEAR_BGRX8888, //!< = Blue, Green, Red, Unused - 32 bpp - IMAGE_FORMAT_LINEAR_RGBA8888, //!< = Red, Green, Blue, Alpha - 32 bpp - IMAGE_FORMAT_LINEAR_ABGR8888, //!< = Alpha, Blue, Green, Red - 32 bpp - IMAGE_FORMAT_LINEAR_ARGB8888, //!< = Alpha, Red, Green, Blue - 32 bpp - IMAGE_FORMAT_LINEAR_BGRA8888, //!< = Blue, Green, Red, Alpha - 32 bpp - IMAGE_FORMAT_LINEAR_RGB888, //!< = Red, Green, Blue - 24 bpp - IMAGE_FORMAT_LINEAR_BGR888, //!< = Blue, Green, Red - 24 bpp - IMAGE_FORMAT_LINEAR_BGRX5551, //!< = Blue, Green, Red, Unused - 16 bpp - IMAGE_FORMAT_LINEAR_I8, //!< = Luminance - 8 bpp - IMAGE_FORMAT_LINEAR_RGBA16161616, //!< = Red, Green, Blue, Alpha signed with mantissa - 64 bpp - IMAGE_FORMAT_LE_BGRX8888, //!< = Blue, Green, Red, Unused - 32 bpp - IMAGE_FORMAT_LE_BGRA8888, //!< = Blue, Green, Red, Alpha - 32 bpp + //! Image data formats VTFLib supports. + /*! + Image data formats supported by VTFLib. Details show colour channel order, plus number + of bits per-pixel. + \note "Bluescreen" alpha uses any pixel with an pixel of R0, G0, B255 as transparent. */ - IMAGE_FORMAT_COUNT, - IMAGE_FORMAT_NONE = -1 -} VTFImageFormat; - - -//! VTF image header flags. -typedef enum tagVTFImageFlag -{ - TEXTUREFLAGS_POINTSAMPLE = 0x00000001, - TEXTUREFLAGS_TRILINEAR = 0x00000002, - TEXTUREFLAGS_CLAMPS = 0x00000004, - TEXTUREFLAGS_CLAMPT = 0x00000008, - TEXTUREFLAGS_ANISOTROPIC = 0x00000010, - TEXTUREFLAGS_HINT_DXT5 = 0x00000020, - TEXTUREFLAGS_SRGB = 0x00000040, // Originally internal to VTex as TEXTUREFLAGS_NOCOMPRESS. - TEXTUREFLAGS_DEPRECATED_NOCOMPRESS = 0x00000040, - TEXTUREFLAGS_NORMAL = 0x00000080, - TEXTUREFLAGS_NOMIP = 0x00000100, - TEXTUREFLAGS_NOLOD = 0x00000200, - TEXTUREFLAGS_MINMIP = 0x00000400, - TEXTUREFLAGS_PROCEDURAL = 0x00000800, - TEXTUREFLAGS_ONEBITALPHA = 0x00001000, //!< Automatically generated by VTex. - TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000, //!< Automatically generated by VTex. - TEXTUREFLAGS_ENVMAP = 0x00004000, - TEXTUREFLAGS_RENDERTARGET = 0x00008000, - TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000, - TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000, - TEXTUREFLAGS_SINGLECOPY = 0x00040000, - TEXTUREFLAGS_UNUSED0 = 0x00080000, //!< Originally internal to VTex as TEXTUREFLAGS_ONEOVERMIPLEVELINALPHA. - TEXTUREFLAGS_DEPRECATED_ONEOVERMIPLEVELINALPHA = 0x00080000, - TEXTUREFLAGS_UNUSED1 = 0x00100000, //!< Originally internal to VTex as TEXTUREFLAGS_PREMULTCOLORBYONEOVERMIPLEVEL. - TEXTUREFLAGS_DEPRECATED_PREMULTCOLORBYONEOVERMIPLEVEL = 0x00100000, - TEXTUREFLAGS_UNUSED2 = 0x00200000, //!< Originally internal to VTex as TEXTUREFLAGS_NORMALTODUDV. - TEXTUREFLAGS_DEPRECATED_NORMALTODUDV = 0x00200000, - TEXTUREFLAGS_UNUSED3 = 0x00400000, //!< Originally internal to VTex as TEXTUREFLAGS_ALPHATESTMIPGENERATION. - TEXTUREFLAGS_DEPRECATED_ALPHATESTMIPGENERATION = 0x00400000, - TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000, - TEXTUREFLAGS_UNUSED4 = 0x01000000, //!< Originally internal to VTex as TEXTUREFLAGS_NICEFILTERED. - TEXTUREFLAGS_DEPRECATED_NICEFILTERED = 0x01000000, - TEXTUREFLAGS_CLAMPU = 0x02000000, - TEXTUREFLAGS_VERTEXTEXTURE = 0x04000000, - TEXTUREFLAGS_SSBUMP = 0x08000000, - TEXTUREFLAGS_UNUSED5 = 0x10000000, //!< Originally TEXTUREFLAGS_UNFILTERABLE_OK. - TEXTUREFLAGS_DEPRECATED_UNFILTERABLE_OK = 0x10000000, - TEXTUREFLAGS_BORDER = 0x20000000, - TEXTUREFLAGS_DEPRECATED_SPECVAR_RED = 0x40000000, - TEXTUREFLAGS_DEPRECATED_SPECVAR_ALPHA = 0x80000000, - TEXTUREFLAGS_LAST = 0x20000000, - TEXTUREFLAGS_COUNT = 30 -} VTFImageFlag; - -//! VTF image cubemap face indices. -typedef enum tagVTFCubeMapFace -{ - CUBEMAP_FACE_RIGHT = 0, // +x - CUBEMAP_FACE_LEFT, // -x - CUBEMAP_FACE_BACK, // +y - CUBEMAP_FACE_FRONT, // -y - CUBEMAP_FACE_UP, // +z - CUBEMAP_FACE_DOWN, // -z - CUBEMAP_FACE_SphereMap, // fall back - CUBEMAP_FACE_COUNT -} VTFCubeMapFace; - -//! MIP map reduction filter indices. -typedef enum tagVTFMipmapFilter -{ - MIPMAP_FILTER_POINT = 0, - MIPMAP_FILTER_BOX, - MIPMAP_FILTER_TRIANGLE, - MIPMAP_FILTER_QUADRATIC, - MIPMAP_FILTER_CUBIC, - MIPMAP_FILTER_CATROM, - MIPMAP_FILTER_MITCHELL, - MIPMAP_FILTER_GAUSSIAN, - MIPMAP_FILTER_SINC, - MIPMAP_FILTER_BESSEL, - MIPMAP_FILTER_HANNING, - MIPMAP_FILTER_HAMMING, - MIPMAP_FILTER_BLACKMAN, - MIPMAP_FILTER_KAISER, - MIPMAP_FILTER_COUNT -} VTFMipmapFilter; + typedef enum tagVTFImageFormat + { + IMAGE_FORMAT_RGBA8888 = 0, //!< = Red, Green, Blue, Alpha - 32 bpp + IMAGE_FORMAT_ABGR8888, //!< = Alpha, Blue, Green, Red - 32 bpp + IMAGE_FORMAT_RGB888, //!< = Red, Green, Blue - 24 bpp + IMAGE_FORMAT_BGR888, //!< = Blue, Green, Red - 24 bpp + IMAGE_FORMAT_RGB565, //!< = Red, Green, Blue - 16 bpp + IMAGE_FORMAT_I8, //!< = Luminance - 8 bpp + IMAGE_FORMAT_IA88, //!< = Luminance, Alpha - 16 bpp + IMAGE_FORMAT_P8, //!< = Paletted - 8 bpp + IMAGE_FORMAT_A8, //!< = Alpha- 8 bpp + IMAGE_FORMAT_RGB888_BLUESCREEN, //!< = Red, Green, Blue, "BlueScreen" Alpha - 24 bpp + IMAGE_FORMAT_BGR888_BLUESCREEN, //!< = Red, Green, Blue, "BlueScreen" Alpha - 24 bpp + IMAGE_FORMAT_ARGB8888, //!< = Alpha, Red, Green, Blue - 32 bpp + IMAGE_FORMAT_BGRA8888, //!< = Blue, Green, Red, Alpha - 32 bpp + IMAGE_FORMAT_DXT1, //!< = DXT1 compressed format - 4 bpp + IMAGE_FORMAT_DXT3, //!< = DXT3 compressed format - 8 bpp + IMAGE_FORMAT_DXT5, //!< = DXT5 compressed format - 8 bpp + IMAGE_FORMAT_BGRX8888, //!< = Blue, Green, Red, Unused - 32 bpp + IMAGE_FORMAT_BGR565, //!< = Blue, Green, Red - 16 bpp + IMAGE_FORMAT_BGRX5551, //!< = Blue, Green, Red, Unused - 16 bpp + IMAGE_FORMAT_BGRA4444, //!< = Red, Green, Blue, Alpha - 16 bpp + IMAGE_FORMAT_DXT1_ONEBITALPHA, //!< = DXT1 compressed format with 1-bit alpha - 4 bpp + IMAGE_FORMAT_BGRA5551, //!< = Blue, Green, Red, Alpha - 16 bpp + IMAGE_FORMAT_UV88, //!< = 2 channel format for DuDv/Normal maps - 16 bpp + IMAGE_FORMAT_UVWQ8888, //!< = 4 channel format for DuDv/Normal maps - 32 bpp + IMAGE_FORMAT_RGBA16161616F, //!< = Red, Green, Blue, Alpha - 64 bpp + IMAGE_FORMAT_RGBA16161616, //!< = Red, Green, Blue, Alpha signed with mantissa - 64 bpp + IMAGE_FORMAT_UVLX8888, //!< = 4 channel format for DuDv/Normal maps - 32 bpp + IMAGE_FORMAT_R32F, //!< = Luminance - 32 bpp + IMAGE_FORMAT_RGB323232F, //!< = Red, Green, Blue - 96 bpp + IMAGE_FORMAT_RGBA32323232F, //!< = Red, Green, Blue, Alpha - 128 bpp + + IMAGE_FORMAT_NV_NULL = 33, //!< = 0 bpp + + IMAGE_FORMAT_ATI2N, //!< = Red, Green BC5 compressed format - 8 bpp + IMAGE_FORMAT_ATI1N, //!< = Red BC4 compressed format - 4 bpp + + IMAGE_FORMAT_ATI2N_OLD = 37, //!< = Red, Green BC5 compressed format - 8 bpp + IMAGE_FORMAT_ATI1N_OLD, //!< = Red BC4 compressed format - 4 bpp + + IMAGE_FORMAT_BC7 = 70, //!< = Red, Green, Blue, Alpha BC7 compressed format - 8 bpp + /* + XBox: + IMAGE_FORMAT_X360_DST16, + IMAGE_FORMAT_X360_DST24, + IMAGE_FORMAT_X360_DST24F, + IMAGE_FORMAT_LINEAR_BGRX8888, //!< = Blue, Green, Red, Unused - 32 bpp + IMAGE_FORMAT_LINEAR_RGBA8888, //!< = Red, Green, Blue, Alpha - 32 bpp + IMAGE_FORMAT_LINEAR_ABGR8888, //!< = Alpha, Blue, Green, Red - 32 bpp + IMAGE_FORMAT_LINEAR_ARGB8888, //!< = Alpha, Red, Green, Blue - 32 bpp + IMAGE_FORMAT_LINEAR_BGRA8888, //!< = Blue, Green, Red, Alpha - 32 bpp + IMAGE_FORMAT_LINEAR_RGB888, //!< = Red, Green, Blue - 24 bpp + IMAGE_FORMAT_LINEAR_BGR888, //!< = Blue, Green, Red - 24 bpp + IMAGE_FORMAT_LINEAR_BGRX5551, //!< = Blue, Green, Red, Unused - 16 bpp + IMAGE_FORMAT_LINEAR_I8, //!< = Luminance - 8 bpp + IMAGE_FORMAT_LINEAR_RGBA16161616, //!< = Red, Green, Blue, Alpha signed with mantissa - 64 bpp + IMAGE_FORMAT_LE_BGRX8888, //!< = Blue, Green, Red, Unused - 32 bpp + IMAGE_FORMAT_LE_BGRA8888, //!< = Blue, Green, Red, Alpha - 32 bpp + */ + IMAGE_FORMAT_COUNT, + IMAGE_FORMAT_NONE = -1 + } VTFImageFormat; + + //! VTF image header flags. + typedef enum tagVTFImageFlag + { + TEXTUREFLAGS_POINTSAMPLE = 0x00000001, + TEXTUREFLAGS_TRILINEAR = 0x00000002, + TEXTUREFLAGS_CLAMPS = 0x00000004, + TEXTUREFLAGS_CLAMPT = 0x00000008, + TEXTUREFLAGS_ANISOTROPIC = 0x00000010, + TEXTUREFLAGS_HINT_DXT5 = 0x00000020, + TEXTUREFLAGS_SRGB = 0x00000040, // Originally internal to VTex as TEXTUREFLAGS_NOCOMPRESS. + TEXTUREFLAGS_DEPRECATED_NOCOMPRESS = 0x00000040, + TEXTUREFLAGS_NORMAL = 0x00000080, + TEXTUREFLAGS_NOMIP = 0x00000100, + TEXTUREFLAGS_NOLOD = 0x00000200, + TEXTUREFLAGS_MINMIP = 0x00000400, + TEXTUREFLAGS_PROCEDURAL = 0x00000800, + TEXTUREFLAGS_ONEBITALPHA = 0x00001000, //!< Automatically generated by VTex. + TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000, //!< Automatically generated by VTex. + TEXTUREFLAGS_ENVMAP = 0x00004000, + TEXTUREFLAGS_RENDERTARGET = 0x00008000, + TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000, + TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000, + TEXTUREFLAGS_SINGLECOPY = 0x00040000, + TEXTUREFLAGS_UNUSED0 = 0x00080000, //!< Originally internal to VTex as TEXTUREFLAGS_ONEOVERMIPLEVELINALPHA. + TEXTUREFLAGS_DEPRECATED_ONEOVERMIPLEVELINALPHA = 0x00080000, + TEXTUREFLAGS_UNUSED1 = 0x00100000, //!< Originally internal to VTex as TEXTUREFLAGS_PREMULTCOLORBYONEOVERMIPLEVEL. + TEXTUREFLAGS_DEPRECATED_PREMULTCOLORBYONEOVERMIPLEVEL = 0x00100000, + TEXTUREFLAGS_UNUSED2 = 0x00200000, //!< Originally internal to VTex as TEXTUREFLAGS_NORMALTODUDV. + TEXTUREFLAGS_DEPRECATED_NORMALTODUDV = 0x00200000, + TEXTUREFLAGS_UNUSED3 = 0x00400000, //!< Originally internal to VTex as TEXTUREFLAGS_ALPHATESTMIPGENERATION. + TEXTUREFLAGS_DEPRECATED_ALPHATESTMIPGENERATION = 0x00400000, + TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000, + TEXTUREFLAGS_UNUSED4 = 0x01000000, //!< Originally internal to VTex as TEXTUREFLAGS_NICEFILTERED. + TEXTUREFLAGS_DEPRECATED_NICEFILTERED = 0x01000000, + TEXTUREFLAGS_CLAMPU = 0x02000000, + TEXTUREFLAGS_VERTEXTEXTURE = 0x04000000, + TEXTUREFLAGS_SSBUMP = 0x08000000, + TEXTUREFLAGS_UNUSED5 = 0x10000000, //!< Originally TEXTUREFLAGS_UNFILTERABLE_OK. + TEXTUREFLAGS_DEPRECATED_UNFILTERABLE_OK = 0x10000000, + TEXTUREFLAGS_BORDER = 0x20000000, + TEXTUREFLAGS_DEPRECATED_SPECVAR_RED = 0x40000000, + TEXTUREFLAGS_DEPRECATED_SPECVAR_ALPHA = 0x80000000, + TEXTUREFLAGS_LAST = 0x20000000, + TEXTUREFLAGS_COUNT = 30 + } VTFImageFlag; + + //! VTF image cubemap face indices. + typedef enum tagVTFCubeMapFace + { + CUBEMAP_FACE_RIGHT = 0, // +x + CUBEMAP_FACE_LEFT, // -x + CUBEMAP_FACE_BACK, // +y + CUBEMAP_FACE_FRONT, // -y + CUBEMAP_FACE_UP, // +z + CUBEMAP_FACE_DOWN, // -z + CUBEMAP_FACE_SphereMap, // fall back + CUBEMAP_FACE_COUNT + } VTFCubeMapFace; + + //! MIP map reduction filter indices. + typedef enum tagVTFMipmapFilter + { + MIPMAP_FILTER_POINT = 0, + MIPMAP_FILTER_BOX, + MIPMAP_FILTER_TRIANGLE, + MIPMAP_FILTER_QUADRATIC, + MIPMAP_FILTER_CUBIC, + MIPMAP_FILTER_CATROM, + MIPMAP_FILTER_MITCHELL, + MIPMAP_FILTER_GAUSSIAN, + MIPMAP_FILTER_SINC, + MIPMAP_FILTER_BESSEL, + MIPMAP_FILTER_HANNING, + MIPMAP_FILTER_HAMMING, + MIPMAP_FILTER_BLACKMAN, + MIPMAP_FILTER_KAISER, + MIPMAP_FILTER_COUNT + } VTFMipmapFilter; #define KERNEL_FILTER_BASE 1040 -//! Normal map creation kernel size indices. -typedef enum tagVTFKernelFilter -{ - KERNEL_FILTER_4X = 0, - KERNEL_FILTER_3X3, - KERNEL_FILTER_5X5, - KERNEL_FILTER_7X7, - KERNEL_FILTER_9X9, - KERNEL_FILTER_DUDV, - KERNEL_FILTER_COUNT -} VTFKernelFilter; + //! Normal map creation kernel size indices. + typedef enum tagVTFKernelFilter + { + KERNEL_FILTER_4X = 0, + KERNEL_FILTER_3X3, + KERNEL_FILTER_5X5, + KERNEL_FILTER_7X7, + KERNEL_FILTER_9X9, + KERNEL_FILTER_DUDV, + KERNEL_FILTER_COUNT + } VTFKernelFilter; #define HEIGHT_CONVERSION_METHOD_BASE 1009 -//! Normal map height conversion method indices. -typedef enum tagVTFHeightConversionMethod -{ - HEIGHT_CONVERSION_METHOD_ALPHA = 0, - HEIGHT_CONVERSION_METHOD_AVERAGE_RGB, - HEIGHT_CONVERSION_METHOD_BIASED_RGB, - HEIGHT_CONVERSION_METHOD_RED, - HEIGHT_CONVERSION_METHOD_GREEN, - HEIGHT_CONVERSION_METHOD_BLUE, - HEIGHT_CONVERSION_METHOD_MAX_RGB, - HEIGHT_CONVERSION_METHOD_COLORSPACE, - //HEIGHT_CONVERSION_METHOD_NORMALIZE, - HEIGHT_CONVERSION_METHOD_COUNT -} VTFHeightConversionMethod; + //! Normal map height conversion method indices. + typedef enum tagVTFHeightConversionMethod + { + HEIGHT_CONVERSION_METHOD_ALPHA = 0, + HEIGHT_CONVERSION_METHOD_AVERAGE_RGB, + HEIGHT_CONVERSION_METHOD_BIASED_RGB, + HEIGHT_CONVERSION_METHOD_RED, + HEIGHT_CONVERSION_METHOD_GREEN, + HEIGHT_CONVERSION_METHOD_BLUE, + HEIGHT_CONVERSION_METHOD_MAX_RGB, + HEIGHT_CONVERSION_METHOD_COLORSPACE, + // HEIGHT_CONVERSION_METHOD_NORMALIZE, + HEIGHT_CONVERSION_METHOD_COUNT + } VTFHeightConversionMethod; #define NORMAL_ALPHA_RESULT_BASE 1033 -//! Normal map alpha channel handling indices. -typedef enum tagVTFNormalAlphaResult -{ - NORMAL_ALPHA_RESULT_NOCHANGE = 0, - NORMAL_ALPHA_RESULT_HEIGHT, - NORMAL_ALPHA_RESULT_BLACK, - NORMAL_ALPHA_RESULT_WHITE, - NORMAL_ALPHA_RESULT_COUNT -} VTFNormalAlphaResult; - -//! Image re-size handling method indices. -typedef enum tagVTFResizeMethod -{ - RESIZE_NEAREST_POWER2 = 0, - RESIZE_BIGGEST_POWER2, - RESIZE_SMALLEST_POWER2, - RESIZE_SET, - RESIZE_COUNT -} VTFResizeMethod; - -//! Spheremap creation look direction indices. -//-------------------------------------------- -typedef enum tagVTFLookDir -{ - LOOK_DOWN_X = 0, - LOOK_DOWN_NEGX, - LOOK_DOWN_Y, - LOOK_DOWN_NEGY, - LOOK_DOWN_Z, - LOOK_DOWN_NEGZ -} VTFLookDir; - -#define MAKE_VTF_RSRC_ID(a, b, c) ((vlUInt)(((vlByte)a) | ((vlByte)b << 8) | ((vlByte)c << 16))) -#define MAKE_VTF_RSRC_IDF(a, b, c, d) ((vlUInt)(((vlByte)a) | ((vlByte)b << 8) | ((vlByte)c << 16) | ((vlByte)d << 24))) - -//! Resource entry type flags. -//-------------------------------------------- -typedef enum tagVTFResourceEntryTypeFlag -{ - RSRCF_HAS_NO_DATA_CHUNK = 0x02 -} VTFResourceEntryTypeFlag; - -//! Resource entry type idendifiers. -//-------------------------------------------- -typedef enum tagVTFResourceEntryType -{ - VTF_LEGACY_RSRC_LOW_RES_IMAGE = MAKE_VTF_RSRC_ID(0x01, 0, 0), - VTF_LEGACY_RSRC_IMAGE = MAKE_VTF_RSRC_ID(0x30, 0, 0), - VTF_RSRC_SHEET = MAKE_VTF_RSRC_ID(0x10, 0, 0), - VTF_RSRC_CRC = MAKE_VTF_RSRC_IDF('C', 'R', 'C', RSRCF_HAS_NO_DATA_CHUNK), - VTF_RSRC_TEXTURE_LOD_SETTINGS = MAKE_VTF_RSRC_IDF('L', 'O', 'D', RSRCF_HAS_NO_DATA_CHUNK), - VTF_RSRC_TEXTURE_SETTINGS_EX = MAKE_VTF_RSRC_IDF('T', 'S', 'O', RSRCF_HAS_NO_DATA_CHUNK), - VTF_RSRC_KEY_VALUE_DATA = MAKE_VTF_RSRC_ID('K', 'V', 'D'), - VTF_RSRC_AUX_COMPRESSION_INFO = MAKE_VTF_RSRC_ID('A', 'X', 'C'), - VTF_RSRC_MAX_DICTIONARY_ENTRIES = 32 -} VTFResourceEntryType; - -#pragma pack(1) - -//! VTFFileHeader struct. -/*! - - The VTF file header sits at the start of a VTF file and is used to - determine which version of the file is being loaded. -*/ -struct SVTFFileHeader -{ - vlChar TypeString[4]; //!< "Magic number" identifier- "VTF\0". - vlUInt Version[2]; //!< Version[0].version[1] (currently 7.2) - vlUInt HeaderSize; //!< Size of the header struct (currently 120 bytes) -}; - -//! VTFHeader_70 struct. -/*! - - The complete header for v7.0 of the VTF file format. -*/ -struct SVTFHeader_70 : public SVTFFileHeader -{ - vlUShort Width; //!< Width of the largest image - vlUShort Height; //!< Height of the largest image - vlUInt Flags; //!< Flags for the image - vlUShort Frames; //!< Number of frames if animated (1 for no animation) - vlUShort StartFrame; //!< Start frame (always 0) - vlByte Padding0[4]; //!< Reflectivity padding (16 byte alignment) - vlSingle Reflectivity[3]; //!< Reflectivity vector - vlByte Padding1[4]; //!< Reflectivity padding (8 byte packing) - vlSingle BumpScale; //!< Bump map scale - VTFImageFormat ImageFormat; //!< Image format index - vlByte MipCount; //!< Number of MIP levels (including the largest image) - VTFImageFormat LowResImageFormat; //!< Image format of the thumbnail image - vlByte LowResImageWidth; //!< Thumbnail image width - vlByte LowResImageHeight; //!< Thumbnail image height -}; - -//! VTFHeader_70_A struct. -/*! + //! Normal map alpha channel handling indices. + typedef enum tagVTFNormalAlphaResult + { + NORMAL_ALPHA_RESULT_NOCHANGE = 0, + NORMAL_ALPHA_RESULT_HEIGHT, + NORMAL_ALPHA_RESULT_BLACK, + NORMAL_ALPHA_RESULT_WHITE, + NORMAL_ALPHA_RESULT_COUNT + } VTFNormalAlphaResult; + + //! Image re-size handling method indices. + typedef enum tagVTFResizeMethod + { + RESIZE_NEAREST_POWER2 = 0, + RESIZE_BIGGEST_POWER2, + RESIZE_SMALLEST_POWER2, + RESIZE_SET, + RESIZE_COUNT + } VTFResizeMethod; + + //! Spheremap creation look direction indices. + //-------------------------------------------- + typedef enum tagVTFLookDir + { + LOOK_DOWN_X = 0, + LOOK_DOWN_NEGX, + LOOK_DOWN_Y, + LOOK_DOWN_NEGY, + LOOK_DOWN_Z, + LOOK_DOWN_NEGZ + } VTFLookDir; + +#define MAKE_VTF_RSRC_ID( a, b, c ) ( (vlUInt)( ( (vlByte)a ) | ( (vlByte)b << 8 ) | ( (vlByte)c << 16 ) ) ) +#define MAKE_VTF_RSRC_IDF( a, b, c, d ) ( (vlUInt)( ( (vlByte)a ) | ( (vlByte)b << 8 ) | ( (vlByte)c << 16 ) | ( (vlByte)d << 24 ) ) ) + + //! Resource entry type flags. + //-------------------------------------------- + typedef enum tagVTFResourceEntryTypeFlag + { + RSRCF_HAS_NO_DATA_CHUNK = 0x02 + } VTFResourceEntryTypeFlag; + + //! Resource entry type idendifiers. + //-------------------------------------------- + typedef enum tagVTFResourceEntryType + { + VTF_LEGACY_RSRC_LOW_RES_IMAGE = MAKE_VTF_RSRC_ID( 0x01, 0, 0 ), + VTF_LEGACY_RSRC_IMAGE = MAKE_VTF_RSRC_ID( 0x30, 0, 0 ), + VTF_RSRC_SHEET = MAKE_VTF_RSRC_ID( 0x10, 0, 0 ), + VTF_RSRC_CRC = MAKE_VTF_RSRC_IDF( 'C', 'R', 'C', RSRCF_HAS_NO_DATA_CHUNK ), + VTF_RSRC_TEXTURE_LOD_SETTINGS = MAKE_VTF_RSRC_IDF( 'L', 'O', 'D', RSRCF_HAS_NO_DATA_CHUNK ), + VTF_RSRC_TEXTURE_SETTINGS_EX = MAKE_VTF_RSRC_IDF( 'T', 'S', 'O', RSRCF_HAS_NO_DATA_CHUNK ), + VTF_RSRC_KEY_VALUE_DATA = MAKE_VTF_RSRC_ID( 'K', 'V', 'D' ), + VTF_RSRC_AUX_COMPRESSION_INFO = MAKE_VTF_RSRC_ID( 'A', 'X', 'C' ), + VTF_RSRC_MAX_DICTIONARY_ENTRIES = 32 + } VTFResourceEntryType; + +#pragma pack( 1 ) + + //! VTFFileHeader struct. + /*! + + The VTF file header sits at the start of a VTF file and is used to + determine which version of the file is being loaded. + */ + struct SVTFFileHeader + { + vlChar TypeString[4]; //!< "Magic number" identifier- "VTF\0". + vlUInt Version[2]; //!< Version[0].version[1] (currently 7.2) + vlUInt HeaderSize; //!< Size of the header struct (currently 120 bytes) + }; - The complete header for v7.0 of the VTF file format aligned to 16 bytes. -*/ -struct alignas(16) SVTFHeader_70_A : public SVTFHeader_70 {}; + //! VTFHeader_70 struct. + /*! -//! VTFHeader_71 struct. -/*! + The complete header for v7.0 of the VTF file format. + */ + struct SVTFHeader_70 : public SVTFFileHeader + { + vlUShort Width; //!< Width of the largest image + vlUShort Height; //!< Height of the largest image + vlUInt Flags; //!< Flags for the image + vlUShort Frames; //!< Number of frames if animated (1 for no animation) + vlUShort StartFrame; //!< Start frame (always 0) + vlByte Padding0[4]; //!< Reflectivity padding (16 byte alignment) + vlSingle Reflectivity[3]; //!< Reflectivity vector + vlByte Padding1[4]; //!< Reflectivity padding (8 byte packing) + vlSingle BumpScale; //!< Bump map scale + VTFImageFormat ImageFormat; //!< Image format index + vlByte MipCount; //!< Number of MIP levels (including the largest image) + VTFImageFormat LowResImageFormat; //!< Image format of the thumbnail image + vlByte LowResImageWidth; //!< Thumbnail image width + vlByte LowResImageHeight; //!< Thumbnail image height + }; - The complete header for v7.1 of the VTF file format. -*/ -struct SVTFHeader_71 : public SVTFHeader_70 -{ + //! VTFHeader_70_A struct. + /*! -}; + The complete header for v7.0 of the VTF file format aligned to 16 bytes. + */ + struct alignas( 16 ) SVTFHeader_70_A : public SVTFHeader_70 + { + }; -//! VTFHeader_71_A struct. -/*! + //! VTFHeader_71 struct. + /*! - The complete header for v7.1 of the VTF file format aligned to 16 bytes. -*/ -struct alignas(16) SVTFHeader_71_A : public SVTFHeader_71 {}; + The complete header for v7.1 of the VTF file format. + */ + struct SVTFHeader_71 : public SVTFHeader_70 + { + }; -//! VTFHeader_72 struct. -/*! + //! VTFHeader_71_A struct. + /*! - The complete header for v7.2 of the VTF file format. -*/ -struct SVTFHeader_72 : public SVTFHeader_71 -{ - vlUShort Depth; //!< Depth of the largest image -}; + The complete header for v7.1 of the VTF file format aligned to 16 bytes. + */ + struct alignas( 16 ) SVTFHeader_71_A : public SVTFHeader_71 + { + }; -//! VTFHeader_72_A struct. -/*! + //! VTFHeader_72 struct. + /*! - The complete header for v7.2 of the VTF file format aligned to 16 bytes. -*/ -struct alignas(16) SVTFHeader_72_A : public SVTFHeader_72 {}; + The complete header for v7.2 of the VTF file format. + */ + struct SVTFHeader_72 : public SVTFHeader_71 + { + vlUShort Depth; //!< Depth of the largest image + }; -//! VTFHeader_73 struct. -/*! + //! VTFHeader_72_A struct. + /*! - The complete header for v7.3 of the VTF file format. -*/ -struct SVTFHeader_73 : public SVTFHeader_72 -{ - vlByte Padding2[3]; - vlUInt ResourceCount; //!< Number of image resources -}; + The complete header for v7.2 of the VTF file format aligned to 16 bytes. + */ + struct alignas( 16 ) SVTFHeader_72_A : public SVTFHeader_72 + { + }; -//! VTFHeader_72_A struct. -/*! + //! VTFHeader_73 struct. + /*! - The complete header for v7.3 of the VTF file format aligned to 16 bytes. -*/ -struct alignas(16) SVTFHeader_73_A : public SVTFHeader_73 {}; + The complete header for v7.3 of the VTF file format. + */ + struct SVTFHeader_73 : public SVTFHeader_72 + { + vlByte Padding2[3]; + vlUInt ResourceCount; //!< Number of image resources + }; -//! VTFHeader_74 struct. -/*! + //! VTFHeader_72_A struct. + /*! - The complete header for v7.4 of the VTF file format. -*/ -struct SVTFHeader_74 : public SVTFHeader_73 -{ + The complete header for v7.3 of the VTF file format aligned to 16 bytes. + */ + struct alignas( 16 ) SVTFHeader_73_A : public SVTFHeader_73 + { + }; -}; + //! VTFHeader_74 struct. + /*! -//! VTFHeader_74_A struct. -/*! + The complete header for v7.4 of the VTF file format. + */ + struct SVTFHeader_74 : public SVTFHeader_73 + { + }; - The complete header for v7.4 of the VTF file format aligned to 16 bytes. -*/ -struct alignas(16) SVTFHeader_74_A : public SVTFHeader_74 {}; + //! VTFHeader_74_A struct. + /*! -//! VTFHeader_75 struct. -/*! + The complete header for v7.4 of the VTF file format aligned to 16 bytes. + */ + struct alignas( 16 ) SVTFHeader_74_A : public SVTFHeader_74 + { + }; - The complete header for v7.5 of the VTF file format. -*/ -struct SVTFHeader_75 : public SVTFHeader_74 -{ + //! VTFHeader_75 struct. + /*! -}; + The complete header for v7.5 of the VTF file format. + */ + struct SVTFHeader_75 : public SVTFHeader_74 + { + }; -//! VTFHeader_75_A struct. -/*! + //! VTFHeader_75_A struct. + /*! - The complete header for v7.5 of the VTF file format aligned to 16 bytes. -*/ -struct alignas(16) SVTFHeader_75_A : public SVTFHeader_75 {}; + The complete header for v7.5 of the VTF file format aligned to 16 bytes. + */ + struct alignas( 16 ) SVTFHeader_75_A : public SVTFHeader_75 + { + }; -//! VTFHeader_76 struct. -/*! + //! VTFHeader_76 struct. + /*! - The complete header for v7.6 of the VTF file format. -*/ -struct SVTFHeader_76 : public SVTFHeader_75 {}; + The complete header for v7.6 of the VTF file format. + */ + struct SVTFHeader_76 : public SVTFHeader_75 + { + }; -//! VTFHeader_76_A struct. -/*! + //! VTFHeader_76_A struct. + /*! - The complete header for v7.6 of the VTF file format aligned to 16 bytes. -*/ -struct alignas(16) SVTFHeader_76_A : public SVTFHeader_76 {}; + The complete header for v7.6 of the VTF file format aligned to 16 bytes. + */ + struct alignas( 16 ) SVTFHeader_76_A : public SVTFHeader_76 + { + }; -struct SVTFResource -{ - union - { - vlUInt Type; - struct + struct SVTFResource + { + union { - vlByte ID[3]; //!< Unique resource ID - vlByte Flags; //!< Resource flags + vlUInt Type; + struct + { + vlByte ID[3]; //!< Unique resource ID + vlByte Flags; //!< Resource flags + }; }; + vlUInt Data; //!< Resource data (e.g. for a CRC) or offset from start of the file }; - vlUInt Data; //!< Resource data (e.g. for a CRC) or offset from start of the file -}; -struct SVTFResourceData -{ - vlUInt Size; //!< Resource data buffer size - vlByte *Data; //!< Resource data bufffer -}; - -typedef struct tagSVTFTextureLODControlResource -{ - vlByte ResolutionClampU; - vlByte ResolutionClampV; - vlByte Padding[2]; -} SVTFTextureLODControlResource; - -typedef struct tagSVTFTextureSettingsExResource -{ - vlByte Flags0; - vlByte Flags1; - vlByte Flags2; - vlByte Flags3; -} SVTFTextureSettingsExResource; - -typedef struct tagSVTFAuxCompressionInfoHeader -{ - static constexpr vlInt32 DEFAULT_COMPRESSION = -1; - - vlInt32 CompressionLevel; // -1 = default, 0 = no compression, 1-9 = specific compression from lowest to highest -} SVTFAuxCompressionInfoHeader; - -typedef struct tagSVTFAuxCompressionInfoEntry -{ - vlUInt32 CompressedSize; // Size of compressed face image data -} SVTFAuxCompressionInfoEntry; + struct SVTFResourceData + { + vlUInt Size; //!< Resource data buffer size + vlByte *Data; //!< Resource data bufffer + }; -struct SVTFHeader : public SVTFHeader_74_A -{ - vlByte Padding3[8]; - SVTFResource Resources[VTF_RSRC_MAX_DICTIONARY_ENTRIES]; - SVTFResourceData Data[VTF_RSRC_MAX_DICTIONARY_ENTRIES]; -}; + typedef struct tagSVTFTextureLODControlResource + { + vlByte ResolutionClampU; + vlByte ResolutionClampV; + vlByte Padding[2]; + } SVTFTextureLODControlResource; + + typedef struct tagSVTFTextureSettingsExResource + { + vlByte Flags0; + vlByte Flags1; + vlByte Flags2; + vlByte Flags3; + } SVTFTextureSettingsExResource; + + typedef struct tagSVTFAuxCompressionInfoHeader + { + static constexpr vlInt32 DEFAULT_COMPRESSION = -1; + + vlInt32 CompressionLevel; // -1 = default, 0 = no compression, 1-9 = specific compression from lowest to highest + } SVTFAuxCompressionInfoHeader; + + typedef struct tagSVTFAuxCompressionInfoEntry + { + vlUInt32 CompressedSize; // Size of compressed face image data + } SVTFAuxCompressionInfoEntry; + + struct SVTFHeader : public SVTFHeader_74_A + { + vlByte Padding3[8]; + SVTFResource Resources[VTF_RSRC_MAX_DICTIONARY_ENTRIES]; + SVTFResourceData Data[VTF_RSRC_MAX_DICTIONARY_ENTRIES]; + }; #pragma pack()