xoreos  0.0.5
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Graphics::Shader::ShaderMaterial Class Reference

#include <shadermaterial.h>

Collaboration diagram for Graphics::Shader::ShaderMaterial:
Collaboration graph
[legend]

Classes

struct  ShaderMaterialVariable
 

Public Types

enum  {
  MATERIAL_OPAQUE = 0x0001, MATERIAL_TRANSPARENT = 0x0002, MATERIAL_TRANSPARENT_B = 0x0004, MATERIAL_DECAL = 0x0008,
  MATERIAL_SPECIAL_BLEND = 0x0010
}
 

Public Member Functions

 ShaderMaterial (Shader::ShaderObject *fragShader, const Common::UString &name="unnamed")
 
 ~ShaderMaterial ()
 
const Common::UStringgetName () const
 
uint32 getFlags () const
 
void setFlags (uint32 flags)
 
Shader::ShaderObjectgetFragmentShader () const
 
uint32 getVariableCount () const
 
Shader::ShaderVariableType getVariableType (uint32 index) const
 
void * getVariableData (uint32 index) const
 
void * getVariableData (const Common::UString &name) const
 
const Common::UStringgetVariableName (uint32 index) const
 
uint32 getVariableFlags (uint32 index) const
 
void setVariableExternal (uint32 index, void *loc, bool textureUnitRecalc=true)
 
void setVariableExternal (const Common::UString &name, void *loc, bool textureUnitRecalc=true)
 
void setVariableInternal (uint32 index, bool textureUnitRecalc=true)
 
void setVariableInternal (const Common::UString &name, bool textureUnitRecalc=true)
 
void recalcTextureUnits ()
 
bool isVariableOwned (uint32 index) const
 
bool isVariableOwned (const Common::UString &name) const
 
void bindProgram (Shader::ShaderProgram *program)
 
void bindProgramNoFade (Shader::ShaderProgram *program)
 
void bindProgram (Shader::ShaderProgram *program, float fade)
 
void bindFade (Shader::ShaderProgram *program, float fade)
 
void bindGLState ()
 
void unbindGLState ()
 
void restoreGLState ()
 
void useIncrement ()
 
void useDecrement ()
 
uint32 useCount () const
 

Private Member Functions

void * genMaterialVar (uint32 index)
 
void delMaterialVar (uint32 index)
 

Private Attributes

std::vector< ShaderMaterialVariable_variableData
 
Shader::ShaderObject_fragShader
 
uint32 _flags
 
Common::UString _name
 
uint32 _usageCount
 
uint32 _alphaIndex
 

Detailed Description

Definition at line 34 of file shadermaterial.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MATERIAL_OPAQUE 

Render hint; material has no transparency.

MATERIAL_TRANSPARENT 

Material definitely has transparency.

MATERIAL_TRANSPARENT_B 

Material definitely has transparency.

MATERIAL_DECAL 

Material is a decal.

MATERIAL_SPECIAL_BLEND 

Different to default blending. Maybe this should be extended one day.

Definition at line 36 of file shadermaterial.h.

Constructor & Destructor Documentation

◆ ShaderMaterial()

Graphics::Shader::ShaderMaterial::ShaderMaterial ( Shader::ShaderObject fragShader,
const Common::UString name = "unnamed" 
)

◆ ~ShaderMaterial()

Graphics::Shader::ShaderMaterial::~ShaderMaterial ( )

Definition at line 49 of file shadermaterial.cpp.

References _variableData, and delMaterialVar().

Here is the call graph for this function:

Member Function Documentation

◆ bindFade()

void Graphics::Shader::ShaderMaterial::bindFade ( Shader::ShaderProgram program,
float  fade 
)

◆ bindGLState()

void Graphics::Shader::ShaderMaterial::bindGLState ( )

◆ bindProgram() [1/2]

void Graphics::Shader::ShaderMaterial::bindProgram ( Shader::ShaderProgram program)

◆ bindProgram() [2/2]

