Collection of techniques which describe how to render a surface. More...
#include <material.h>
Classes | |
class | MaterialPrivate |
Public Member Functions | |
Material (QObject *parent=0) | |
virtual | ~Material () |
bool | load (const QUrl &url) |
void | build (const QString &name=QString()) |
Technique * | technique (const QString &name=QString()) const |
void | addTechnique (Technique *technique) |
void | removeTechnique (const QString &name) |
void | setDefaultTechnique (const QString &name) |
MaterialInstance * | createInstance (const QString &name) |
MaterialInstance * | instance (const QString &name) |
uint | glProgram () |
QHash< QString, QVariant > | uniformList () |
Collection of techniques which describe how to render a surface.
A material is an object containing a set of techniques. Each technique describes a single way to render the surface of an object.
Materials cannot be directly rendered. Instead, you will need a MaterialInstance of the Material to render it. This is because the Material class is more like a code-generation tool. It generates shader code at runtime and compiles it into an OpenGL shader. The MaterialInstance then defines the values for the shader's uniform and attribute values.
MaterialInstances also control which technique is used to render the material. In addition, each material has a default technqiue which will be used if no override has been given.
Definition at line 51 of file material.h.
Material::Material | ( | QObject * | parent = 0 |
) |
Material::~Material | ( | ) | [virtual] |
Destructor.
Definition at line 71 of file material.cpp.
void Material::addTechnique | ( | Technique * | technique | ) |
Add a technique to the material.
Note that this will reparent the technique to this material.
technique | The technique to add. |
Definition at line 210 of file material.cpp.
void Material::build | ( | const QString & | name = QString() |
) |
Build the shader.
This processes the selected technique and generates the shader code. Once done, it then compiles the generated GLSL shader. If the shader compiles correctly, the appropriate parameters will be retrieved and can then be set.
technique | The name of the technique to use for the build process. Passing an empty string means it will use the default technique. |
Definition at line 118 of file material.cpp.
MaterialInstance * Material::createInstance | ( | const QString & | name | ) |
Create a MaterialInstance object for this material.
This will create a MaterialInstance object with all the parameters of this material set as properties on the object.
name | The name of the MaterialInstance to create. |
Definition at line 237 of file material.cpp.
uint Material::glProgram | ( | ) |
Retrieve the internal OpenGL Program identifier.
Definition at line 228 of file material.cpp.
MaterialInstance * Material::instance | ( | const QString & | name | ) |
Retrieve an existing MaterialInstance.
name | The name of the MaterialInstance to retrieve. |
Definition at line 254 of file material.cpp.
bool Material::load | ( | const QUrl & | url | ) |
Load a material definition from a file.
The url passed should point to a GDL file describing the material. See GluonCore::GluonObject for more information about GDL.
url | The url of the file to load. |
Definition at line 76 of file material.cpp.
void Material::removeTechnique | ( | const QString & | name | ) |
Remove a technique from the material.
The named technique will not be deleted but its parent will be set to 0.
name | The name of the technique to remove. |
Definition at line 216 of file material.cpp.
void Material::setDefaultTechnique | ( | const QString & | name | ) |
Set the default technique.
name | The name of the technique to use as default. |
Definition at line 222 of file material.cpp.
Technique * Material::technique | ( | const QString & | name = QString() |
) | const |
Retrieve a technique by name.
name | The name of the technique to retrieve. |
Definition at line 204 of file material.cpp.
QHash< QString, QVariant > Material::uniformList | ( | ) |
Definition at line 263 of file material.cpp.