OGRE  2.1.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::HlmsTextureManager Class Reference

HLMS Texture Manager manages textures in the way HLMS expects. More...

#include <OgreHlmsTextureManager.h>

+ Inheritance diagram for Ogre::HlmsTextureManager:

Classes

struct  DefaultTextureParameters
 
struct  TextureLocation
 
struct  Threshold
 Textures whose size are less or equal to minTextureSize (without considering mipmaps) will have their maxTexturesPerArray clamped to the value given in this threshold structure. More...
 

Public Types

enum  PackingMethod { TextureArrays, Atlas }
 
enum  TextureMapType {
  TEXTURE_TYPE_DIFFUSE, TEXTURE_TYPE_MONOCHROME, TEXTURE_TYPE_NORMALS, TEXTURE_TYPE_ENV_MAP,
  TEXTURE_TYPE_DETAIL, TEXTURE_TYPE_DETAIL_NORMAL_MAP, TEXTURE_TYPE_NON_COLOR_DATA, NUM_TEXTURE_TYPES
}
 
typedef vector< Threshold >::type ThresholdVec
 

Public Member Functions

 HlmsTextureManager ()
 
virtual ~HlmsTextureManager ()
 
void _changeRenderSystem (RenderSystem *newRs)
 Called when the RenderSystem changes. More...
 
void createFromTexturePack (const HlmsTexturePack &pack)
 
TextureLocation createOrRetrieveTexture (const String &texName, TextureMapType mapType)
 Create a texture based on its name. More...
 
TextureLocation createOrRetrieveTexture (const String &aliasName, const String &texName, TextureMapType mapType, Image *imgSource=0)
 See other overload. More...
 
void destroyTexture (IdString aliasName)
 Destroys a texture. More...
 
void dumpMemoryUsage (Log *log=NULL) const
 Dumps to the Ogre log passed as parameter (if NULL, uses the default one) in csv format (separator is '|') the usage statistics of all textures currently loaded by the texture manager. More...
 
const StringfindAliasName (const TextureLocation &textureLocation) const
 Finds the alias name of a texture given its TextureLocation. More...
 
const StringfindResourceNameFromAlias (IdString alias) const
 
TextureLocation getBlankTexture (void) const
 Returns the precreated blank texture. More...
 
DefaultTextureParametersgetDefaultTextureParameters (void)
 
void initialize (void)
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info More...
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
void * operator new[] (size_t sz)
 

Detailed Description

HLMS Texture Manager manages textures in the way HLMS expects.

Most HLMS implementations, when creating a datablock/material with a texture, you can't remove the texture or use a null ptr texture; either you create a new datablock, or use an empty dummy texture. This manager ensures you always get at least a dummy texture.
Its other main job is to provide UV atlas on the fly and/or texture arrays on the fly. To do that, we group textures into categories: Different categories have different default parameters. By default all types try to use array textures unless the RenderSystem API doesn't support it (in which case fallbacks to UV atlas).
For example, Diffuse & detail textures enable hardware gamma correction. Normal maps attempt to use BC5 compression, or uncompress UV8, in that order (depends on HW support). Detail maps default to not using UV atlas when texture arrays aren't supported (because detail maps are often meant to be tileable), etc

Member Typedef Documentation

◆ ThresholdVec

Member Enumeration Documentation

◆ PackingMethod

Enumerator
TextureArrays 
Atlas 

◆ TextureMapType

Enumerator
TEXTURE_TYPE_DIFFUSE 
TEXTURE_TYPE_MONOCHROME 
TEXTURE_TYPE_NORMALS 
TEXTURE_TYPE_ENV_MAP 
TEXTURE_TYPE_DETAIL 
TEXTURE_TYPE_DETAIL_NORMAL_MAP 
TEXTURE_TYPE_NON_COLOR_DATA 
NUM_TEXTURE_TYPES 

Constructor & Destructor Documentation

◆ HlmsTextureManager()

Ogre::HlmsTextureManager::HlmsTextureManager ( )

◆ ~HlmsTextureManager()

virtual Ogre::HlmsTextureManager::~HlmsTextureManager ( )
virtual