void Graphics::Shader::ShaderMaterial::bindProgram ( Shader::ShaderProgram program,
float  fade 
)

◆ bindProgramNoFade()

void Graphics::Shader::ShaderMaterial::bindProgramNoFade ( Shader::ShaderProgram program)

◆ delMaterialVar()

void Graphics::Shader::ShaderMaterial::delMaterialVar ( uint32  index)
private

Definition at line 315 of file shadermaterial.cpp.

References _fragShader, _variableData, Graphics::Shader::SHADER_FLOAT, Graphics::Shader::SHADER_INT, Graphics::Shader::SHADER_ISAMPLER1D, Graphics::Shader::SHADER_ISAMPLER1DARRAY, Graphics::Shader::SHADER_ISAMPLER2D, Graphics::Shader::SHADER_ISAMPLER2DARRAY, Graphics::Shader::SHADER_ISAMPLER3D, Graphics::Shader::SHADER_ISAMPLERCUBE, Graphics::Shader::SHADER_IVEC2, Graphics::Shader::SHADER_IVEC3, Graphics::Shader::SHADER_IVEC4, Graphics::Shader::SHADER_MAT2, Graphics::Shader::SHADER_MAT3, Graphics::Shader::SHADER_MAT4, SHADER_MATERIAL_VARIABLE_OWNED, Graphics::Shader::SHADER_SAMPLER1D, Graphics::Shader::SHADER_SAMPLER1DARRAY, Graphics::Shader::SHADER_SAMPLER1DARRAYSHADOW, Graphics::Shader::SHADER_SAMPLER1DSHADOW, Graphics::Shader::SHADER_SAMPLER2D, Graphics::Shader::SHADER_SAMPLER2DARRAY, Graphics::Shader::SHADER_SAMPLER2DARRAYSHADOW, Graphics::Shader::SHADER_SAMPLER2DSHADOW, Graphics::Shader::SHADER_SAMPLER3D, Graphics::Shader::SHADER_SAMPLERBUFFER, Graphics::Shader::SHADER_SAMPLERCUBE, Graphics::Shader::SHADER_UNIFORM_BUFFER, Graphics::Shader::SHADER_USAMPLER1D, Graphics::Shader::SHADER_USAMPLER1DARRAY, Graphics::Shader::SHADER_USAMPLER2D, Graphics::Shader::SHADER_USAMPLER2DARRAY, Graphics::Shader::SHADER_USAMPLER3D, Graphics::Shader::SHADER_USAMPLERCUBE, Graphics::Shader::SHADER_VEC2, Graphics::Shader::SHADER_VEC3, Graphics::Shader::SHADER_VEC4, and Graphics::Shader::ShaderObject::variablesCombined.

Referenced by setVariableExternal(), and ~ShaderMaterial().

Here is the caller graph for this function:

◆ genMaterialVar()

void * Graphics::Shader::ShaderMaterial::genMaterialVar ( uint32  index)
private

Definition at line 255 of file shadermaterial.cpp.

