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

- Main Page
- Classes

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

All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
gameplay::RenderState Class Reference

`#include <RenderState.h>`

Inheritance diagram for gameplay::RenderState:

List of all members.

## Classes

class | AutoBindingResolver
class | StateBlock

## Public Types

enum | AutoBinding { NONE, WORLD_MATRIX, VIEW_MATRIX, PROJECTION_MATRIX, WORLD_VIEW_MATRIX, VIEW_PROJECTION_MATRIX, WORLD_VIEW_PROJECTION_MATRIX, INVERSE_TRANSPOSE_WORLD_MATRIX, INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX, CAMERA_WORLD_POSITION, CAMERA_VIEW_POSITION, MATRIX_PALETTE, SCENE_AMBIENT_COLOR }

enum

Blend {
BLEND_ZERO = GL_ZERO, BLEND_ONE = GL_ONE, BLEND_SRC_COLOR = GL_SRC_COLOR, BLEND_ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
BLEND_DST_COLOR = GL_DST_COLOR, BLEND_ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR, BLEND_SRC_ALPHA = GL_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
BLEND_DST_ALPHA = GL_DST_ALPHA, BLEND_ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA, BLEND_CONSTANT_ALPHA = GL_CONSTANT_ALPHA, BLEND_ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA,
BLEND_SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE
}

enum | DepthFunction { DEPTH_NEVER = GL_NEVER, DEPTH_LESS = GL_LESS, DEPTH_EQUAL = GL_EQUAL, DEPTH_LEQUAL = GL_LEQUAL, DEPTH_GREATER = GL_GREATER, DEPTH_NOTEQUAL = GL_NOTEQUAL, DEPTH_GEQUAL = GL_GEQUAL, DEPTH_ALWAYS = GL_ALWAYS }
enum | CullFaceSide { CULL_FACE_SIDE_BACK = GL_BACK, CULL_FACE_SIDE_FRONT = GL_FRONT, CULL_FACE_SIDE_FRONT_AND_BACK = GL_FRONT_AND_BACK }
enum | FrontFace { FRONT_FACE_CW = GL_CW, FRONT_FACE_CCW = GL_CCW }
enum | StencilFunction { STENCIL_NEVER = GL_NEVER, STENCIL_ALWAYS = GL_ALWAYS, STENCIL_LESS = GL_LESS, STENCIL_LEQUAL = GL_LEQUAL, STENCIL_EQUAL = GL_EQUAL, STENCIL_GREATER = GL_GREATER, STENCIL_GEQUAL = GL_GEQUAL, STENCIL_NOTEQUAL = GL_NOTEQUAL }
enum | StencilOperation { STENCIL_OP_KEEP = GL_KEEP, STENCIL_OP_ZERO = GL_ZERO, STENCIL_OP_REPLACE = GL_REPLACE, STENCIL_OP_INCR = GL_INCR, STENCIL_OP_DECR = GL_DECR, STENCIL_OP_INVERT = GL_INVERT, STENCIL_OP_INCR_WRAP = GL_INCR_WRAP, STENCIL_OP_DECR_WRAP = GL_DECR_WRAP }

## Public Member Functions

MaterialParameter * | getParameter (const char *name) const
unsigned int | getParameterCount () const
MaterialParameter * | getParameterByIndex (unsigned int index)
void | addParameter (MaterialParameter *param)
void | removeParameter (const char *name)
void | setParameterAutoBinding (const char *name, AutoBinding autoBinding)
void | setParameterAutoBinding (const char *name, const char *autoBinding)
void | setStateBlock (StateBlock *state)
StateBlock * | getStateBlock () const
virtual void | setNodeBinding (Node *node)

## Protected Member Functions

| RenderState ()
virtual | ~RenderState ()
void | applyAutoBinding (const char *uniformName, const char *autoBinding)
void | bind (Pass *pass)
RenderState * | getTopmost (RenderState *below)
void | cloneInto (RenderState *renderState, NodeCloneContext &context) const

## Static Protected Member Functions

static void | initialize ()
static void | finalize ()

## Protected Attributes

