HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Shader Class Reference

#include <Shader.h>

Public Member Functions

 Shader (const string &name, ShaderGraphPtr graph)
 Constructor. More...
 
virtual ~Shader ()
 Destructor. More...
 
const stringgetName () const
 Return the shader name. More...
 
size_t numStages () const
 Return the number of shader stages for this shader. More...
 
ShaderStagegetStage (size_t index)
 Return a stage by index. More...
 
const ShaderStagegetStage (size_t index) const
 Return a stage by index. More...
 
bool hasStage (const string &name)
 Return if stage exists. More...
 
ShaderStagegetStage (const string &name)
 Return a stage by name. More...
 
const ShaderStagegetStage (const string &name) const
 Return a stage by name. More...
 
bool hasAttribute (const string &attrib) const
 Return true if the shader has a given named attribute. More...
 
ValuePtr getAttribute (const string &attrib) const
 
void setAttribute (const string &attrib, ValuePtr value)
 Set a value attribute on the shader. More...
 
void setAttribute (const string &attrib)
 Set a flag attribute on the shader. More...
 
const ShaderGraphgetGraph () const
 Return the shader graph. More...
 
ShaderGraphgetGraph ()
 Return the shader graph. More...
 
bool hasClassification (unsigned int c) const
 Return true if this shader matches the given classification. More...
 
void setSourceCode (const string &code, const string &stage=Stage::PIXEL)
 Set the shader source code for a given shader stage. More...
 
const stringgetSourceCode (const string &stage=Stage::PIXEL) const
 Return the shader source code for a given shader stage. More...
 

Protected Member Functions

ShaderStagePtr createStage (const string &name, ConstSyntaxPtr syntax)
 Create a new stage in the shader. More...
 

Protected Attributes

string _name
 
ShaderGraphPtr _graph
 
std::unordered_map< string,
ShaderStagePtr
_stagesMap
 
vector< ShaderStage * > _stages
 
std::unordered_map< string,
ValuePtr
_attributeMap
 

Friends

class ShaderGenerator
 

Detailed Description

Class containing all data needed during shader generation. After generation is completed it will contain the resulting source code emitted by shader generators.

The class contains a default implementation using a single shader stage. Derived shaders can override this, as well as overriding all methods that add code to the shader.

Definition at line 32 of file Shader.h.

Constructor & Destructor Documentation

Shader::Shader ( const string name,
ShaderGraphPtr  graph 
)

Constructor.

virtual Shader::~Shader ( )
inlinevirtual

Destructor.

Definition at line 39 of file Shader.h.

Member Function Documentation

ShaderStagePtr Shader::createStage ( const string name,
ConstSyntaxPtr  syntax 
)
protected

Create a new stage in the shader.

ValuePtr Shader::getAttribute ( const string attrib) const
inline

Return the value for a named attribute, or nullptr if no such attribute is found.

Definition at line 70 of file Shader.h.

const ShaderGraph& Shader::getGraph ( ) const
inline

Return the shader graph.

Definition at line 89 of file Shader.h.

ShaderGraph& Shader::getGraph ( )
inline

Return the shader graph.

Definition at line 92 of file Shader.h.

const string& Shader::getName ( ) const
inline

Return the shader name.

Definition at line 42 of file Shader.h.

const string& Shader::getSourceCode ( const string stage = Stage::PIXEL) const
inline

Return the shader source code for a given shader stage.

Definition at line 101 of file Shader.h.

ShaderStage& Shader::getStage ( size_t  index)

Return a stage by index.

const ShaderStage& Shader::getStage ( size_t  index) const

Return a stage by index.

ShaderStage& Shader::getStage ( const string name)

Return a stage by name.

const ShaderStage& Shader::getStage ( const string name) const

Return a stage by name.

bool Shader::hasAttribute ( const string attrib) const
inline

Return true if the shader has a given named attribute.

Definition at line 63 of file Shader.h.

bool Shader::hasClassification ( unsigned int  c) const
inline

Return true if this shader matches the given classification.

Definition at line 95 of file Shader.h.

bool Shader::hasStage ( const string name)

Return if stage exists.

size_t Shader::numStages ( ) const
inline

Return the number of shader stages for this shader.

Definition at line 45 of file Shader.h.

void Shader::setAttribute ( const string attrib,
ValuePtr  value 
)
inline

Set a value attribute on the shader.

Definition at line 77 of file Shader.h.

void Shader::setAttribute ( const string attrib)
inline

Set a flag attribute on the shader.

Definition at line 83 of file Shader.h.

void Shader::setSourceCode ( const string code,
const string stage = Stage::PIXEL 
)
inline

Set the shader source code for a given shader stage.

Definition at line 98 of file Shader.h.

Friends And Related Function Documentation

friend class ShaderGenerator
friend

Definition at line 113 of file Shader.h.

Member Data Documentation

std::unordered_map<string, ValuePtr> Shader::_attributeMap
protected

Definition at line 111 of file Shader.h.

ShaderGraphPtr Shader::_graph
protected

Definition at line 108 of file Shader.h.

string Shader::_name
protected

Definition at line 107 of file Shader.h.

vector<ShaderStage*> Shader::_stages
protected

Definition at line 110 of file Shader.h.

std::unordered_map<string, ShaderStagePtr> Shader::_stagesMap
protected

Definition at line 109 of file Shader.h.


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