Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | List of all members
BIAS::ShaderProgramPool Class Reference

this class represents a set of shader programs one can add and remove shader programs to and from the pool all programs have unique names and can be accessed by the name uniform variables of the shader programs can be set by addressing a program by its name by setting a uniform variable it is checked, if a uniform variable of this type and with this name exists, if not an glfException is thrown before using a shader program call : LinkAll(); More...

#include <OpenGLFramework/Utils/ShaderProgramPool.hh>

Public Types

typedef std::pair
< glfShaderProgram
*, uniforms_map_t
program_data_t
 
typedef std::map< std::string,
program_data_t
program_map_t
 
typedef std::pair< glfShader
*, std::string > 
shader_data_t
 
typedef std::map< std::string,
shader_data_t
shader_map_t
 
typedef std::map< std::string,
std::list< std::string > > 
uniforms_map_t
 

Public Member Functions

void AddFragmentShader (const std::string &shader_source, const std::string &shader_name, const std::string &shader_program_name)
 adds a fragment shader with name shader_name and source code shader_source to the program with the name shader_program_name throws an glf exception if a shader with this name already exists More...
 
void AddFragmentShaderFromFile (const std::string &path_to_shader, const std::string &shader_name, const std::string &shader_program_name)
 adds a fragment shader with name shader_name and source code in a file (path) to the program with the name shader_program_name throws an glf exception if a shader with this name already exists More...
 
void AddShaderProgram (const std::string &shader_program_name)
 adds a shader program with name shader_program_name to the shader pool throws an glf exception if a program with this name already exists More...
 
void AddVertexShader (const std::string &shader_source, const std::string &shader_name, const std::string &shader_program_name)
 adds a vertex shader with name shader_name and source code shader_source to the program with the name shader_program_name throws an glf exception if a shader with this name already exists More...
 
void AddVertexShaderFromFile (const std::string &path_to_shader, const std::string &shader_name, const std::string &shader_program_name)
 adds a vertex shader with name shader_name and source code in a file (path) to the program with the name shader_program_name throws an glf exception if a shader with this name already exists More...
 
void BindShaderProgram (const std::string &shader_program_name)
 Binds shader program with the given name. More...
 
void ClearAll ()
 resets shader pool More...
 
void GetShaderNames (const std::string &shader_program_name, std::vector< std::string > &shader_names)
 fills the vector shader_names with names of all shaders attached to the program with the name shader_program_name More...
 
glfShaderProgramGetShaderProgram (const std::string &shader_program_name)
 returns the pointer to the shader program with the name shader_program_name if a program with this name does not exist NULL is returned More...
 
std::vector< std::pair
< std::string,
glfShaderProgram * > > 
GetShaderPrograms ()
 returns a vector with pairs (shader program name, shader program pointer) for all shader programs in the shader pool More...
 
std::string GetUniformType (const std::string &shader_program_name, const std::string &varName)
 returns the type of uniform variable with name varName if such variable exists in the shader_program otherwise an empty string is returned More...
 
bool IsLinked ()
 returns true if all programs are linked, false otherwise More...
 
void LinkAll ()
 Links all shader program after that the programs are ready to be bind and executed and uniform variables may be set. More...
 
void RemoveShaderProgram (const std::string &shader_program_name)
 removes a shader program with name shader_program_name to the shader pool More...
 
template<class StorageType >
void SetUniform (const std::string &shader_program_name, const std::string &varName, StorageType value)
 sets uniform variable varName for shader program shader_program_name glfException is thrown if no uniform variables with such type and name exist in the shader program More...
 
template<class StorageType >
void SetUniformArray (const std::string &shader_program_name, const std::string &varName, StorageType values, int arg_number)
 
 ShaderProgramPool ()
 
 ~ShaderProgramPool ()
 

Detailed Description

this class represents a set of shader programs one can add and remove shader programs to and from the pool all programs have unique names and can be accessed by the name uniform variables of the shader programs can be set by addressing a program by its name by setting a uniform variable it is checked, if a uniform variable of this type and with this name exists, if not an glfException is thrown before using a shader program call : LinkAll();

Author
frick

Definition at line 56 of file ShaderProgramPool.hh.

Member Typedef Documentation

Definition at line 67 of file ShaderProgramPool.hh.

Definition at line 69 of file ShaderProgramPool.hh.

typedef std::pair<glfShader*, std::string> BIAS::ShaderProgramPool::shader_data_t

Definition at line 63 of file ShaderProgramPool.hh.

typedef std::map<std::string, shader_data_t> BIAS::ShaderProgramPool::shader_map_t

Definition at line 65 of file ShaderProgramPool.hh.

typedef std::map<std::string, std::list<std::string> > BIAS::ShaderProgramPool::uniforms_map_t

Definition at line 61 of file ShaderProgramPool.hh.

Constructor & Destructor Documentation

ShaderProgramPool::ShaderProgramPool ( )

Definition at line 17 of file ShaderProgramPool.cpp.

ShaderProgramPool::~ShaderProgramPool ( )

Definition at line 23 of file ShaderProgramPool.cpp.

