All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
pvrtexture::CPVRTexture Class Reference

A full public texture container format, with support for custom meta-data, and complete, optimised, resource loading code into PVRTools. More...

#include <PVRTexture.h>

Inheritance diagram for pvrtexture::CPVRTexture:
Inheritance graph
[legend]

Public Member Functions

 CPVRTexture ()
 Creates a new empty texture. More...
 
 CPVRTexture (const CPVRTextureHeader &sHeader, const void *pData=NULL)
 Creates a new texture based on a texture header, pre-allocating the correct amount of memory. If data is supplied, it will be copied into memory. More...
 
 CPVRTexture (const char *szFilePath)
 Creates a new texture from a filepath. More...
 
 CPVRTexture (const void *pTexture)
 Creates a new texture from a pointer that includes a header structure, meta data and texture data as laid out in a file. This functionality is primarily for user-defined file loading. Header may be any version of pvr. More...
 
 CPVRTexture (const CPVRTexture &texture)
 Creates a new texture as a copy of another. More...
 
 ~CPVRTexture ()
 Deconstructor for CPVRTextures. More...
 
CPVRTextureoperator= (const CPVRTexture &rhs)
 Will copy the contents and information of another texture into this one. More...
 
void * getDataPtr (uint32 uiMIPLevel=0, uint32 uiArrayMember=0, uint32 uiFaceNumber=0) const
 Returns a pointer into the texture's data. More...
 
const CPVRTextureHeadergetHeader () const
 Gets the header for this texture, allowing you to create a new texture based on this one with some changes. Useful for passing information about a texture without passing all of its data. More...
 
void addPaddingMetaData (uint32 uiPadding)
 When writing the texture out to a PVR file, it is often desirable to pad the meta data so that the start of the texture data aligns to a given boundary. More...
 
bool saveFile (const CPVRTString &filepath) const
 Writes out to a file, given a filename and path. More...
 
bool saveFileLegacyPVR (const CPVRTString &filepath, ELegacyApi eApi) const
 Writes out to a file, stripping any extensions specified and appending .pvr. This function is for legacy support only and saves out to PVR Version 2 file. The target api must be specified in order to save to this format. More...
 
- Public Member Functions inherited from pvrtexture::CPVRTextureHeader
 CPVRTextureHeader ()
 Default constructor for a CPVRTextureHeader. Returns an empty header. More...
 
 CPVRTextureHeader (PVRTextureHeaderV3 fileHeader, uint32 metaDataCount=0, MetaDataBlock *metaData=NULL)
 Creates a new texture header from a PVRTextureHeaderV3, and appends Meta data if any is supplied. More...
 
 CPVRTextureHeader (uint64 u64PixelFormat, uint32 u32Height=1, uint32 u32Width=1, uint32 u32Depth=1, uint32 u32NumMipMaps=1, uint32 u32NumArrayMembers=1, uint32 u32NumFaces=1, EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB, EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false)
 Creates a new texture header based on individual header variables. More...
 
CPVRTextureHeaderoperator= (const CPVRTextureHeader &rhs)
 Will copy the contents and information of another header into this one. More...
 
PVRTextureHeaderV3 getFileHeader () const
 Gets the file header structure. More...
 
PixelType getPixelType () const
 Gets the 64-bit pixel type ID of the texture. More...
 
uint32 getBitsPerPixel () const
 Gets the bits per pixel of the texture format. More...
 
EPVRTColourSpace getColourSpace () const
 Returns the colour space of the texture. More...
 
EPVRTVariableType getChannelType () const
 Returns the variable type that the texture's data is stored in. More...
 
