/*!**************************************************************************** @file PVRTTexture.h @copyright Copyright (c) Imagination Technologies Limited. @brief Texture loading. ******************************************************************************/ #ifndef _PVRTTEXTURE_H_ #define _PVRTTEXTURE_H_ #include "PVRTGlobal.h" /***************************************************************************** * Texture related constants and enumerations. *****************************************************************************/ // V3 Header Identifiers. const PVRTuint32 PVRTEX3_IDENT = 0x03525650; // 'P''V''R'3 const PVRTuint32 PVRTEX3_IDENT_REV = 0x50565203; // If endianness is backwards then PVR3 will read as 3RVP, hence why it is written as an int. //Current version texture identifiers const PVRTuint32 PVRTEX_CURR_IDENT = PVRTEX3_IDENT; const PVRTuint32 PVRTEX_CURR_IDENT_REV = PVRTEX3_IDENT_REV; // PVR Header file flags. Condition if true. If false, opposite is true unless specified. const PVRTuint32 PVRTEX3_FILE_COMPRESSED = (1<<0); // Texture has been file compressed using PVRTexLib (currently unused) const PVRTuint32 PVRTEX3_PREMULTIPLIED = (1<<1); // Texture has been premultiplied by alpha value. // Mip Map level specifier constants. Other levels are specified by 1,2...n const PVRTint32 PVRTEX_TOPMIPLEVEL = 0; const PVRTint32 PVRTEX_ALLMIPLEVELS = -1; //This is a special number used simply to return a total of all MIP levels when dealing with data sizes. //values for each meta data type that we know about. Texture arrays hinge on each surface being identical in all but content, including meta data. //If the meta data varies even slightly then a new texture should be used. It is possible to write your own extension to get around this however. enum EPVRTMetaData { ePVRTMetaDataTextureAtlasCoords=0, ePVRTMetaDataBumpData, ePVRTMetaDataCubeMapOrder, ePVRTMetaDataTextureOrientation, ePVRTMetaDataBorderData, ePVRTMetaDataPadding, ePVRTMetaDataNumMetaDataTypes }; enum EPVRTAxis { ePVRTAxisX = 0, ePVRTAxisY = 1, ePVRTAxisZ = 2 }; enum EPVRTOrientation { ePVRTOrientLeft = 1< class CPVRTMap; /*!*********************************************************************** @fn PVRTGetBitsPerPixel @param[in] u64PixelFormat A PVR Pixel Format ID. @return const PVRTuint32 Number of bits per pixel. @brief Returns the number of bits per pixel in a PVR Pixel Format identifier. *************************************************************************/ PVRTuint32 PVRTGetBitsPerPixel(PVRTuint64 u64PixelFormat); /*!*********************************************************************** @fn PVRTGetFormatMinDims @param[in] u64PixelFormat A PVR Pixel Format ID. @param[in,out] minX Returns the minimum width. @param[in,out] minY Returns the minimum height. @param[in,out] minZ Returns the minimum depth. @brief Gets the minimum dimensions (x,y,z) for a given pixel format. *************************************************************************/ void PVRTGetFormatMinDims(PVRTuint64 u64PixelFormat, PVRTuint32 &minX, PVRTuint32 &minY, PVRTuint32 &minZ); /*!*********************************************************************** @fn PVRTConvertOldTextureHeaderToV3 @param[in] LegacyHeader Legacy header for conversion. @param[in,out] NewHeader New header to output into. @param[in,out] pMetaData MetaData Map to output into. @brief Converts a legacy texture header (V1 or V2) to a current generation header (V3) *************************************************************************/ void PVRTConvertOldTextureHeaderToV3(const PVR_Texture_Header* LegacyHeader, PVRTextureHeaderV3& NewHeader, CPVRTMap >* pMetaData); /*!*********************************************************************** @fn PVRTMapLegacyTextureEnumToNewFormat @param[in] OldFormat Legacy Enumeration Value @param[in,out] newType New PixelType identifier. @param[in,out] newCSpace New ColourSpace @param[in,out] newChanType New Channel Type @param[in,out] isPreMult Whether format is pre-multiplied @brief Maps a legacy enumeration value to the new PVR3 style format. *************************************************************************/ void PVRTMapLegacyTextureEnumToNewFormat(PVRTPixelType OldFormat, PVRTuint64& newType, EPVRTColourSpace& newCSpace, EPVRTVariableType& newChanType, bool& isPreMult); /*!*************************************************************************** @fn PVRTTextureLoadTiled @param[in,out] pDst Texture to place the tiled data @param[in] nWidthDst Width of destination texture @param[in] nHeightDst Height of destination texture @param[in] pSrc Texture to tile @param[in] nWidthSrc Width of source texture @param[in] nHeightSrc Height of source texture @param[in] nElementSize Bytes per pixel @param[in] bTwiddled True if the data is twiddled @brief Needed by PVRTTextureTile() in the various PVRTTextureAPIs *****************************************************************************/ void PVRTTextureLoadTiled( PVRTuint8 * const pDst, const unsigned int nWidthDst, const unsigned int nHeightDst, const PVRTuint8 * const pSrc, const unsigned int nWidthSrc, const unsigned int nHeightSrc, const unsigned int nElementSize, const bool bTwiddled); /*!*************************************************************************** @fn PVRTTextureTwiddle @param[out] a Twiddled value @param[in] u Coordinate axis 0 @param[in] v Coordinate axis 1 @brief Combine a 2D coordinate into a twiddled value *****************************************************************************/ void PVRTTextureTwiddle(unsigned int &a, const unsigned int u, const unsigned int v); /*!*************************************************************************** @fn PVRTTextureDeTwiddle @param[out] u Coordinate axis 0 @param[out] v Coordinate axis 1 @param[in] a Twiddled value @brief Extract 2D coordinates from a twiddled value. *****************************************************************************/ void PVRTTextureDeTwiddle(unsigned int &u, unsigned int &v, const unsigned int a); /*!*********************************************************************** @fn PVRTGetTextureDataSize @param[in] sTextureHeader Specifies the texture header. @param[in] iMipLevel Specifies a mip level to check, 'PVRTEX_ALLMIPLEVELS' can be passed to get the size of all MIP levels. @param[in] bAllSurfaces Size of all surfaces is calculated if true, only a single surface if false. @param[in] bAllFaces Size of all faces is calculated if true, only a single face if false. @return PVRTuint32 Size in BYTES of the specified texture area. @brief Gets the size in BYTES of the texture, given various input parameters. User can retrieve the size of either all surfaces or a single surface, all faces or a single face and all MIP-Maps or a single specified MIP level. *************************************************************************/ PVRTuint32 PVRTGetTextureDataSize(PVRTextureHeaderV3 sTextureHeader, PVRTint32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true); #endif /* _PVRTTEXTURE_H_ */ /***************************************************************************** End of file (PVRTTexture.h) *****************************************************************************/