Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CTextureManager Class Reference

Texture Manager class provides APIs to load, retrieve, check, and release textures within the engine. More...

#include <TextureManager/CTextureManager.h>

Classes

struct  STexturePackage
 Structure storing texture info: package, path, and pointer to the texture. More...

Public Member Functions

 CTextureManager ()
 Constructor.
virtual ~CTextureManager ()
 Destructor. Releases all resources.
void setCurrentPackage (const char *name)
 Set the current texture package name.
const char * getCurrentPackage ()
 Get the current texture package name.
void removeAllTexture ()
 Remove all loaded textures.
void removeTexture (const char *namePackage)
 Remove all textures in a specific package.
void removeTexture (ITexture *tex)
 Remove a specific texture resource.
const char * getTexturePath (ITexture *tex)
 Get the file path of a texture.
bool existTexture (const char *path)
 Check if a texture exists by path.
bool resolveTexturePath (const char *path, std::string &result)
 Finds the actual, existing file path for a texture, resolving the correct file extension.
bool isTextureLoaded (const char *path)
 Check if a texture is already loaded.
ITexturegetTexture (const char *path)
 Load and get a texture by path.
ITexturegetTexture (const char *filename, const std::vector< std::string > &folders)
 Load and get a texture from a set of folders.
ITexturegetTextureFromRealPath (const char *path)
 Get texture using the real file path.
ITexturegetCubeTexture (const char *pathX1, const char *pathX2, const char *pathY1, const char *pathY2, const char *pathZ1, const char *pathZ2)
 Load a cube map texture from 6 image paths.
ITexturegetTextureArray (std::vector< std::string > &listTexture)
 Load a texture array from a list of texture paths.
ITexturegetNullNormalMap ()
 Get the default null normal map texture.
ITexturegetNullTexture ()
 Get the default null texture.
ITexturecreateTransformTexture2D (const char *name, core::matrix4 *transforms, int w, int h)
 Create a 2D texture from a list of transformation matrices.
ITexturecreateVectorTexture2D (const char *name, core::vector3df *vectors, int w, int h)
 Create a 2D texture from a list of vector3df values.

Static Public Member Functions

static const char * getGlobalName ()
 Get the global package name.
static std::vector< std::string > getTextureExts ()
 Get supported texture file extensions.
static bool isTextureExt (const char *ext)
 Check if a file extension is a supported texture format.

Protected Member Functions

void registerTexture (ITexture *tex, const char *path)
 Register a texture with the manager.

Protected Attributes

std::string m_currentPackage
 Current package used for loading textures.
std::vector< STexturePackage * > m_textureList
 List of loaded texture packages.
std::vector< std::string > m_listCommonTexture
 List of common textures.
ITexturem_nullNormalMap
 Default null normal map texture.
ITexturem_nullTexture
 Default null texture.

Detailed Description

Texture Manager class provides APIs to load, retrieve, check, and release textures within the engine.

Example usage:

ITexture *texture = CTextureManager::getInstance()->getTexture("BuiltIn/Textures/Skylicht.png");
Interface of a Video Driver dependent Texture.
Definition ITexture.h:119

Member Function Documentation

◆ createTransformTexture2D()

ITexture * Skylicht::CTextureManager::createTransformTexture2D ( const char * name,
core::matrix4 * transforms,
int w,
int h )

Create a 2D texture from a list of transformation matrices.

Parameters
nameTexture name.
transformsArray of transformation matrices.
wWidth of matrix array.
hHeight of matrix array.
Returns
Pointer to created texture.

◆ createVectorTexture2D()

ITexture * Skylicht::CTextureManager::createVectorTexture2D ( const char * name,
core::vector3df * vectors,
int w,
int h )

Create a 2D texture from a list of vector3df values.

Parameters
nameTexture name.
vectorsArray of vector3df values.
wWidth of vector array.
hHeight of vector array.
Returns
Pointer to created texture.

◆ existTexture()

bool Skylicht::CTextureManager::existTexture ( const char * path)

Check if a texture exists by path.

Parameters
pathTexture file path.
Returns
True if exists, false otherwise.

◆ getCubeTexture()

