Privacy
An open-source, flexible 3D physical simulation framework
osg_material_manager::ShaderFactory Class Reference

This class is responsible for generating the osg::Program for shading operations. More...

#include <ShaderFactory.h>

Public Member Functions

void setShaderProvider (IShaderProvider *provider, ShaderType shader_type)
 Sets a shader provider for given shader type The function takes ownership of the provider pointer by storing it inside of an std::unique_ptr! More...
 
string generateShaderSource (ShaderType shader_type)
 Generates the complete source code for a shader program of given type TODO: Only generate if not generated before/no changes. More...
 
osg::Program * generateProgram ()
 Generates the entire osg::Program containing all shader types served by a provider. More...
 

Private Attributes

map< ShaderType, std::unique_ptr< IShaderProvider > > providers
 This map contains the current provider for each shader type. More...
 

Detailed Description

This class is responsible for generating the osg::Program for shading operations.

The IShaderProvider provide the necessary information to generate a shader for each ShaderType

Definition at line 44 of file ShaderFactory.h.

Member Function Documentation

◆ generateProgram()

osg::Program * osg_material_manager::ShaderFactory::generateProgram ( )

Generates the entire osg::Program containing all shader types served by a provider.

Returns
The ready to use osg::Program

Definition at line 87 of file ShaderFactory.cpp.

◆ generateShaderSource()

string osg_material_manager::ShaderFactory::generateShaderSource ( ShaderType  shader_type)

Generates the complete source code for a shader program of given type TODO: Only generate if not generated before/no changes.

Parameters
shader_typeThe type to generate the shader for
Returns
String containing the shader source

Definition at line 31 of file ShaderFactory.cpp.

◆ setShaderProvider()

void osg_material_manager::ShaderFactory::setShaderProvider ( IShaderProvider provider,
ShaderType  shader_type 
)

Sets a shader provider for given shader type The function takes ownership of the provider pointer by storing it inside of an std::unique_ptr!

Parameters
providerA pointer to the shader provider
shader_typeThe shader type this provider serves

Definition at line 26 of file ShaderFactory.cpp.

Member Data Documentation

◆ providers

map<ShaderType, std::unique_ptr<IShaderProvider> > osg_material_manager::ShaderFactory::providers
private

This map contains the current provider for each shader type.

Since the provider pointers are stored inside of an unique_ptr the memory management is taken care of.

Definition at line 73 of file ShaderFactory.h.


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