Rasterfarm-SDK
Loading...
Searching...
No Matches
Surface::Material Class Reference

#include <material.h>

Inheritance diagram for Surface::Material:
Program DynamicType ShadowMap::ShadowMaterial

Classes

struct  Initializer
 
struct  ShaderCode
 

Public Types

typedef List< Render::Component * > ComponentList
 
typedef List< Render::ModelUpdate * > ModelUpdateList
 
typedef List< Render::ViewUpdate * > ViewUpdateList
 
typedef List< Render::ModelViewUpdate * > ModelViewUpdateList
 
typedef UnorderedMap< TypeID, Render::Normal * > NormalMap
 
typedef List< Render::Color::Texel::Sampler * > SamplerList
 
typedef List< Render::Color::Pixel::Factor * > FactorList
 
typedef List< Render::Color::Function::Filter * > FilterList
 
- Public Types inherited from Program
enum  Errors { NO_LOCATION = -1 }
 
typedef Handle AttributeLocation
 
typedef Handle VaryingLocation
 
typedef Handle UniformBinding
 
typedef UnorderedMap< AttributeLocation, AttributeBuffer * > LocationAttributeBufferMap
 
typedef UnorderedMap< UniformBinding, Uniform * > BindingUniformMap
 
typedef UnorderedMap< AttributeLocation, bool > AttributeEnabled
 
typedef UnorderedMap< String, Handle > StringLocation
 
typedef UnorderedMap< UniformBinding, intBindingIntMap
 
typedef UnorderedMap< UniformBinding, floatBindingFloatMap
 
typedef UnorderedMap< UniformBinding, intBindingIntPointerMap
 
typedef UnorderedMap< UniformBinding, floatBindingFloatPointerMap
 
typedef UnorderedMap< UniformBinding, Vector2fArrayBindingVector2fArrayMap
 
typedef UnorderedMap< UniformBinding, Vector3fArrayBindingVector3fArrayMap
 
typedef UnorderedMap< UniformBinding, Vector4fArrayBindingVector4fArrayMap
 
typedef UnorderedMap< UniformBinding, HeapArray< Matrix3f > > BindingMatrix3fArrayMap
 
typedef UnorderedMap< UniformBinding, HeapArray< Matrix4f > > BindingMatrix4fArrayMap
 
typedef UnorderedMap< UniformBinding, UniformDescriptorTypeBindingDescriptorTypeMap
 

Public Member Functions

 Material (Render::Model::Position *pPosition, MaterialManager *pManager)
 
 Material (Render::Model::Position *pPosition, MaterialManager *pManager, size_t startElementIndex, size_t indexElementSize)
 
virtual ~Material ()
 
virtual void init ()
 
virtual void update ()
 
virtual void perform ()
 
bool isInitialized ()
 
virtual void setModelView (const Matrix4f &model, const Matrix4f &view)
 
void setFragmentColor (const Vector4f &color)
 
void addNormal (Render::Normal *pNormal)
 
void addColorSampler (Render::Color::Texel::Sampler *pComponent)
 
void addColorFactor (Render::Color::Pixel::Factor *pComponent)
 
void addColorFilter (Render::Color::Function::Filter *pComponent)
 
void addModelUpdate (Render::ModelUpdate *pModelUpdate)
 
void addViewUpdate (Render::ViewUpdate *pViewUpdate)
 
void addModelViewUpdate (Render::ModelViewUpdate *pModelViewUpdate)
 
void addAttributeBuffer (AttributeLocation location, void *pArray, size_t arrayLength, uint componentSize, BufferType componentType)
 
void updateAttributeBuffer (AttributeLocation location, void *pArray, size_t arrayLength, size_t offset=0)
 
Engine::UniformgetUniform (UniformBinding binding)
 
String assembleShaderCode (ShaderType type)
 
const String & getShaderGlobalCode (ShaderType type)
 
const String & getShaderMainCode (ShaderType type)
 