uint32 getWidth (uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const
 Gets the width of the user specified MIP-Map level for the texture. More...
 
uint32 getHeight (uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const
 Gets the height of the user specified MIP-Map level for the texture. More...
 
uint32 getDepth (uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const
 Gets the depth of the user specified MIP-Map level for the texture. More...
 
uint32 getTextureSize (int32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces=true, bool bAllFaces=true) const
 Gets the size in PIXELS of the texture, given various input parameters. User can retrieve the total 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. All of these. More...
 
uint32 getDataSize (int32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces=true, bool bAllFaces=true) const
 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. More...
 
uint32 getNumArrayMembers () const
 Gets the number of array members stored in this texture. More...
 
uint32 getNumMIPLevels () const
 Gets the number of MIP-Map levels stored in this texture. More...
 
uint32 getNumFaces () const
 Gets the number of faces stored in this texture. More...
 
EPVRTOrientation getOrientation (EPVRTAxis axis) const
 Gets the data orientation for this texture. More...
 
bool isFileCompressed () const
 Returns whether or not the texture is compressed using PVRTexLib's FILE compression - this is independent of any texture compression. More...
 
bool isPreMultiplied () const
 Returns whether or not the texture's colour has been pre-multiplied by the alpha values. More...
 
uint32 getMetaDataSize () const
 Returns the total size of the meta data stored in the header. This includes the size of all information stored in all MetaDataBlocks. More...
 
void getOGLFormat (uint32 &internalformat, uint32 &format, uint32 &type) const
 Gets the OpenGL equivalent values of internal format, format and type for this texture. This will return any supported OpenGL texture values, it is up to the user to decide if these are valid for their current platform. More...
 
void getOGLESFormat (uint32 &internalformat, uint32 &format, uint32 &type) const
 Gets the OpenGLES equivalent values of internal format, format and type for this texture. This will return any supported OpenGLES texture values, it is up to the user to decide if these are valid for their current platform. More...
 
uint32 getD3DFormat () const
 Gets the D3DFormat (up to DirectX 9 and Direct 3D Mobile) equivalent values for this texture. This will return any supported D3D texture formats, it is up to the user to decide if this is valid for their current platform. More...
 
uint32 getDXGIFormat () const
 Gets the DXGIFormat (DirectX 10 onward) equivalent values for this texture. This will return any supported DX texture formats, it is up to the user to decide if this is valid for their current platform. More...
 
void setPixelFormat (PixelType uPixelFormat)
 Sets the pixel format for this texture. More...
 
void setColourSpace (EPVRTColourSpace eColourSpace)
 Sets the colour space for this texture. Default is lRGB. More...
 
void setChannelType (EPVRTVariableType eVarType)
 Sets the variable type for the channels in this texture. More...
 
bool setOGLFormat (const uint32 &internalformat, const uint32 &format, const uint32 &type)
 Sets the format of the texture to PVRTexLib's internal representation of the OGL format. More...
 
bool setOGLESFormat (const uint32 &internalformat, const uint32 &format, const uint32 &type)
 Sets the format of the texture to PVRTexLib's internal representation of the OGLES format. More...
 
bool setD3DFormat (const uint32 &DWORD_D3D_FORMAT)
 Sets the format of the texture to PVRTexLib's internal representation of the D3D format. More...
 
bool setDXGIFormat (const uint32 &DWORD_DXGI_FORMAT)
 Sets the format of the texture to PVRTexLib's internal representation of the DXGI format. More...
 
void setWidth (uint32 newWidth)
 Sets the width. More...
 
void setHeight (uint32 newHeight)
 Sets the height. More...
 
void setDepth (uint32 newDepth)
 Sets the depth. More...
 
void setNumArrayMembers (uint32 newNumMembers)
 Sets the depth. More...
 
void setNumMIPLevels (uint32 newNumMIPLevels)
 Sets the number of MIP-Map levels in this texture. More...
 
void setNumFaces (uint32 newNumFaces)
 Sets the number of faces stored in this texture. More...
 
void setOrientation (EPVRTOrientation eAxisOrientation)
 Sets the data orientation for a given axis in this texture. More...
 
void setIsFileCompressed (bool isFileCompressed)
 Sets whether or not the texture is compressed using PVRTexLib's FILE compression - this is independent of any texture compression. Currently unsupported. More...
 
void setIsPreMultiplied (bool isPreMultiplied)
 Sets whether or not the texture's colour has been pre-multiplied by the alpha values. More...
 
bool isBumpMap () const
 Returns whether the texture is a bump map or not. More...
 
float getBumpMapScale () const
 Gets the bump map scaling value for this texture. More...
 
CPVRTString getBumpMapOrder () const
 Gets the bump map channel order relative to rgba. More...
 
int getNumTextureAtlasMembers () const
 Works out the number of possible texture atlas members in the texture based on the w/h/d and the data size. More...
 
const float * getTextureAtlasData () const
 Returns a pointer to the texture atlas data. More...
 
CPVRTString getCubeMapOrder () const
 Gets the cube map face order. More...
 
void getBorder (uint32 &uiBorderWidth, uint32 &uiBorderHeight, uint32 &uiBorderDepth) const
 Obtains the border size in each dimension for this texture. More...
 
MetaDataBlock getMetaData (uint32 DevFOURCC, uint32 u32Key) const
 Returns a block of meta data from the texture. If the meta data doesn't exist, a block with data size 0 will be returned. More...
 
bool hasMetaData (uint32 DevFOURCC, uint32 u32Key) const
 Returns whether or not the specified meta data exists as part of this texture header. More...
 
const MetaDataMapgetMetaDataMap () const
 A pointer directly to the Meta Data Map, to allow users to read out data. More...
 
void setBumpMap (float bumpScale, CPVRTString bumpOrder="xyz")
 Sets a texture's bump map data. More...
 
void setTextureAtlas (float *pAtlasData, uint32 dataSize)
 Sets the texture atlas coordinate meta data for later display. It is up to the user to make sure that this texture atlas data actually makes sense in the context of the header. It is suggested that the "generateTextureAtlas" method in the tools is used to create a texture atlas, manually setting one up is possible but should be done with care. More...
 
void setCubeMapOrder (CPVRTString cubeMapOrder="XxYyZz")
 Sets a texture's bump map data. More...
 
void setBorder (uint32 uiBorderWidth, uint32 uiBorderHeight, uint32 uiBorderDepth)
 Sets a texture's border size data. This value is subtracted from the current texture height/width/depth to get the valid texture data. More...
 
void addMetaData (const MetaDataBlock &MetaBlock)
 Adds an arbitrary piece of meta data. More...
 
void removeMetaData (const uint32 &DevFOURCC, const uint32 &u32Key)
 Removes a specified piece of meta data, if it exists. More...
 

Additional Inherited Members

- Protected Attributes inherited from pvrtexture::CPVRTextureHeader
PVRTextureHeaderV3 m_sHeader
 Texture header as laid out in a file. More...
 
CPVRTMap< uint32, CPVRTMap
< uint32, MetaDataBlock > > 
m_MetaData
 Map of all the meta data stored for a texture. More...
 

Detailed Description

A full public texture container format, with support for custom meta-data, and complete, optimised, resource loading code into PVRTools.


Constructor & Destructor Documentation

pvrtexture::CPVRTexture::CPVRTexture ( )

Creates a new empty texture.


Returns
A new CPVRTexture.
pvrtexture::CPVRTexture::CPVRTexture ( const CPVRTextureHeader sHeader,
const void *  pData = NULL 
)

Creates a new texture based on a texture header, pre-allocating the correct amount of memory. If data is supplied, it will be copied into memory.


Parameters
[in]sHeaderTexture header
[in]pDataTexture data
Returns
A new CPVRTexture.
pvrtexture::CPVRTexture::CPVRTexture ( const char *  szFilePath)

Creates a new texture from a filepath.


Parameters
[in]szFilePathFile path to existing texture
Returns
A new CPVRTexture.
pvrtexture::CPVRTexture::CPVRTexture ( const void *  pTexture)

Creates a new texture from a pointer that includes a header structure, meta data and texture data as laid out in a file. This functionality is primarily for user-defined file loading. Header may be any version of pvr.


Parameters
[in]pTexturePointer to texture data
Returns
A new CPVRTexture.
pvrtexture::CPVRTexture::CPVRTexture ( const CPVRTexture texture)

Creates a new texture as a copy of another.


Parameters
[in]textureTexture to copy
Returns
A new CPVRTexture
pvrtexture::CPVRTexture::~CPVRTexture ( )

Deconstructor for CPVRTextures.


Member Function Documentation

void pvrtexture::CPVRTexture::addPaddingMetaData ( uint32  uiPadding)

When writing the texture out to a PVR file, it is often desirable to pad the meta data so that the start of the texture data aligns to a given boundary.


This function pads to a boundary value equal to "uiPadding". For example setting uiPadding=8 will align the start of the texture data to an 8 byte boundary. Note - this should be called immediately before saving as the value is worked out based on the current meta data size.

Parameters
[in]uiPaddingPadding boundary value
void* pvrtexture::CPVRTexture::getDataPtr ( uint32  uiMIPLevel = 0,
uint32  uiArrayMember = 0,
uint32  uiFaceNumber = 0 
) const

Returns a pointer into the texture's data.


It is possible to specify an offset to specific array members, faces and MIP Map levels.

Parameters
[in]uiMIPLevelOffset to MIP Map levels
[in]uiArrayMemberOffset to array members
[in]uiFaceNumberOffset to face numbers
Returns
Pointer to a location in the texture.
const CPVRTextureHeader& pvrtexture::CPVRTexture::getHeader ( ) const

Gets the header for this texture, allowing you to create a new texture based on this one with some changes. Useful for passing information about a texture without passing all of its data.


Returns
Returns the header only for this texture.
CPVRTexture& pvrtexture::CPVRTexture::operator= ( const CPVRTexture rhs)

Will copy the contents and information of another texture into this one.


Parameters
[in]rhsTexture to copy
Returns
This texture.
bool pvrtexture::CPVRTexture::saveFile ( const CPVRTString &  filepath) const

Writes out to a file, given a filename and path.


File type will be determined by the extension present in the string. If no extension is present, PVR format will be selected. Unsupported formats will result in failure.

Parameters
[in]filepathFile path to write to
Returns
True if the method succeeds.
bool pvrtexture::CPVRTexture::saveFileLegacyPVR ( const CPVRTString &  filepath,
ELegacyApi  eApi 
) const

Writes out to a file, stripping any extensions specified and appending .pvr. This function is for legacy support only and saves out to PVR Version 2 file. The target api must be specified in order to save to this format.


Parameters
[in]filepathFile path to write to
[in]eApiTarget API
Returns
True if the method succeeds.

The documentation for this class was generated from the following file: