Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Data::TextureManager Class Referencefinal

Manage Texture loading and registration. More...

#include <Engine/Data/TextureManager.hpp>

+ Collaboration diagram for Ra::Engine::Data::TextureManager:

Public Types

using TextureHandle = Ra::Core::Utils::Index
 

Public Member Functions

TextureHandle addTexture (const TextureParameters &p)
 Add a texture given its TextureParameters.
 
TexturegetTexture (const TextureHandle &handle)
 Get raw texture ptr from handle.
 
TextureHandle getTextureHandle (const std::string &name)
 Get a texture handle from textue name.
 
TexturegetTexture (const std::string &name)
 Convinience function to obtain Texture ptr from name.
 
void deleteTexture (const TextureHandle &handle)
 Remove a managed texture identified by handle.
 
 TextureManager (TextureManager const &)=delete
 
 TextureManager (TextureManager &&)=delete
 
TextureManageroperator= (TextureManager const &)=delete
 
TextureManageroperator= (TextureManager &&)=delete
 

Static Public Member Functions

static ImageParameters loadTextureImage (const std::string &filename, bool linearize=false)
 Load filename and fill ImageParameters according to filename content.
 

Detailed Description

Manage Texture loading and registration.

TextureManager allows to store texture globally such that different object can share textures based on their handle or name. Name uniqueness is not guaranteed by the manager, take care in case of search texture by name.

Definition at line 19 of file TextureManager.hpp.

Member Typedef Documentation

◆ TextureHandle

using Ra::Engine::Data::TextureManager::TextureHandle = Ra::Core::Utils::Index

Definition at line 24 of file TextureManager.hpp.

Member Function Documentation

◆ addTexture()

TextureManager::TextureHandle Ra::Engine::Data::TextureManager::addTexture ( const TextureParameters & p)

Add a texture given its TextureParameters.

Returns
a TextureHandle that uniquely identify the texture in the manager.

Definition at line 21 of file TextureManager.cpp.

+ Here is the call graph for this function:

◆ deleteTexture()

void Ra::Engine::Data::TextureManager::deleteTexture ( const TextureHandle & handle)

Remove a managed texture identified by handle.

Texture dtor will register the delete texture gpu task.

Definition at line 104 of file TextureManager.cpp.

◆ getTexture() [1/2]

Texture * Ra::Engine::Data::TextureManager::getTexture ( const std::string & name)
inline

Convinience function to obtain Texture ptr from name.

Definition at line 46 of file TextureManager.hpp.

◆ getTexture() [2/2]

Texture * Ra::Engine::Data::TextureManager::getTexture ( const TextureHandle & handle)

Get raw texture ptr from handle.

The texture is still managed by the manager. Do not delete the return ptr.

Definition at line 91 of file TextureManager.cpp.

◆ getTextureHandle()

TextureManager::TextureHandle Ra::Engine::Data::TextureManager::getTextureHandle ( const std::string & name)

Get a texture handle from textue name.

It search for the first texture in the set of managed texture that have this name.

Returns
An handle to the texture or InvalidIndex if no texture with this name is found

Definition at line 95 of file TextureManager.cpp.

+ Here is the call graph for this function:

◆ loadTextureImage()

ImageParameters Ra::Engine::Data::TextureManager::loadTextureImage ( const std::string & filename,
bool linearize = false )
static

Load filename and fill ImageParameters according to filename content.

Note
only loads 2D image file for now.
Parameters
filenamefully qualified image filename. See stbi_load_image for supported file format.
Returns
ImageParameters corresponding to filename content, image.parameters.texels contains actual image data. In case of loading error, texels is nullptr, width = height = 0.

Definition at line 41 of file TextureManager.cpp.

+ Here is the call graph for this function:

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