const String & getShaderFunctionCode (ShaderType type)
 
Render::Model::PositiongetPosition ()
 
ElementBuffergetElementBuffer ()
 
virtual void initElements (Shape::Geometry *pGeometry)
 
virtual void updateElements (Shape::Geometry *pGeometry)
 
virtual void submit ()
 
void addShaderFunctionCode (ShaderType type, String code)
 Add a new GLSL function to shader code.
 
void addShaderGlobalDefinitionCode (ShaderType type, String code)
 Add a new GLSL variable or define to shader code.
 
void appendShaderMainCode (ShaderType type, String code)
 Append code to main() function of shader code. Code should be non-dependent on existing code within main.
 
void addGlobalsToShaderCode ()
 
size_t getStartElementIndex () const
 
size_t getIndexElementSize () const
 
void setIndexElementSize (size_t size)
 
template<class C >
C * getNormal ()
 
template<class C >
List< C * > getColorSamplerList ()
 
template<class C >
List< C * > getColorFactorList ()
 
template<class C >
List< C * > getColorFilterList ()
 
template<class C >
Handle getColorFilterIndex (C *pObject)
 
template<class C >
Handle getColorSamplerIndex (C *pObject)
 
template<class C >
Handle getColorFactorIndex (C *pObject)
 
const FactorListgetColorFactorList () const
 
const FilterListgetColorFilterList () const
 
const SamplerListgetColorSamplerList () const
 
ComponentList getComponents () const
 
Raster::GeometricBase * getObject () const
 
void setObject (Raster::GeometricBase *pObject)
 
- Public Member Functions inherited from Program
 Program ()
 
virtual ~Program ()
 
void update ()
 
DrawPrimitive getDrawPrimitive () const
 
void setDrawPrimitive (DrawPrimitive drawPrimitive)
 
void setElementBufferUsage (const DrawUsageHint usage)
 
bool hasUniformBuffer (UniformBinding binding)
 
void addUniformMatrix3f (UniformBinding binding, Matrix3f *pMatrix=nullptr, uint count=1)
 
void addUniformMatrix4f (UniformBinding binding, Matrix4f *pMatrix=nullptr, uint count=1)
 
void setUniformMatrix4f (UniformBinding binding, Matrix4f *pMatrix)
 
void addUniformValue1i (UniformBinding binding, int value)
 
void addUniformSampler2D (UniformBinding binding, Texture *pTexture, TextureType textureType=QUAD_MAP)
 
void addUniformSampler2D (UniformBinding binding, TextureUnit textureUnit, TextureType textureType=QUAD_MAP)
 
void addUniformValue1f (UniformBinding binding, float value)
 
void updateUniformValue1i (UniformBinding binding, int value)
 
void updateUniformValue1f (UniformBinding binding, float value)
 
void addUniformBuffer1i (UniformBinding binding, int *pValue, uint count=1)
 
void addUniformBuffer1f (UniformBinding binding, float *pValue, uint count=1)
 
void addUniformBuffer2f (UniformBinding binding, float *pArray, uint count=1)
 
void addUniformBuffer3f (UniformBinding binding, float *pArray, uint count=1)
 
void addUniformBuffer4f (UniformBinding binding, float *pArray, uint count=1)
 
void setUniformBuffer2f (UniformBinding binding, float *pArray)
 
void setUniformBuffer3f (UniformBinding binding, float *pArray)
 
void setUniformBuffer4f (UniformBinding binding, float *pArray)
 
ProgramHandle getHandle ()
 
void create (const HeapArray< Shader * > &pShader)
 
void addGlobalAttribute (const String &typeString, const String &location)
 
void addGlobalUniform (const String &typeString, const String &binding, ShaderType type)
 
void addGlobalSampler (const String &typeString, const String &binding)
 
void addGlobalVarying (const String &typeString, const String &location)
 
bool hasGlobalAttribute (const String &location)
 