References _fragShader, _variableData, Graphics::Shader::SHADER_FLOAT, Graphics::Shader::SHADER_INT, Graphics::Shader::SHADER_ISAMPLER1D, Graphics::Shader::SHADER_ISAMPLER1DARRAY, Graphics::Shader::SHADER_ISAMPLER2D, Graphics::Shader::SHADER_ISAMPLER2DARRAY, Graphics::Shader::SHADER_ISAMPLER3D, Graphics::Shader::SHADER_ISAMPLERCUBE, Graphics::Shader::SHADER_IVEC2, Graphics::Shader::SHADER_IVEC3, Graphics::Shader::SHADER_IVEC4, Graphics::Shader::SHADER_MAT2, Graphics::Shader::SHADER_MAT3, Graphics::Shader::SHADER_MAT4, SHADER_MATERIAL_VARIABLE_OWNED, Graphics::Shader::SHADER_SAMPLER1D, Graphics::Shader::SHADER_SAMPLER1DARRAY, Graphics::Shader::SHADER_SAMPLER1DARRAYSHADOW, Graphics::Shader::SHADER_SAMPLER1DSHADOW, Graphics::Shader::SHADER_SAMPLER2D, Graphics::Shader::SHADER_SAMPLER2DARRAY, Graphics::Shader::SHADER_SAMPLER2DARRAYSHADOW, Graphics::Shader::SHADER_SAMPLER2DSHADOW, Graphics::Shader::SHADER_SAMPLER3D, Graphics::Shader::SHADER_SAMPLERBUFFER, Graphics::Shader::SHADER_SAMPLERCUBE, Graphics::Shader::SHADER_UNIFORM_BUFFER, Graphics::Shader::SHADER_USAMPLER1D, Graphics::Shader::SHADER_USAMPLER1DARRAY, Graphics::Shader::SHADER_USAMPLER2D, Graphics::Shader::SHADER_USAMPLER2DARRAY, Graphics::Shader::SHADER_USAMPLER3D, Graphics::Shader::SHADER_USAMPLERCUBE, Graphics::Shader::SHADER_VEC2, Graphics::Shader::SHADER_VEC3, Graphics::Shader::SHADER_VEC4, and Graphics::Shader::ShaderObject::variablesCombined.

Referenced by setVariableInternal(), and ShaderMaterial().

Here is the caller graph for this function:

◆ getFlags()

uint32 Graphics::Shader::ShaderMaterial::getFlags ( ) const

Definition at line 59 of file shadermaterial.cpp.

References _flags.

Referenced by Graphics::Render::RenderManager::queueRenderable().

Here is the caller graph for this function:

◆ getFragmentShader()

Shader::ShaderObject * Graphics::Shader::ShaderMaterial::getFragmentShader ( ) const

Definition at line 67 of file shadermaterial.cpp.

References _fragShader.

Referenced by Graphics::Shader::ShaderRenderable::updateProgram().

Here is the caller graph for this function:

◆ getName()

const Common::UString & Graphics::Shader::ShaderMaterial::getName ( ) const

Definition at line 55 of file shadermaterial.cpp.

References _name.

Referenced by Graphics::Shader::MaterialManager::addMaterial(), Graphics::Shader::MaterialManager::delMaterial(), and Graphics::Shader::MaterialManager::init().

Here is the caller graph for this function:

◆ getVariableCount()

uint32 Graphics::Shader::ShaderMaterial::getVariableCount ( ) const

◆ getVariableData() [1/2]

void * Graphics::Shader::ShaderMaterial::getVariableData ( uint32  index) const

◆ getVariableData() [2/2]

void * Graphics::Shader::ShaderMaterial::getVariableData ( const Common::UString name) const

◆ getVariableFlags()

uint32 Graphics::Shader::ShaderMaterial::getVariableFlags ( uint32  index) const

Definition at line 101 of file shadermaterial.cpp.

References _variableData.

◆ getVariableName()

const Common::UString & Graphics::Shader::ShaderMaterial::getVariableName ( uint32  index) const

◆ getVariableType()

Shader::ShaderVariableType Graphics::Shader::ShaderMaterial::getVariableType ( uint32  index) const

◆ isVariableOwned() [1/2]

bool Graphics::Shader::ShaderMaterial::isVariableOwned ( uint32  index) const

Definition at line 190 of file shadermaterial.cpp.

References _variableData, and SHADER_MATERIAL_VARIABLE_OWNED.

◆ isVariableOwned() [2/2]

bool Graphics::Shader::ShaderMaterial::isVariableOwned ( const Common::UString name) const

◆ recalcTextureUnits()

void Graphics::Shader::ShaderMaterial::recalcTextureUnits ( )

◆ restoreGLState()

void Graphics::Shader::ShaderMaterial::restoreGLState ( )

Definition at line 248 of file shadermaterial.cpp.

◆ setFlags()

void Graphics::Shader::ShaderMaterial::setFlags ( uint32  flags)