ITexture * Skylicht::CTextureManager::getCubeTexture ( const char * pathX1,
const char * pathX2,
const char * pathY1,
const char * pathY2,
const char * pathZ1,
const char * pathZ2 )

Load a cube map texture from 6 image paths.

Parameters
pathX1Path for +X face.
pathX2Path for -X face.
pathY1Path for +Y face.
pathY2Path for -Y face.
pathZ1Path for +Z face.
pathZ2Path for -Z face.
Returns
Pointer to cube map texture.

◆ getCurrentPackage()

const char * Skylicht::CTextureManager::getCurrentPackage ( )
inline

Get the current texture package name.

Returns
Current package name string.

◆ getGlobalName()

const char * Skylicht::CTextureManager::getGlobalName ( )
static

Get the global package name.

Returns
Global package name as a string.

◆ getNullNormalMap()

ITexture * Skylicht::CTextureManager::getNullNormalMap ( )
inline

Get the default null normal map texture.

Returns
Pointer to null normal map.

◆ getNullTexture()

ITexture * Skylicht::CTextureManager::getNullTexture ( )
inline

Get the default null texture.

Returns
Pointer to null texture.

◆ getTexture() [1/2]

ITexture * Skylicht::CTextureManager::getTexture ( const char * filename,
const std::vector< std::string > & folders )

Load and get a texture from a set of folders.

Parameters
filenameTexture filename.
foldersList of folders to search for the texture.
Returns
Pointer to loaded texture.

◆ getTexture() [2/2]

ITexture * Skylicht::CTextureManager::getTexture ( const char * path)

Load and get a texture by path.

Parameters
pathTexture file path.
Returns
Pointer to loaded texture.

◆ getTextureArray()

ITexture * Skylicht::CTextureManager::getTextureArray ( std::vector< std::string > & listTexture)

Load a texture array from a list of texture paths.

Parameters
listTextureList of texture file paths.
Returns
Pointer to texture array resource.

◆ getTextureExts()

std::vector< std::string > Skylicht::CTextureManager::getTextureExts ( )
static

Get supported texture file extensions.

Returns
Vector of supported extensions (e.g. png, jpg, bmp...).

◆ getTextureFromRealPath()

ITexture * Skylicht::CTextureManager::getTextureFromRealPath ( const char * path)

Get texture using the real file path.

Parameters
pathReal file path.
Returns
Pointer to loaded texture.

◆ getTexturePath()

const char * Skylicht::CTextureManager::getTexturePath ( ITexture * tex)

Get the file path of a texture.

Parameters
texTexture pointer.
Returns
File path string of the texture.

◆ isTextureExt()

bool Skylicht::CTextureManager::isTextureExt ( const char * ext)
static

Check if a file extension is a supported texture format.

Parameters
extFile extension to check.
Returns
True if supported, false otherwise.

◆ isTextureLoaded()

bool Skylicht::CTextureManager::isTextureLoaded ( const char * path)

Check if a texture is already loaded.

Parameters
pathTexture path.
Returns
True if loaded, false otherwise.

◆ registerTexture()

void Skylicht::CTextureManager::registerTexture ( ITexture * tex,
const char * path )
protected

Register a texture with the manager.

Parameters
texPointer to texture.
pathFile path of the texture.

◆ removeTexture() [1/2]

void Skylicht::CTextureManager::removeTexture ( const char * namePackage)

Remove all textures in a specific package.

Parameters
namePackageName of the texture package.

◆ removeTexture() [2/2]

void Skylicht::CTextureManager::removeTexture ( ITexture * tex)

Remove a specific texture resource.

Parameters
texPointer to the texture to remove.

◆ resolveTexturePath()

bool Skylicht::CTextureManager::resolveTexturePath ( const char * path,
std::string & result )

Finds the actual, existing file path for a texture, resolving the correct file extension.

Parameters
pathLogical path to search for.
resultOutput string for the real path found.
Returns
True if found, false otherwise.

◆ setCurrentPackage()

void Skylicht::CTextureManager::setCurrentPackage ( const char * name)
inline

Set the current texture package name.

Parameters
namePackage name string.

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