bool hasGlobalAttribute (const String &typeString, const String &location)
 
bool hasGlobalUniform (const String &location, ShaderType type)
 
bool hasGlobalVarying (const String &location)
 
AttributeLocation getAttributeLocation (const String &str)
 
UniformBinding getUniformBinding (const String &str)
 
ProgramHandle getProgramHandle ()
 
bool hasShader (ShaderType shaderType)
 
ShadergetShader (ShaderType shaderType)
 
HeapArray< Shader * > getShaders ()
 
bool getDepthBufferWrite ()
 
void enable ()
 
void disable ()
 
bool hasEnableState (PipelineState state)
 
void addEnableState (PipelineState state)
 
void removeEnableState (PipelineState state)
 
void setStates ()
 
bool isTransparent ()
 
void setTransparent (bool transparent=true)
 
void setStencilComparisonArgs (CompareOperation stencilTestFunction, int stencilComparisonValue, Handle stencilComparisonMask)
 
void setStencilOperationArgs (StencilOperation stencilOperationFail, StencilOperation stencilOperationDepthFail, StencilOperation stencilOperationDepthPass)
 
void setTriangleVertexOrientation (VertexOrientation orientation)
 
void setDepthTestFunction (CompareOperation function)
 
void setDepthBufferWrite (bool write=true)
 
void setLineWidth (float width)
 
void setBlendFactors (BlendFactor sBlendFactor, BlendFactor dBlendFactor)
 
void setBlend ()
 
void bindAttributeBuffers ()
 
void submit (ElementBuffer *pElementBuffer)
 
void submitUniforms ()
 
void setUniformSampler2D (UniformBinding binding, Texture *pTexture, TextureType textureType)
 
void setUniformValue1i (UniformBinding location, int value)
 
void setUniformValue1f (UniformBinding location, float value)
 
void setUniformBuffer1f (UniformBinding location, float *pBuffer)
 
void updateUniformPointer1i (UniformBinding location, int count, int *pBuffer)
 
void updateUniformPointer1f (UniformBinding location, int count, float *pBuffer)
 
void updateUniformPointer2f (UniformBinding location, int count, float *pBuffer)
 
void updateUniformPointer3f (UniformBinding location, int count, float *pBuffer)
 
void updateUniformPointer4f (UniformBinding location, int count, float *pBuffer)
 
void updateUniformMatrix3f (UniformBinding location, int count, float *pBuffer)
 
void updateUniformMatrix4f (UniformBinding location, int count, float *pBuffer)
 
- Public Member Functions inherited from DynamicType
 DynamicType ()
 
template<class C >
void addType ()
 
TypeID getDerivedTypeId () const
 
template<class C >
const bool isType () const
 
template<class C >
const C * cast () const
 
template<class C >
C * cast ()
 
template<class FROM , class TO >
TO * cast ()
 
template<class FROM , class TO >
const TO * cast () const
 

Protected Member Functions

void updateComponents ()
 

Protected Attributes

UnorderedMap< ShaderType, ShaderCodeshaderCode
 
Raster::GeometricBase * pObject
 
NormalMap pNormal
 
SamplerList pColorSampler
 
FactorList pColorFactor
 
FilterList pColorFilter
 
ModelUpdateList modelUpdate
 
ViewUpdateList viewUpdate
 
ModelViewUpdateList modelViewUpdate
 
size_t startElementIndex
 
size_t indexElementSize
 
ElementBufferpElementBuffer
 
Render::Model::PositionpPosition
 
bool initialized
 
MaterialManagerpManager
 
- Protected Attributes inherited from Program
VertexArrayHandle vao
 
UnorderedMap< ShaderType, Shader * > pShader
 
LocationAttributeBufferMap pAttributeBuffer
 
BindingUniformMap pUniform
 
String vertexShaderCode
 
String vertexShaderMainCode
 
String vertexShaderFunctionCode
 
