overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions | Static Public Member Functions
gameplay::Material Class Reference

#include <Material.h>

Inheritance diagram for gameplay::Material:
gameplay::RenderState gameplay::Ref

List of all members.

Public Types

typedef std::string(* PassCallback )(Pass *, void *)

Public Member Functions

unsigned int getTechniqueCount () const
TechniquegetTechniqueByIndex (unsigned int index) const
TechniquegetTechnique (const char *id) const
TechniquegetTechnique () const
void setTechnique (const char *id)
void setNodeBinding (Node *node)

Static Public Member Functions

static Materialcreate (const char *url)
static Materialcreate (const char *url, PassCallback callback, void *cookie=NULL)
static Materialcreate (Properties *materialProperties)
static Materialcreate (Effect *effect)
static Materialcreate (const char *vshPath, const char *fshPath, const char *defines=NULL)

Detailed Description

Defines a material for an object to be rendered.

This class encapsulates a set of rendering techniques that can be used to render an object. This class facilitates loading of techniques using specified shaders or material files (.material). When multiple techniques are loaded using a material file, the current technique for an object can be set at runtime.

See also:
http://gameplay3d.github.io/GamePlay/docs/file-formats.html#wiki-Materials

Member Typedef Documentation

typedef std::string(* gameplay::Material::PassCallback)(Pass *, void *)

Pass creation callback function definition.


Member Function Documentation

static Material* gameplay::Material::create ( const char *  url) [static]

Creates a material using the data from the Properties object defined at the specified URL, where the URL is of the format "<file-path>.<extension>#<namespace-id>/<namespace-id>/.../<namespace-id>" (and "#<namespace-id>/<namespace-id>/.../<namespace-id>" is optional).

Parameters:
urlThe URL pointing to the Properties object defining the material.
Returns:
A new Material or NULL if there was an error.
static Material* gameplay::Material::create ( const char *  url,
PassCallback  callback,
void *  cookie = NULL 
) [static]

Creates a material from a Properties file.

This overloaded method allows you to pass a function pointer to be called back for each pass that is loaded for the material. The passed in callback receives a pointer to each Pass being created and returns a string of optional defines to append to the shaders being compiled for each Pass. The function is called during Pass creation, prior to compiling the shaders for that Pass. MaterialParameters can be safely modified in this callback even though the shader is not yet compiled.

Parameters:
urlThe URL pointing to the Properties object defining the material.
callbackFunction pointer to be called during Pass creation.
cookieOptional custom parameter to be passed to the callback function.
Returns:
A new Material or NULL if there was an error.
static Material* gameplay::Material::create ( Properties materialProperties) [static]

Creates a material from the specified properties object.

Parameters:
materialPropertiesThe properties object defining the material (must have namespace equal to 'material').
Returns:
A new Material.
static Material* gameplay::Material::create ( Effect effect) [static]

Creates a material from the specified effect.

The returned material has a single technique and a single pass for the given effect.

Parameters:
effectEffect for the new material.
Returns:
A new Material.
static Material* gameplay::Material::create ( const char *  vshPath,
const char *  fshPath,
const char *  defines = NULL 
) [static]

Creates a material using the specified vertex and fragment shader.

The returned material has a single technique and a single pass for the given effect.

Parameters:
vshPathPath to the vertex shader file.
fshPathPath to the fragment shader file.
definesNew-line delimited list of preprocessor defines.
Returns:
A new Material.
Technique* gameplay::Material::getTechnique ( const char *  id) const

Returns the technique with the specified ID in this material.

Parameters:
idThe ID of the technique to return.
Returns:
The specified technique.

Returns this material's current technique.

Returns:
The current technique.
Technique* gameplay::Material::getTechniqueByIndex ( unsigned int  index) const

Returns the technique at the specified index in this material.

Parameters:
indexThe index of the technique to return.
Returns:
The specified technique.
unsigned int gameplay::Material::getTechniqueCount ( ) const

Returns the number of techniques in the material.

Returns:
The technique count.
void gameplay::Material::setNodeBinding ( Node node) [virtual]
See also:
RenderState::setNodeBinding

Reimplemented from gameplay::RenderState.

void gameplay::Material::setTechnique ( const char *  id)

Sets the current material technique.

Parameters:
idID of the technique to set.
 All Classes Functions Variables Typedefs Enumerations Enumerator