|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:

List of all members.

## Public Types

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

## Public Member Functions

unsigned int | getTechniqueCount () const
Technique * | getTechniqueByIndex (unsigned int index) const
Technique * | getTechnique (const char *id) const
Technique * | getTechnique () const
void | setTechnique (const char *id)
void | setNodeBinding (Node *node)

## Static Public Member Functions

static Material * | create (const char *url)
static Material * | create (const char *url, PassCallback callback, void *cookie=NULL)
static Material * | create (Properties *materialProperties)
static Material * | create (Effect *effect)
static Material * | create (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:

  url | The 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:

  url | The URL pointing to the Properties object defining the material.
  callback | Function pointer to be called during Pass creation.
  cookie | Optional 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:

  materialProperties | The 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:

  effect | Effect 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:

  vshPath | Path to the vertex shader file.
  fshPath | Path to the fragment shader file.
  defines | New-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:

  id | The ID of the technique to return.

Returns:
  The specified technique.

Technique* gameplay::Material::getTechnique | ( |  | ) | const

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:

  index | The 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:

  id | ID of the technique to set.

All Classes Functions Variables Typedefs Enumerations Enumerator