String vertexShaderGlobalCode
 
String fragmentShaderCode
 
String fragmentShaderMainCode
 
String fragmentShaderFunctionCode
 
String fragmentShaderGlobalCode
 
StringUnorderedSet globalAttributeString
 
StringUnorderedSet vertexVaryingString
 
StringUnorderedSet fragmentVaryingString
 
StringUnorderedSet vertexGlobalUniformString
 
StringUnorderedSet fragmentGlobalUniformString
 
StateUnorderedSet stateEnable
 
DrawUsageHint elementBufferUsage
 
ElementBufferpElementBuffer
 
bool transparent
 
CullFace faceCull
 
bool depthBufferWrite
 
DrawPrimitive drawPrimitive
 
CompareOperation depthTestFunction
 
CompareOperation stencilTestFunction
 
int stencilComparisonValue
 
Handle stencilComparisonMask
 
StencilOperation stencilOperationFail
 
StencilOperation stencilOperationDepthFail
 
StencilOperation stencilOperationDepthPass
 
VertexOrientation triangleVertexOrientation
 
BlendFactor sBlendFactor
 
BlendFactor dBlendFactor
 
float lineWidth
 

Friends

class Raster::GeometricBase
 
class Raster::ShadowMap
 
class Raster::ReflectionMap
 

Additional Inherited Members

- Public Attributes inherited from Program
HeapArray< AttributeLocationattributeLocation
 
HeapArray< VaryingLocationvaryingLocation
 
StringLocation attributeHandle
 
StringLocation uniformHandle
 
StringLocation varyingHandle
 
AttributeEnabled attributeEnabled
 
- Static Public Attributes inherited from Program
static const String shaderVersionString
 
static const String shaderMainStartString
 
static const String fragmentColorString
 
static const String fragnentShaderHeaderString
 
static const String vertexPositionString
 
static const String texture2DSamplerString
 
static const String textureCubeSamplerString
 
static const String projectionSamplerString
 

Detailed Description

Contains shader program and components that describe the physical charactoristics of an GeometricObject.

Member Typedef Documentation

◆ ComponentList

◆ FactorList

typedef List< Render::Color::Pixel::Factor * > Surface::Material::FactorList

◆ FilterList

typedef List< Render::Color::Function::Filter * > Surface::Material::FilterList

◆ ModelUpdateList

◆ ModelViewUpdateList

◆ NormalMap

typedef UnorderedMap< TypeID, Render::Normal * > Surface::Material::NormalMap

◆ SamplerList

typedef List< Render::Color::Texel::Sampler * > Surface::Material::SamplerList

◆ ViewUpdateList

Constructor & Destructor Documentation

◆ Material() [1/2]

Surface::Material::Material ( Render::Model::Position * pPosition,
MaterialManager * pManager )

Constructor.

Parameters
Requiredvertex position component pointer.
OptionalMaterialManager, pass nullptr for no management.

◆ Material() [2/2]

Surface::Material::Material ( Render::Model::Position * pPosition,
MaterialManager * pManager,
size_t startElementIndex,
size_t indexElementSize )

Constructor.

Parameters
Requiredvertex position component pointer.
OptionalMaterialManager, pass nullptr for no management.
Thevertex start-index for the element-buffer.
Thenumber of vertices for the element-buffer to draw.

◆ ~Material()

virtual Surface::Material::~Material ( )
virtual

Member Function Documentation

◆ addAttributeBuffer()

void Surface::Material::addAttributeBuffer ( AttributeLocation location,
void * pArray,
size_t arrayLength,
uint componentSize,
BufferType componentType )

◆ addColorFactor()

void Surface::Material::addColorFactor ( Render::Color::Pixel::Factor * pComponent)

Add a color-factor component for this Material prior to initialization. NOTE: Adding samplers post-initialization currently not-supported

◆ addColorFilter()

void Surface::Material::addColorFilter ( Render::Color::Function::Filter * pComponent)

