Sly Engine
ShaderManager Class Reference

#include <ShaderManager.h>

Collaboration diagram for ShaderManager:
Collaboration graph

Static Public Member Functions

static ShaderObject * Get (std::string key)
 Gets a shader object* using the given key. More...
 
static void Load (std::string key, const char *path)
 Loads the specified shader. More...
 
static void LoadSpriteShader (std::string key)
 Loads sprite shader with the unique specified key. More...
 

Private Types

typedef std::string MapKey
 Defines an alias representing the map key. More...
 
typedef std::map< MapKey, ShaderObject * > StorageMap
 Defines an alias representing the storage map. More...
 

Private Member Functions

 ShaderManager ()
 Default constructor. More...
 
 ShaderManager (const ShaderManager &)=delete
 Copy constructor
More...
 
 ShaderManager (ShaderManager &&)=delete
 Move constructor. More...
 
ShaderManageroperator= (const ShaderManager &)=delete
 Assignment operator. More...
 
ShaderManageroperator= (ShaderManager &&)=delete
 Move assignment operator. More...
 
 ~ShaderManager ()=default
 Deconstructor
More...
 
ShaderObject * privGet (std::string key)
 Private get. More...
 
void privLoad (std::string key, const char *path)
 Private load. More...
 
void privLoadSpriteShader (std::string key)
 Private load sprite shader. More...
 
void privDelete ()
 Deletes pointer instance. To be called internally only. More...
 

Static Private Member Functions

static ShaderManagerInstance ()
 Gets the instance. More...
 
static void Delete ()
 Deletes pointer instance. To be called within Engine code only. More...
 

Private Attributes

std::string defaultPath
 The default path that Shaders are stored. More...
 
std::map< std::string, ShaderObject * > shaderMap
 A map containing shaders specified by a string key. More...
 

Static Private Attributes

static ShaderManagerptrInstance = nullptr
 Pointer to the ShaderManager instance. More...
 

Friends

class ShaderManagerAttorney
 Dictates access to ShaderManager's private functions for engine usage. More...
 

Member Typedef Documentation

◆ MapKey

std::string ShaderManager::MapKey
private

Defines an alias representing the map key.

◆ StorageMap

std::map< MapKey, ShaderObject * > ShaderManager::StorageMap
private

Defines an alias representing the storage map.

Constructor & Destructor Documentation

◆ ShaderManager() [1/3]

ShaderManager::ShaderManager ( )
private

Default constructor.

Here is the caller graph for this function:

◆ ShaderManager() [2/3]

ShaderManager::ShaderManager ( const ShaderManager )
privatedelete

Copy constructor

◆ ShaderManager() [3/3]

ShaderManager::ShaderManager ( ShaderManager &&  )
privatedelete

Move constructor.

◆ ~ShaderManager()

ShaderManager::~ShaderManager ( )
privatedefault

Deconstructor

Member Function Documentation

◆ Delete()

static void ShaderManager::Delete ( )
inlinestaticprivate

Deletes pointer instance. To be called within Engine code only.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get()

static ShaderObject * ShaderManager::Get ( std::string  key)
inlinestatic

Gets a shader object* using the given key.

Parameters
keyThe key to get.
Returns
Assertion if it fails, else a pointer to a ShaderObject.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Instance()

static ShaderManager & ShaderManager::Instance ( )
inlinestaticprivate

Gets the instance.

Returns
A reference to ShaderManager.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Load()

static void ShaderManager::Load ( std::string  key,
const char *  path 
)
inlinestatic

Loads the specified shader.

Parameters
keyThe key.
pathPartial pathname of the file.
Here is the call graph for this function:

◆ LoadSpriteShader()

static void ShaderManager::LoadSpriteShader ( std::string  key)
inlinestatic

Loads sprite shader with the unique specified key.

Parameters
keyThe unique key.

This loading of this sprite shader ensures that no two sprites can load the same shader under the same name. As an example:

// This code is NOT valid:
mySprite = new SlySprite("Gordon-Freeman");
myOtherSprite = new SlySprite("Gordon-Freeman");
// This code IS valid:
mySprite = new SlySprite("Gordon-Freeman");
myOtherSprite = new SlySprite("The-Free-Man");
Here is the call graph for this function:

◆ operator=() [1/2]

ShaderManager& ShaderManager::operator= ( const ShaderManager )
privatedelete

Assignment operator.

◆ operator=() [2/2]

ShaderManager& ShaderManager::operator= ( ShaderManager &&  )
privatedelete

Move assignment operator.

◆ privDelete()

void ShaderManager::privDelete ( )
private

Deletes pointer instance. To be called internally only.

Here is the caller graph for this function:

◆ privGet()

ShaderObject * ShaderManager::privGet ( std::string  key)
private

Private get.

Parameters
keyThe key.
Returns
Assertion if it fails, else a pointer to a ShaderObject.
Here is the caller graph for this function:

◆ privLoad()

void ShaderManager::privLoad ( std::string  key,
const char *  path 
)
private

Private load.

Parameters
keyThe key.
pathPartial pathname of the file.
Here is the caller graph for this function:

◆ privLoadSpriteShader()

void ShaderManager::privLoadSpriteShader ( std::string  key)
private

Private load sprite shader.

Parameters
keyThe unique key.

Internal process for loading the sprite shader. Checks the existing map if the key is unique. If it is, the default SpriteShader is loaded and added to the map. Assertion fail otherwise.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ShaderManagerAttorney

friend class ShaderManagerAttorney
friend

Dictates access to ShaderManager's private functions for engine usage.

Member Data Documentation

◆ defaultPath

std::string ShaderManager::defaultPath
private

The default path that Shaders are stored.

◆ ptrInstance

ShaderManager * ShaderManager::ptrInstance = nullptr
staticprivate

Pointer to the ShaderManager instance.

◆ shaderMap

std::map<std::string, ShaderObject*> ShaderManager::shaderMap
private

A map containing shaders specified by a string key.


The documentation for this class was generated from the following files:
SlySprite
Definition: SlySprite.h:11