Member Function Documentation

void ShaderProgramPool::AddFragmentShader ( const std::string &  shader_source,
const std::string &  shader_name,
const std::string &  shader_program_name 
)

adds a fragment shader with name shader_name and source code shader_source to the program with the name shader_program_name throws an glf exception if a shader with this name already exists

adds a fragment shader with shader_name and shader_source to the program with shader_program_name the program with the given name must exist

Author
frick

Definition at line 92 of file ShaderProgramPool.cpp.

void ShaderProgramPool::AddFragmentShaderFromFile ( const std::string &  path_to_shader,
const std::string &  shader_name,
const std::string &  shader_program_name 
)

adds a fragment shader with name shader_name and source code in a file (path) to the program with the name shader_program_name throws an glf exception if a shader with this name already exists

Author
frick

Definition at line 113 of file ShaderProgramPool.cpp.

void ShaderProgramPool::AddShaderProgram ( const std::string &  shader_program_name)

adds a shader program with name shader_program_name to the shader pool throws an glf exception if a program with this name already exists

adds an empty shader program identified through the shader_program_name to the pool

Author
frick

Definition at line 65 of file ShaderProgramPool.cpp.

References BIAS::glfShaderProgram::Create().

void ShaderProgramPool::AddVertexShader ( const std::string &  shader_source,
const std::string &  shader_name,
const std::string &  shader_program_name 
)

adds a vertex shader with name shader_name and source code shader_source to the program with the name shader_program_name throws an glf exception if a shader with this name already exists

adds a vertex shader with shader_name and shader_source to the program with shader_program_name the program with the given name must exist

Author
frick

Definition at line 105 of file ShaderProgramPool.cpp.

void ShaderProgramPool::AddVertexShaderFromFile ( const std::string &  path_to_shader,
const std::string &  shader_name,
const std::string &  shader_program_name 
)

adds a vertex shader with name shader_name and source code in a file (path) to the program with the name shader_program_name throws an glf exception if a shader with this name already exists

Author
frick

Definition at line 122 of file ShaderProgramPool.cpp.

void ShaderProgramPool::BindShaderProgram ( const std::string &  shader_program_name)

Binds shader program with the given name.

Author
frick

Definition at line 179 of file ShaderProgramPool.cpp.

References BIAS::glfShaderProgram::Bind().

void ShaderProgramPool::ClearAll ( )

resets shader pool

Definition at line 29 of file ShaderProgramPool.cpp.

void ShaderProgramPool::GetShaderNames ( const std::string &  shader_program_name,
std::vector< std::string > &  shader_names 
)

fills the vector shader_names with names of all shaders attached to the program with the name shader_program_name

Definition at line 216 of file ShaderProgramPool.cpp.

glfShaderProgram * ShaderProgramPool::GetShaderProgram ( const std::string &  shader_program_name)

returns the pointer to the shader program with the name shader_program_name if a program with this name does not exist NULL is returned

returns the program pointer or null if the program with shader_program_name does not exist

Author
frick

Definition at line 165 of file ShaderProgramPool.cpp.

Referenced by BIAS::SimpleMultiPassFragmentShader::Execute().

std::vector<std::pair<std::string, glfShaderProgram*> > BIAS::ShaderProgramPool::GetShaderPrograms ( )

returns a vector with pairs (shader program name, shader program pointer) for all shader programs in the shader pool

Author
frick
string ShaderProgramPool::GetUniformType ( const std::string &  shader_program_name,
const std::string &  varName 
)

returns the type of uniform variable with name varName if such variable exists in the shader_program otherwise an empty string is returned

Definition at line 231 of file ShaderProgramPool.cpp.

bool ShaderProgramPool::IsLinked ( )

returns true if all programs are linked, false otherwise

Author
frick

Definition at line 189 of file ShaderProgramPool.cpp.

void ShaderProgramPool::LinkAll ( )

Links all shader program after that the programs are ready to be bind and executed and uniform variables may be set.

Author
frick

Definition at line 195 of file ShaderProgramPool.cpp.

void ShaderProgramPool::RemoveShaderProgram ( const std::string &  shader_program_name)

removes a shader program with name shader_program_name to the shader pool

removes the shader program from program pool; deletes all attached shaders

Author
frick

Definition at line 134 of file ShaderProgramPool.cpp.

template<class StorageType >
template void BIASOpenGLFramework_EXPORT ShaderProgramPool::SetUniform< Vector< float > > ( const std::string &  shader_program_name,
const std::string &  varName,
StorageType  value 
)

sets uniform variable varName for shader program shader_program_name glfException is thrown if no uniform variables with such type and name exist in the shader program

Definition at line 322 of file ShaderProgramPool.cpp.

References BIAS::glfShaderProgram::SetUniform().

template<class StorageType >
template void BIASOpenGLFramework_EXPORT ShaderProgramPool::SetUniformArray< int * > ( const std::string &  shader_program_name,
const std::string &  varName,
StorageType  values,
int  arg_number 
)

Definition at line 261 of file ShaderProgramPool.cpp.

References BIAS::glfShaderProgram::SetUniform().


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