Add a color-filter component for this Material prior to initialization. NOTE: Adding samplers post-initialization currently not-supported

◆ addColorSampler()

void Surface::Material::addColorSampler ( Render::Color::Texel::Sampler * pComponent)

Add a color-sampler component for this Material prior to initialization. NOTE: Adding samplers post-initialization currently not-supported

◆ addGlobalsToShaderCode()

void Surface::Material::addGlobalsToShaderCode ( )

◆ addModelUpdate()

void Surface::Material::addModelUpdate ( Render::ModelUpdate * pModelUpdate)

◆ addModelViewUpdate()

void Surface::Material::addModelViewUpdate ( Render::ModelViewUpdate * pModelViewUpdate)

◆ addNormal()

void Surface::Material::addNormal ( Render::Normal * pNormal)

Add a normal component for this Material prior to initialization. NOTE: Adding samplers post-initialization currently not-supported

◆ addShaderFunctionCode()

void Surface::Material::addShaderFunctionCode ( ShaderType type,
String code )

Add a new GLSL function to shader code.

Add a complete function, including signature and brackets.

Parameters
specifythe shader to put the function

◆ addShaderGlobalDefinitionCode()

void Surface::Material::addShaderGlobalDefinitionCode ( ShaderType type,
String code )

Add a new GLSL variable or define to shader code.

A global-variable, defintion, or directive.

Parameters
specifythe shader to put the function

◆ addViewUpdate()

void Surface::Material::addViewUpdate ( Render::ViewUpdate * pViewUpdate)

◆ appendShaderMainCode()

void Surface::Material::appendShaderMainCode ( ShaderType type,
String code )

Append code to main() function of shader code. Code should be non-dependent on existing code within main.

Append code within the main() block.

Parameters
specifythe shader to put the function

◆ assembleShaderCode()

String Surface::Material::assembleShaderCode ( ShaderType type)

◆ getColorFactorIndex()

template<class C >
Handle Surface::Material::getColorFactorIndex ( C * pObject)
inline
Parameters
Theobject to find the index for.
Returns
A handle for the given object.

◆ getColorFactorList() [1/2]

template<class C >
List< C * > Surface::Material::getColorFactorList ( )
inline
Parameters
TheDynamicType id.
Returns
A vector of ColorFactor pointers matching the typeID.

◆ getColorFactorList() [2/2]

const FactorList & Surface::Material::getColorFactorList ( ) const
inline

◆ getColorFilterIndex()

template<class C >
Handle Surface::Material::getColorFilterIndex ( C * pObject)
inline
Parameters
Theobject to find the index for.
Returns
A handle for the given object.

◆ getColorFilterList() [1/2]

template<class C >
List< C * > Surface::Material::getColorFilterList ( )
inline
Parameters
TheDynamicType id.
Returns
A vector of ColorFactor pointers matching the typeID.

◆ getColorFilterList() [2/2]

const FilterList & Surface::Material::getColorFilterList ( ) const
inline

◆ getColorSamplerIndex()

template<class C >
Handle Surface::Material::getColorSamplerIndex ( C * pObject)
inline
Parameters
Theobject to find the index for.
Returns
A handle for the given object.

◆ getColorSamplerList() [1/2]

template<class C >
List< C * > Surface::Material::getColorSamplerList ( )
inline
Parameters
TheDynamicType id.
Returns
A vector of ColorSampler pointers matching the typeID.

◆ getColorSamplerList() [2/2]

const SamplerList & Surface::Material::getColorSamplerList ( ) const
inline

◆ getComponents()

ComponentList Surface::Material::getComponents ( ) const
Returns
All components used-by this Material.

◆ getElementBuffer()

ElementBuffer * Surface::Material::getElementBuffer ( )
inline

◆ getIndexElementSize()

size_t Surface::Material::getIndexElementSize ( ) const
inline

◆ getNormal()

