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

#include <Engine/Data/ShaderProgramManager.hpp>

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

Public Member Functions

 ShaderProgramManager ()
 Rule of three needed here to prevent copy on this manager (only movable)
 
 ShaderProgramManager (const ShaderProgramManager &)=delete
 
ShaderProgramManageroperator= (const ShaderProgramManager &)=delete
 
Core::Utils::optional< const Data::ShaderProgram * > addShaderProgram (const Data::ShaderConfiguration &config)
 
const Data::ShaderProgramgetShaderProgram (const std::string &id)
 
const Data::ShaderProgramgetShaderProgram (const Data::ShaderConfiguration &config)
 
void reloadAllShaderPrograms ()
 
void reloadNotCompiledShaderPrograms ()
 
bool addNamedString (const std::string &includepath, const std::string &realfile)
 
void reloadNamedString ()
 

Detailed Description

Manage the set of shaders used by Radium Engine for rendering.

This class allows to manage shader programs according to their configuration so that, for a given configuration, there is only one ShaderProgram instance in the system.

This manager is a singleton. At the creation of the singleton, one can give parameters that will define the default shader program example : Engine::ShaderProgramManager::createInstance( "Shaders/Default.vert.glsl", "Shaders/Default.frag.glsl" );

Definition at line 36 of file ShaderProgramManager.hpp.

Constructor & Destructor Documentation

◆ ShaderProgramManager()

Ra::Engine::Data::ShaderProgramManager::ShaderProgramManager ( )

Rule of three needed here to prevent copy on this manager (only movable)

Definition at line 19 of file ShaderProgramManager.cpp.

◆ ~ShaderProgramManager()

Ra::Engine::Data::ShaderProgramManager::~ShaderProgramManager ( )

Definition at line 21 of file ShaderProgramManager.cpp.

Member Function Documentation

◆ addNamedString()

bool Ra::Engine::Data::ShaderProgramManager::addNamedString ( const std::string & includepath,
const std::string & realfile )

Allows to define named string so that the inclusion mechanism of OpenGL could be efficient. A name string associates the name that will be used by a #define directive in a glsl source file with a file that contains the included glsl source code.

Parameters
includepath
realfile
Returns
false if the string already exists. Print an error message

Definition at line 25 of file ShaderProgramManager.cpp.

+ Here is the call graph for this function:

◆ addShaderProgram()

Core::Utils::optional< const Data::ShaderProgram * > Ra::Engine::Data::ShaderProgramManager::addShaderProgram ( const Data::ShaderConfiguration & config)

Add a shader program to the program collection according to the given configuration. This method must be called only once an opeGL context is bound. The shader sources corresponding to the configuration will be compiled, linked and verified.

Parameters
configthe configuration of the program to add to the collection
Returns
the created shader program. In case of compile/link/verify error, return false
Note
ownership on the returned pointer is keep by the manager.
Warning
this method is not reentrant

Definition at line 58 of file ShaderProgramManager.cpp.

+ Here is the call graph for this function:

◆ getShaderProgram() [1/2]

const Data::ShaderProgram * Ra::Engine::Data::ShaderProgramManager::getShaderProgram ( const Data::ShaderConfiguration & config)

Get the shader program corresponding to the given configuration

Parameters
configName of the program to retrieve
Returns
the shader program retrieved, or nullptr when no shader program corresponding to the configuration is found.

Definition at line 105 of file ShaderProgramManager.cpp.

+ Here is the call graph for this function:

◆ getShaderProgram() [2/2]

const Data::ShaderProgram * Ra::Engine::Data::ShaderProgramManager::getShaderProgram ( const std::string & id)

Get the shader program corresponding to the given id

Parameters
idName of the program to retrieve
Returns
the shader program retrieved, nullptr if the program was not in the collection

Definition at line 97 of file ShaderProgramManager.cpp.

+ Here is the call graph for this function:

◆ reloadAllShaderPrograms()

void Ra::Engine::Data::ShaderProgramManager::reloadAllShaderPrograms ( )

Reload source, recompile, link and validate all the managed programms. Usefull for shaders development

Definition at line 110 of file ShaderProgramManager.cpp.

+ Here is the call graph for this function:

◆ reloadNamedString()

void Ra::Engine::Data::ShaderProgramManager::reloadNamedString ( )

Reload all the registered name string. Usefull for shader development.

Definition at line 49 of file ShaderProgramManager.cpp.

◆ reloadNotCompiledShaderPrograms()

void Ra::Engine::Data::ShaderProgramManager::reloadNotCompiledShaderPrograms ( )

Programs that did not compiled are temporarilly stored and could be reloaded and compiled when one call this method. If the reloaded program is ok, it is removed from the set of not compiled program and added to the program collection.

Definition at line 123 of file ShaderProgramManager.cpp.

+ Here is the call graph for this function:

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