Definition at line 63 of file shadermaterial.cpp.

References _flags.

Referenced by Graphics::Aurora::ModelNode_Witcher::buildMaterial(), and Graphics::Aurora::ModelNode::buildMaterial().

Here is the caller graph for this function:

◆ setVariableExternal() [1/2]

void Graphics::Shader::ShaderMaterial::setVariableExternal ( uint32  index,
void *  loc,
bool  textureUnitRecalc = true 
)

Definition at line 105 of file shadermaterial.cpp.

References _variableData, delMaterialVar(), and recalcTextureUnits().

Here is the call graph for this function:

◆ setVariableExternal() [2/2]

void Graphics::Shader::ShaderMaterial::setVariableExternal ( const Common::UString name,
void *  loc,
bool  textureUnitRecalc = true 
)

Definition at line 113 of file shadermaterial.cpp.

References _fragShader, _variableData, delMaterialVar(), recalcTextureUnits(), and Graphics::Shader::ShaderObject::variablesCombined.

Here is the call graph for this function:

◆ setVariableInternal() [1/2]

void Graphics::Shader::ShaderMaterial::setVariableInternal ( uint32  index,
bool  textureUnitRecalc = true 
)

Definition at line 127 of file shadermaterial.cpp.

References genMaterialVar(), and recalcTextureUnits().

Here is the call graph for this function:

◆ setVariableInternal() [2/2]

void Graphics::Shader::ShaderMaterial::setVariableInternal ( const Common::UString name,
bool  textureUnitRecalc = true 
)

Definition at line 135 of file shadermaterial.cpp.

References _fragShader, _variableData, genMaterialVar(), recalcTextureUnits(), and Graphics::Shader::ShaderObject::variablesCombined.

Here is the call graph for this function:

◆ unbindGLState()

void Graphics::Shader::ShaderMaterial::unbindGLState ( )

◆ useCount()

uint32 Graphics::Shader::ShaderMaterial::useCount ( ) const

Definition at line 388 of file shadermaterial.cpp.

References _usageCount.

Referenced by Graphics::Shader::MaterialManager::cleanup().

Here is the caller graph for this function:

◆ useDecrement()

void Graphics::Shader::ShaderMaterial::useDecrement ( )

Definition at line 382 of file shadermaterial.cpp.

References _usageCount.

Referenced by Graphics::Shader::ShaderRenderable::setMaterial(), and Graphics::Shader::ShaderRenderable::~ShaderRenderable().

Here is the caller graph for this function:

◆ useIncrement()

void Graphics::Shader::ShaderMaterial::useIncrement ( )

Definition at line 378 of file shadermaterial.cpp.

References _usageCount.

Referenced by Graphics::Shader::ShaderRenderable::setMaterial(), and Graphics::Shader::ShaderRenderable::ShaderRenderable().

Here is the caller graph for this function:

Member Data Documentation

◆ _alphaIndex

uint32 Graphics::Shader::ShaderMaterial::_alphaIndex
private

Definition at line 103 of file shadermaterial.h.

Referenced by bindFade(), bindProgram(), bindProgramNoFade(), and ShaderMaterial().

◆ _flags

uint32 Graphics::Shader::ShaderMaterial::_flags
private

Definition at line 98 of file shadermaterial.h.

Referenced by bindGLState(), getFlags(), setFlags(), and unbindGLState().

◆ _fragShader

Shader::ShaderObject* Graphics::Shader::ShaderMaterial::_fragShader
private

◆ _name

Common::UString Graphics::Shader::ShaderMaterial::_name
private

Definition at line 100 of file shadermaterial.h.

Referenced by getName().

◆ _usageCount

uint32 Graphics::Shader::ShaderMaterial::_usageCount
private

Definition at line 101 of file shadermaterial.h.

Referenced by useCount(), useDecrement(), and useIncrement().

◆ _variableData

std::vector<ShaderMaterialVariable> Graphics::Shader::ShaderMaterial::_variableData
private

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