Member Function Documentation

◆ _changeRenderSystem()

void Ogre::HlmsTextureManager::_changeRenderSystem ( RenderSystem newRs)

Called when the RenderSystem changes.

Remarks
Some settings in mDefaultTextureParameters will be reset

◆ createFromTexturePack()

void Ogre::HlmsTextureManager::createFromTexturePack ( const HlmsTexturePack pack)

◆ createOrRetrieveTexture() [1/2]

TextureLocation Ogre::HlmsTextureManager::createOrRetrieveTexture ( const String texName,
TextureMapType  mapType 
)

Create a texture based on its name.

If a texture with such name has already been created, retrieves the existing one.

Parameters
texNameName of the texture (e.g. "myTextureFile.dds" "penguin.jpg")
mapTypeThe type of texture map this texture is going to be. See the class overview documentation for an explanation of the differences. If the texture has already been created, this parameter is ignored.
Returns
retVal.texture The texture that should be bound

if packingMethond == TextureArrays retVal.xIdx: The array index in the texture array. if packingMethond == Atlas retVal.xIdx: The U offset to apply to UVs retVal.yIdx: The V offset to apply to UVs retVal.divisor: The value the original UVs have to be divided for

◆ createOrRetrieveTexture() [2/2]

TextureLocation Ogre::HlmsTextureManager::createOrRetrieveTexture ( const String aliasName,
const String texName,
TextureMapType  mapType,
Image imgSource = 0 
)

See other overload.

This one allows aliasing a texture. If you have "VERY_TECHNICAL_NAME_HASH_1234.png" as texName, you can make your first call with aliasName as "Tree Wood", and the next calls to createOrRetrieveTexture( "Tree Wood", mapType ) will refer to this texture NOTE: aliasName cannot be blank/empty.

Parameters
imgSourceWhen null, texture is loaded from texName as a file. When not null, texture is loaded from imgSource and texName is ignored (still used in logging messages though). Note imgSource may be modified (e.g. to generate mipmaps). Note this pointer is ignored if the texture already exists and is just being retrieved.

◆ destroyTexture()

void Ogre::HlmsTextureManager::destroyTexture ( IdString  aliasName)

Destroys a texture.

If the array has multiple entries, the entry for this texture is sent back to a waiting list for a future new entry. Trying to read from this texture after this call may result in garbage.

◆ dumpMemoryUsage()

void Ogre::HlmsTextureManager::dumpMemoryUsage ( Log log = NULL) const

Dumps to the Ogre log passed as parameter (if NULL, uses the default one) in csv format (separator is '|') the usage statistics of all textures currently loaded by the texture manager.

Useful for profiling or determining sources of waste GPU RAM.

◆ findAliasName()

const String* Ogre::HlmsTextureManager::findAliasName ( const TextureLocation textureLocation) const

Finds the alias name of a texture given its TextureLocation.

Useful for retrieving back the name of a texture as it was called via createOrRetrieveTexture. Returns null if not found. Note the returned pointer may be invalidated if new calls are made to createOrRetrieveTexture or destroyTexture

◆ findResourceNameFromAlias()

const String* Ogre::HlmsTextureManager::findResourceNameFromAlias ( IdString  alias) const

◆ getBlankTexture()

TextureLocation Ogre::HlmsTextureManager::getBlankTexture ( void  ) const

Returns the precreated blank texture.

◆ getDefaultTextureParameters()

DefaultTextureParameters* Ogre::HlmsTextureManager::getDefaultTextureParameters ( void  )
inline

◆ initialize()

void Ogre::HlmsTextureManager::initialize ( void  )

◆ operator delete() [1/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

◆ operator delete() [2/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inlineinherited

◆ operator delete() [3/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

◆ operator delete[]() [1/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inlineinherited

◆ operator delete[]() [2/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

◆ operator new() [1/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

operator new, with debug line info

◆ operator new() [2/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

◆ operator new() [3/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
)
inlineinherited

placement operator new

◆ operator new[]() [1/2]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

array operator new, with debug line info

◆ operator new[]() [2/2]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

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