VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Member Functions | List of all members
TextureManager Class Reference

Class which loads and caches Textures. More...

Public Member Functions

TexturePtr getTexture (const QString &path)
 Returns a Texture containing the image at path relative to the standard image directory. More...
 
TexturePtr getTextureAsset (const QString &assetPath)
 Returns a Texture containing the image at assetPath relative to the standard asset directory. More...
 
TexturePtr getTextureImage (const QString &imagePath)
 Returns a Texture containing the image at imagePath relative to the standard image directory. More...
 
void markAllTexturesForDeletion ()
 Move all Textures currently cached onto the deletion list, to be deleted on the next call to processDeletion(). More...
 
void processDeletion ()
 Release references to all Textures on the delete list. More...
 

Detailed Description

Class which loads and caches Textures.

Textures are loaded as QSGTextures and wrapped into Texture objects. Returned textures are cached until the next call to markAllTexturesForDeletion() which occurs when Engine switches levels. Textures that are requested before the next frame ends are retained in the cache. Textures that were not referenced during that frame are released.

This is used to:

  1. Ensure that Textures are not deleted while they are in use by GL
  2. Reduce texture loads when changing levels

Member Function Documentation

TexturePtr TextureManager::getTexture ( const QString path)

Returns a Texture containing the image at path relative to the standard image directory.

Parameters
pathPlatform dependent absolute path of image to get
TexturePtr TextureManager::getTextureAsset ( const QString assetPath)

Returns a Texture containing the image at assetPath relative to the standard asset directory.

Parameters
assetPathPath of image to get
TexturePtr TextureManager::getTextureImage ( const QString imagePath)

Returns a Texture containing the image at imagePath relative to the standard image directory.

Parameters
imagePathPath of image to get
void TextureManager::markAllTexturesForDeletion ( )

Move all Textures currently cached onto the deletion list, to be deleted on the next call to processDeletion().

If a Texture on the delete list is requested through one of the getTexture() calls, it will move off the delete list and back into the cache.

See also
processDeletion()
void TextureManager::processDeletion ( )

Release references to all Textures on the delete list.

This list contains all Textures that have not been requested since the last call to markAllTexturesForDeletion().