GluonGraphics::Material Class Reference

Collection of techniques which describe how to render a surface. More...

#include <material.h>

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

List of all members.

Classes

class  MaterialPrivate

Public Member Functions

 Material (QObject *parent=0)
virtual ~Material ()
bool load (const QUrl &url)
void build (const QString &name=QString())
Techniquetechnique (const QString &name=QString()) const
void addTechnique (Technique *technique)
void removeTechnique (const QString &name)
void setDefaultTechnique (const QString &name)
MaterialInstancecreateInstance (const QString &name)
MaterialInstanceinstance (const QString &name)
uint glProgram ()
QHash< QString, QVariant > uniformList ()

Detailed Description

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.

See also:
MaterialInstance

Definition at line 51 of file material.h.


Constructor & Destructor Documentation

Material::Material ( QObject parent = 0  ) 

Constructor.

Constructs an empty material.

Definition at line 64 of file material.cpp.

Material::~Material (  )  [virtual]

Destructor.

Definition at line 71 of file material.cpp.


Member Function Documentation

void Material::addTechnique ( Technique technique  ) 

Add a technique to the material.

Note that this will reparent the technique to this material.

Parameters:
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.

Parameters:
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.

Parameters:
name The name of the MaterialInstance to create.
Returns:
The MaterialInstance object just created. If the MaterialInstance already exists the existing object will be returned.
See also:
MaterialInstance

Definition at line 237 of file material.cpp.

uint Material::glProgram (  ) 

Retrieve the internal OpenGL Program identifier.

Returns:
The OpenGL identifier for the program or 0 if build was not yet called.

Definition at line 228 of file material.cpp.

MaterialInstance * Material::instance ( const QString &  name  ) 

Retrieve an existing MaterialInstance.

Parameters:
name The name of the MaterialInstance to retrieve.
Returns:
The named MaterialInstance or 0 if it was not found.

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.

Parameters:
url The url of the file to load.
Returns:
True if successful, false if not.

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.

Parameters:
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.

Parameters:
name The name of the technique to use as default.
See also:
defaultTechnique

Definition at line 222 of file material.cpp.

Technique * Material::technique ( const QString &  name = QString()  )  const

Retrieve a technique by name.

Parameters:
name The name of the technique to retrieve.
Returns:
The technique with the name "name" or 0 if it was not found. Passing an empty string will return the default technique.

Definition at line 204 of file material.cpp.

QHash< QString, QVariant > Material::uniformList (  ) 

Definition at line 263 of file material.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