Set of values that define the parameters of a Material. More...
#include <materialinstance.h>
Classes | |
class | MaterialInstancePrivate |
Public Member Functions | |
Q_INVOKABLE | MaterialInstance (QObject *parent=0) |
virtual | ~MaterialInstance () |
virtual void | bind () |
virtual void | release () |
Material * | material () |
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) |
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.
MaterialInstance::MaterialInstance | ( | QObject * | parent = 0 |
) | [explicit] |
Constructor.
Creates an unassigned MaterialInstance. It is recommended to use Material::createInstance instead.
Definition at line 56 of file materialinstance.cpp.
MaterialInstance::~MaterialInstance | ( | ) | [virtual] |
Destructor.
Definition at line 62 of file materialinstance.cpp.
int MaterialInstance::attributeLocation | ( | const QString & | attrib | ) |
Retrieve the location of a uniform variable from the underlying shader program.
name | The name of the uniform to retrieve the location for, |
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.
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.
|
Definition at line 212 of file materialinstance.cpp.
Material * MaterialInstance::material | ( | ) |
Retrieve the material used by this material instance.
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.
name | The name of the uniform to set the value of.
|
Definition at line 151 of file materialinstance.cpp.
void MaterialInstance::setMaterial | ( | Material * | material | ) |
Set the material this material instance uses.
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.
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.
name | The name of the uniform to retrieve the location for, |
Definition at line 116 of file materialinstance.cpp.