template<class C >
C * Surface::Material::getNormal ( )
inline
Parameters
TheDynamicType id.
Returns
The unique Normal component pointer for the typeID. If the component does not exist, nullptr.

◆ getObject()

Raster::GeometricBase * Surface::Material::getObject ( ) const
inline

◆ getPosition()

Render::Model::Position * Surface::Material::getPosition ( )
inline

◆ getShaderFunctionCode()

const String & Surface::Material::getShaderFunctionCode ( ShaderType type)

◆ getShaderGlobalCode()

const String & Surface::Material::getShaderGlobalCode ( ShaderType type)

◆ getShaderMainCode()

const String & Surface::Material::getShaderMainCode ( ShaderType type)

◆ getStartElementIndex()

size_t Surface::Material::getStartElementIndex ( ) const
inline

◆ getUniform()

Engine::Uniform * Surface::Material::getUniform ( UniformBinding binding)

◆ init()

virtual void Surface::Material::init ( )
virtual

This can only be called 1X.

Reimplemented from Program.

Reimplemented in ShadowMap::ShadowMaterial.

◆ initElements()

virtual void Surface::Material::initElements ( Shape::Geometry * pGeometry)
virtual

◆ isInitialized()

bool Surface::Material::isInitialized ( )
inline

◆ perform()

virtual void Surface::Material::perform ( )
virtual

◆ setFragmentColor()

void Surface::Material::setFragmentColor ( const Vector4f & color)

◆ setIndexElementSize()

void Surface::Material::setIndexElementSize ( size_t size)
inline

◆ setModelView()

virtual void Surface::Material::setModelView ( const Matrix4f & model,
const Matrix4f & view )
virtual

◆ setObject()

void Surface::Material::setObject ( Raster::GeometricBase * pObject)

◆ submit()

virtual void Surface::Material::submit ( )
virtual

◆ update()

virtual void Surface::Material::update ( )
virtual

Reimplemented in ShadowMap::ShadowMaterial.

◆ updateAttributeBuffer()

void Surface::Material::updateAttributeBuffer ( AttributeLocation location,
void * pArray,
size_t arrayLength,
size_t offset = 0 )

◆ updateComponents()

void Surface::Material::updateComponents ( )
protected

◆ updateElements()

virtual void Surface::Material::updateElements ( Shape::Geometry * pGeometry)
virtual

Friends And Related Symbol Documentation

◆ Raster::GeometricBase

friend class Raster::GeometricBase
friend

◆ Raster::ReflectionMap

friend class Raster::ReflectionMap
friend

◆ Raster::ShadowMap

friend class Raster::ShadowMap
friend

Member Data Documentation

◆ indexElementSize

size_t Surface::Material::indexElementSize
protected

◆ initialized

bool Surface::Material::initialized
protected

◆ modelUpdate

ModelUpdateList Surface::Material::modelUpdate
protected

◆ modelViewUpdate

ModelViewUpdateList Surface::Material::modelViewUpdate
protected

◆ pColorFactor

FactorList Surface::Material::pColorFactor
protected

◆ pColorFilter

FilterList Surface::Material::pColorFilter
protected

◆ pColorSampler

SamplerList Surface::Material::pColorSampler
protected

◆ pElementBuffer

ElementBuffer* Surface::Material::pElementBuffer
protected

◆ pManager

MaterialManager* Surface::Material::pManager
protected

Callback if set.

◆ pNormal

NormalMap Surface::Material::pNormal
protected

◆ pObject

Raster::GeometricBase* Surface::Material::pObject
protected

◆ pPosition

Render::Model::Position* Surface::Material::pPosition
protected

A Unique component.

◆ shaderCode

UnorderedMap< ShaderType, ShaderCode > Surface::Material::shaderCode
protected

◆ startElementIndex

size_t Surface::Material::startElementIndex
protected

◆ viewUpdate

ViewUpdateList Surface::Material::viewUpdate
protected

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