Radium Engine  1.5.0
Ra::Engine::Data::TextureManager Class Referencefinal

#include <Engine/Data/TextureManager.hpp>

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

Public Member Functions

TextureParametersaddTexture (const std::string &name, uint width, uint height, void *data)
 
TexturegetOrLoadTexture (const TextureParameters &texParameters, bool linearize=false)
 
TextureloadTexture (const TextureParameters &texParameters, bool linearize=false)
 
void deleteTexture (const std::string &filename)
 
void deleteTexture (Texture *texture)
 
void updateTextureContent (const std::string &texture, void *content)
 
void updatePendingTextures ()
 
void loadTextureImage (TextureParameters &texParameters)
 

Detailed Description

Manage Texture loading and registration.

Todo:
(for Radium-V2) Allow to share the same image data between different instances of a texture. Instances could be differentiated by the sampler parameter and the mip-map availability.

Definition at line 18 of file TextureManager.hpp.

Member Function Documentation

◆ addTexture()

TextureParameters & Ra::Engine::Data::TextureManager::addTexture ( const std::string &  name,
uint  width,
uint  height,
void *  data 
)

Add a texture giving its name, dimension and content. Useful for defining procedural textures

Parameters
namename of the texture
widthwidth of the texture
heightheight of the texture
datapointer to the texture content
Returns
a texture descriptor that could be further specialized (filtering parameters ..) before the texture is inserted into Radium OpenGL system by getOrLoadTexture

Definition at line 26 of file TextureManager.cpp.

◆ deleteTexture() [1/2]

void Ra::Engine::Data::TextureManager::deleteTexture ( const std::string &  filename)

Delete a named texture from the manager

Parameters
filename

Definition at line 129 of file TextureManager.cpp.

◆ deleteTexture() [2/2]

void Ra::Engine::Data::TextureManager::deleteTexture ( Texture texture)

Delete a texture from the manager

Parameters
texture

Definition at line 138 of file TextureManager.cpp.

+ Here is the call graph for this function:

◆ getOrLoadTexture()

Texture * Ra::Engine::Data::TextureManager::getOrLoadTexture ( const TextureParameters texParameters,
bool  linearize = false 
)

Get or load a named texture. If image data are not presents in texParameters.texels (this field is nullptr), this method will assume that the texParameters.name field contains the fully qualified filename to be loaded to initialize texParameters.texels

If image data are presents in texParameters.texels (this field is not nullptr), the name could be of any form as no loading will occur.

This method creates, initialize OpenGL part of the texture and add the created texture to the Texture cache of the engine.

Note
For the moment, the texture cache is indexed by the name of the texture only.
Parameters
texParameters: The description of the texture to create
linearize: true if the texture data (texParameters.texels) must be converted from sRGB to LinearRGB
Returns
The texture as inserted into the Radium available openGL system

Definition at line 104 of file TextureManager.cpp.

◆ loadTexture()

Texture * Ra::Engine::Data::TextureManager::loadTexture ( const TextureParameters texParameters,
bool  linearize = false 
)

Helper function, load the texture without adding it to the manager.

See also
getOrLoadTexture() for parameters description.

Definition at line 86 of file TextureManager.cpp.

◆ loadTextureImage()

void Ra::Engine::Data::TextureManager::loadTextureImage ( TextureParameters texParameters)

Load a texture as described by texParameters.

Note
: only loads 2D image file for now.
Parameters
texParametersparameters describing the texture to load. This parameter will be updated (width, height, ...) according to the loaded file properties.

Definition at line 38 of file TextureManager.cpp.

◆ updatePendingTextures()

void Ra::Engine::Data::TextureManager::updatePendingTextures ( )

Update all textures that are pending after a call to updateTextureContent.

The cooperation of updateTextureContent and updatePendingTextures allow applications to manage efficiently the on line texture generation by separating the content definition (updateTextureContent) from the OpenGL state modification (updatePendingTextures).

Todo:
find a better name and description for this method that do not act on pending textures, i.e. textures that do not have a valid OpenGl state.

Definition at line 148 of file TextureManager.cpp.

◆ updateTextureContent()

void Ra::Engine::Data::TextureManager::updateTextureContent ( const std::string &  texture,
void *  content 
)

Lazy update the texture content from the raw pointer content. The real update will be done when calling updatePendingTextures

Note
User must ensure that the data pointed by content are of the good type wrt the texture.
Parameters
texture
content

Definition at line 142 of file TextureManager.cpp.


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