std::vector< MaterialParameter * > | _parameters
std::map< std::string, std::string > | _autoBindings
Node * | _nodeBinding
StateBlock * | _state
RenderState * | _parent

## Static Protected Attributes

static std::vector < AutoBindingResolver * > | _customAutoBindingResolvers

## Detailed Description

Defines the rendering state of the graphics device.

## Member Enumeration Documentation

enum gameplay::RenderState::AutoBinding

Built-in auto-bind targets for material parameters.

Enumerator:

  WORLD_MATRIX | Binds a node's World matrix.
  VIEW_MATRIX | Binds the View matrix of the active camera for the node's scene.
  PROJECTION_MATRIX | Binds the Projection matrix of the active camera for the node's scene.
  WORLD_VIEW_MATRIX | Binds a node's WorldView matrix.
  VIEW_PROJECTION_MATRIX | Binds the ViewProjection matrix of the active camera for the node's scene.
  WORLD_VIEW_PROJECTION_MATRIX | Binds a node's WorldViewProjection matrix.
  INVERSE_TRANSPOSE_WORLD_MATRIX | Binds a node's InverseTransposeWorl matrix.
  INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX | Binds a node's InverseTransposeWorldView matrix.
  CAMERA_WORLD_POSITION | Binds the position (Vector3) of the active camera for the node's scene.
  CAMERA_VIEW_POSITION | Binds the view-space position (Vector3) of the active camera for the node's scene.
  MATRIX_PALETTE | Binds the matrix palette of MeshSkin attached to a node's model.
  SCENE_AMBIENT_COLOR | Binds the current scene's ambient color (Vector3).

enum gameplay::RenderState::Blend

Defines blend constants supported by the blend function.

enum gameplay::RenderState::CullFaceSide

Defines culling criteria for front-facing, back-facing and both-side facets.

enum gameplay::RenderState::DepthFunction

Defines the supported depth compare functions.

Depth compare functions specify the comparison that takes place between the incoming pixel's depth value and the depth value already in the depth buffer. If the compare function passes, the new pixel will be drawn.

The intial depth compare function is DEPTH_LESS.

enum gameplay::RenderState::FrontFace

Defines the winding of vertices in faces that are considered front facing.

The initial front face mode is set to FRONT_FACE_CCW.

enum gameplay::RenderState::StencilFunction

Defines the supported stencil compare functions.

Stencil compare functions determine if a new pixel will be drawn.

The initial stencil compare function is STENCIL_ALWAYS.

enum gameplay::RenderState::StencilOperation

Defines the supported stencil operations to perform.

Stencil operations determine what should happen to the pixel if the stencil test fails, passes, or passes but fails the depth test.

The initial stencil operation is STENCIL_OP_KEEP.

## Constructor & Destructor Documentation

gameplay::RenderState::RenderState | ( |  | ) | `[protected]`

Constructor.

virtual gameplay::RenderState::~RenderState | ( |  | ) | `[protected, virtual]`

Destructor.

## Member Function Documentation

void gameplay::RenderState::addParameter | ( | MaterialParameter * | param | ) |

Adds a MaterialParameter to the render state.

Parameters:

  param | The parameters to to added.

void gameplay::RenderState::applyAutoBinding | ( | const char * | uniformName,
|  | const char * | autoBinding
| ) |  | `[protected]`

Applies the specified custom auto-binding.

Parameters:

  uniformName | Name of the shader uniform.
  autoBinding | Name of the auto binding.s

void gameplay::RenderState::bind | ( | Pass * | pass | ) | `[protected]`

Binds the render state for this RenderState and any of its parents, top-down, for the given pass.

void gameplay::RenderState::cloneInto | ( | RenderState * | renderState,
|  | NodeCloneContext & | context
| ) |  | const`[protected]`

Copies the data from this RenderState into the given RenderState.

Parameters:

  renderState | The RenderState to copy the data to.
  context | The clone context.

static void gameplay::RenderState::finalize | ( |  | ) | `[static, protected]`

Static finalizer that is called during game shutdown.

MaterialParameter* gameplay::RenderState::getParameter | ( | const char * | name | ) | const

Gets a MaterialParameter for the specified name.

