"L. Spiro Engine"
Classes | Public Member Functions | Protected Types | Protected Attributes

lsg::CTextureManager Class Reference

A texture manager. More...

#include <LSGTextureManager.h>

List of all members.

Classes

struct  LSG_TEXTURE_DATA
struct  LSG_TEXTURE_DATA_COMBINED

Public Member Functions

CSharedStdTexPtr LSE_CALL CreateSharedTexFromMemory (LSUINT32 _ui32Crc1, LSUINT32 _ui32Crc2, const LSUINT8 *_pui8Data, LSUINTPTR _uiptrLen, const LSG_TEX_PARMS &_tpParms)
CSharedStdTexPtr LSE_CALL CreateSharedTexFromFile (const LSCHAR *_pcPath, const LSG_TEX_PARMS &_tpParms)
CSharedStdTexPtr LSE_CALL CreateNormalMapFromBumpTexture (LSUINT32 _ui32Crc1, LSUINT32 _ui32Crc2, const CSharedStdTexPtr _sstpBumpTexture, LSBOOL _bWrapX=true, LSBOOL _bWrapY=true)
CSharedStdTexPtr LSE_CALL CombineRgbAlphaTextures (LSUINT32 _ui32CrcRgb1, LSUINT32 _ui32CrcRgb2, const CSharedStdTexPtr _sstpRgbTexture, LSUINT32 _ui32CrcAlpha1, LSUINT32 _ui32CrcAlpha2, const CSharedStdTexPtr _sstpAlphaTexture, const LSG_TEX_PARMS &_tpParms)
LSVOID LSE_CALL Release ()
LSVOID LSE_CALL ReleaseUnreferenced ()

Protected Types

typedef struct
lsg::CTextureManager::LSG_TEXTURE_DATA
LPLSG_TEXTURE_DATA
typedef struct
lsg::CTextureManager::LSG_TEXTURE_DATA 
LPCLSG_TEXTURE_DATA
typedef struct
lsg::CTextureManager::LSG_TEXTURE_DATA_COMBINED
LPLSG_TEXTURE_DATA_COMBINED
typedef struct
lsg::CTextureManager::LSG_TEXTURE_DATA_COMBINED 
LPCLSG_TEXTURE_DATA_COMBINED

Protected Attributes

CMap< LSG_TEXTURE_DATA,
CSharedStdTexPtr
m_mSharedData
CMap< LSG_TEXTURE_DATA,
LSG_TEXTURE_DATA
m_mBumpConversions
CMap
< LSG_TEXTURE_DATA_COMBINED,
LSG_TEXTURE_DATA
m_mCombinedTextures

Detailed Description

A texture manager.

Class CTextureManager Description: A texture manager. It handles sharing of textures and prevents duplicate textures from being stored.


Member Typedef Documentation

The sorting key for the shared texture map used by this class. When file names match exactly, the key is considered a match. Otherwise, the key is considered a match if both CRC values match.

The sorting key for the shared texture map used by this class. When both sets of texture data are the same, there is a match.


Member Function Documentation

CSharedStdTexPtr LSE_CALL lsg::CTextureManager::CombineRgbAlphaTextures ( LSUINT32  _ui32CrcRgb1,
LSUINT32  _ui32CrcRgb2,
const CSharedStdTexPtr  _sstpRgbTexture,
LSUINT32  _ui32CrcAlpha1,
LSUINT32  _ui32CrcAlpha2,
const CSharedStdTexPtr  _sstpAlphaTexture,
const LSG_TEX_PARMS _tpParms 
)

Gets a shared texture created by combining an RGB texture with an alpha texture.

Parameters:
_ui32CrcRgb1The first CRC value of the RGB texture.
_ui32CrcRgb2The second CRC value of the RGB texture.
_sstpRgbTextureThe RGB texture.
_ui32CrcAlpha1The first CRC value of the alpha texture.
_ui32CrcAlpha2The second CRC value of the alpha texture.
_sstpAlphaTextureThe alpha texture.
_tpParmsParameters to use to create the texture if it does not already exist.
Returns:
Returns a shared pointer to the RGBA result of combining the given textures. If the textures have already been combined, the existing shared pointer is returned.
CSharedStdTexPtr LSE_CALL lsg::CTextureManager::CreateNormalMapFromBumpTexture ( LSUINT32  _ui32Crc1,
LSUINT32  _ui32Crc2,
const CSharedStdTexPtr  _sstpBumpTexture,
LSBOOL  _bWrapX = true,
LSBOOL  _bWrapY = true 
)

Gets a shared texture given an existing bump texture and its CRC pairs. The bump texture is converted to shared normal map which is returned.

Parameters:
_ui32Crc1The first CRC value.
_ui32Crc2The second CRC value.
_sstpBumpTextureThe bump texture to convert to a normal map.
_bWrapXIf true, the normal map is calculated with wrapping at the horizontal borders.
_bWrapYIf true, the normal map is calculated with wrapping at the vertical borders.
Returns:
Returns a shared pointer to the normal map of the given bump texture. If the bump texture was already converted, the existing shared pointer is returned.
CSharedStdTexPtr LSE_CALL lsg::CTextureManager::CreateSharedTexFromFile ( const LSCHAR *  _pcPath,
const LSG_TEX_PARMS _tpParms 
)

Gets a shared texture given a file path and some filtering parameters.

Parameters:
_pcPathThe path of the file to load.
_tpParmsParameters to use to create the texture if it does not already exist.
Returns:
Returns a shared pointer to a texture. If the texture did not exist and not enough resources were available to create it, an invalid pointer is returned.
CSharedStdTexPtr LSE_CALL lsg::CTextureManager::CreateSharedTexFromMemory ( LSUINT32  _ui32Crc1,
LSUINT32  _ui32Crc2,
const LSUINT8 *  _pui8Data,
LSUINTPTR  _uiptrLen,
const LSG_TEX_PARMS _tpParms 
)

Gets a shared texture given two CRC values and some in-memory initialization data. The in-memory data is used to create a new texture should no matching texture already exist.

Parameters:
_ui32Crc1The first CRC value.
_ui32Crc2The second CRC value.
_pui8DataThe memory image of the image to create if necessary.
_uiptrLenLength of the data to which _pui8Data points.
_tpParmsParameters to use to create the texture if it does not already exist.
Returns:
Returns a shared pointer to a texture. If the texture did not exist and not enough resources were available to create it, an invalid pointer is returned.
LSVOID LSE_CALL lsg::CTextureManager::Release ( )

Decreases the reference count on all shared pointers. Any that reach a 0 reference count will be removed from the list.

LSVOID LSE_CALL lsg::CTextureManager::ReleaseUnreferenced ( )

Removes all shared pointers with a reference count of 1. By having a 1 reference count, the pointers are not referenced outside of the manager.


Member Data Documentation

Map of converted bump textures.

Map of combined textures.

Map of shared textures. The keys are LSG_TEXTURE_DATA structures and the values are CSharedStdTexPtr.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator