GluonGraphics::MaterialInstance Class Reference

Set of values that define the parameters of a Material. More...

#include <materialinstance.h>

Inheritance diagram for GluonGraphics::MaterialInstance:
GluonCore::GluonObject QObject

List of all members.

Classes

class  MaterialInstancePrivate

Public Member Functions

Q_INVOKABLE MaterialInstance (QObject *parent=0)
virtual ~MaterialInstance ()
virtual void bind ()
virtual void release ()
Materialmaterial ()
void setMaterial (Material *material)
int uniformLocation (const QString &name)
int attributeLocation (const QString &attrib)
void setModelViewProjectionMatrix (QMatrix4x4 mvp)
void setPropertiesFromMaterial ()

Protected Member Functions

void setGLUniform (const QString &name, const QVariant &value)
void bindTexture (const QString &name, GluonGraphics::Texture *tex)

Detailed Description

Set of values that define the parameters of a Material.

The MaterialInstance class enables the rendering of a Material. It defines all the necessary parameters that the material needs to be rendered correctly. It does this by looking at its own dynamic properties during a call to bind() and setting all uniform variables related to those properties.

Definition at line 41 of file materialinstance.h.


Constructor & Destructor Documentation

MaterialInstance::MaterialInstance ( QObject parent = 0  )  [explicit]

Constructor.

Creates an unassigned MaterialInstance. It is recommended to use Material::createInstance instead.

See also:
Material::createInstance

Definition at line 56 of file materialinstance.cpp.

MaterialInstance::~MaterialInstance (  )  [virtual]

Destructor.

Definition at line 62 of file materialinstance.cpp.


Member Function Documentation

int MaterialInstance::attributeLocation ( const QString &  attrib  ) 

Retrieve the location of a uniform variable from the underlying shader program.

Parameters:
name The name of the uniform to retrieve the location for,
Returns:
The location of the uniform variable.

Definition at line 102 of file materialinstance.cpp.

void MaterialInstance::bind (  )  [virtual]

Bind the MaterialInstance for rendering.

This will switch the current OpenGL state to use the shader from the Material and set the appropriate parameters on this shader.

Definition at line 68 of file materialinstance.cpp.

void MaterialInstance::bindTexture ( const QString &  name,
GluonGraphics::Texture tex 
) [protected]

Bind a texture to a uniform variable.

Parameters:
name The name of the uniform. It is expected to be in the form "textureX" where X is the number of the texture unit to use.
Parameters:
tex The texture to bind.

Definition at line 212 of file materialinstance.cpp.

Material * MaterialInstance::material (  ) 

Retrieve the material used by this material instance.

Returns:
The material this material instance uses.

Definition at line 91 of file materialinstance.cpp.

void MaterialInstance::release (  )  [virtual]

Release the MaterialInstance from rendering.

Definition at line 84 of file materialinstance.cpp.

void MaterialInstance::setGLUniform ( const QString &  name,
const QVariant &  value 
) [protected]

Set the actual uniform variable. This method determines the type of the variant passed in as value and then proceeds to set the uniform to this value.

Note:
It is assumed that the material is bound when this method is called.
Parameters:
name The name of the uniform to set the value of.
Parameters:
value The value to set the uniform to.

Definition at line 151 of file materialinstance.cpp.

void MaterialInstance::setMaterial ( Material material  ) 

Set the material this material instance uses.

Parameters:
material The material to use.

Definition at line 97 of file materialinstance.cpp.

void MaterialInstance::setModelViewProjectionMatrix ( QMatrix4x4  mvp  ) 

Sets the modelViewProj uniform variable. The modelViewProj uniform contains the model-view-projection matrix, which is the matrix determining where to render the current model. This specific uniform should always be available.

Note:
It is assumed that the material is bound when this method is called.
Parameters:
mvp The model-view-projection matrix to set the uniform to.

Definition at line 131 of file materialinstance.cpp.

void MaterialInstance::setPropertiesFromMaterial (  ) 

Set local properties according to the information supplied by the material.

Definition at line 141 of file materialinstance.cpp.

int MaterialInstance::uniformLocation ( const QString &  name  ) 

Retrieve the location of a uniform variable from the underlying shader program.

Parameters:
name The name of the uniform to retrieve the location for,
Returns:
The location of the uniform variable.

Definition at line 116 of file materialinstance.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Dec 27 13:13:43 2010 for Gluon by  doxygen 1.6.3