The returned MaterialParameter can be used to set values for the specified parameter name.

Note that this method causes a new MaterialParameter to be created if one does not already exist for the given parameter name.

Parameters:

  name | Material parameter (uniform) name.

Returns:
  A MaterialParameter for the specified name.

MaterialParameter* gameplay::RenderState::getParameterByIndex | ( | unsigned int | index | ) |

Gets a MaterialParameter for the specified index.

Returns:
  A MaterialParameter for the specified index.

unsigned int gameplay::RenderState::getParameterCount | ( |  | ) | const

Gets the number of material parameters.

Returns:
  The number of material parameters.

StateBlock* gameplay::RenderState::getStateBlock | ( |  | ) | const

Gets the fixed-function StateBlock for this RenderState object.

The returned StateBlock is referenced by this RenderState and therefore should not be released by the user. To release a StateBlock for a RenderState, the setState(StateBlock*) method should be called, passing NULL. This removes the StateBlock and resets the fixed-function render state to the default state.

It is legal to pass the returned StateBlock to another RenderState object. In this case, the StateBlock will be referenced by both RenderState objects and any changes to the StateBlock will be reflected in all objects that reference it.

Returns:
  The StateBlock for this RenderState.

RenderState* gameplay::RenderState::getTopmost | ( | RenderState * | below | ) | `[protected]`

Returns the topmost RenderState in the hierarchy below the given RenderState.

static void gameplay::RenderState::initialize | ( |  | ) | `[static, protected]`

Static initializer that is called during game startup.

void gameplay::RenderState::removeParameter | ( | const char * | name | ) |

Removes(clears) the MaterialParameter with the given name.

If a material parameter exists for the given name, it is destroyed and removed from this RenderState.

Parameters:

  name | Material parameter (uniform) name.

virtual void gameplay::RenderState::setNodeBinding | ( | Node * | node | ) | `[virtual]`

Sets the node that this render state is bound to.

The specified node is used to apply auto-bindings for the render state. This is typically set to the node of the model that a material is applied to.

Parameters:

  node | The node to use for applying auto-bindings.

Reimplemented in gameplay::Material, and gameplay::Technique.

void gameplay::RenderState::setParameterAutoBinding | ( | const char * | name,
|  | AutoBinding | autoBinding
| ) |  |

Sets a material parameter auto-binding.

Parameters:

  name | The name of the material parameter to store an auto-binding for.
  autoBinding | A valid AutoBinding value.

void gameplay::RenderState::setParameterAutoBinding | ( | const char * | name,
|  | const char * | autoBinding
| ) |  |

Sets a material parameter auto-binding.

This method parses the passed in autoBinding string and attempts to convert it to an AutoBinding enumeration value, which is then stored in this render state.

Parameters:

  name | The name of the material parameter to store an auto-binding for.
  autoBinding | A string matching one of the built-in AutoBinding enum constants.

void gameplay::RenderState::setStateBlock | ( | StateBlock * | state | ) |

Sets the fixed-function render state of this object to the state contained in the specified StateBlock.

The passed in StateBlock is stored in this RenderState object with an increased reference count and released when either a different StateBlock is assigned, or when this RenderState object is destroyed.

Parameters:

  state | The state block to set.

## Member Data Documentation

std::map<std::string, std::string> gameplay::RenderState::_autoBindings `[protected]`

Map of parameter names to auto binding strings.

std::vector<AutoBindingResolver*> gameplay::RenderState::_customAutoBindingResolvers `[static, protected]`

Map of custom auto binding resolvers.

Node* gameplay::RenderState::_nodeBinding `[protected]`

The Node bound to the RenderState.

std::vector<MaterialParameter*> gameplay::RenderState::_parameters `[mutable, protected]`

Collection of MaterialParameter's to be applied to the gameplay::Effect.

RenderState* gameplay::RenderState::_parent `[protected]`

The RenderState's parent.

StateBlock* gameplay::RenderState::_state `[mutable, protected]`

The StateBlock of fixed-function render states that can be applied to the RenderState.

All Classes Functions Variables Typedefs Enumerations Enumerator