overview wiki api reference download
 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:
gameplay::Ref gameplay::Material gameplay::Pass gameplay::Technique

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

MaterialParametergetParameter (const char *name) const
unsigned int getParameterCount () const
MaterialParametergetParameterByIndex (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)
StateBlockgetStateBlock () const
virtual void setNodeBinding (Node *node)

Protected Member Functions

 RenderState ()
virtual ~RenderState ()
void applyAutoBinding (const char *uniformName, const char *autoBinding)
void bind (Pass *pass)
RenderStategetTopmost (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

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).

Defines blend constants supported by the blend function.

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

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.

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

The initial front face mode is set to FRONT_FACE_CCW.

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.

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

Constructor.

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

Destructor.


Member Function Documentation

Adds a MaterialParameter to the render state.

Parameters:
paramThe parameters to to added.
void gameplay::RenderState::applyAutoBinding ( const char *  uniformName,
const char *  autoBinding 
) [protected]

Applies the specified custom auto-binding.

Parameters:
uniformNameName of the shader uniform.
autoBindingName 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:
renderStateThe RenderState to copy the data to.
contextThe clone context.
static void gameplay::RenderState::finalize ( ) [static, protected]

Static finalizer that is called during game shutdown.

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:
nameMaterial parameter (uniform) name.
Returns:
A MaterialParameter for the specified name.

Gets a MaterialParameter for the specified index.

Returns:
A MaterialParameter for the specified index.

Gets the number of material parameters.

Returns:
The number of material parameters.

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.

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:
nameMaterial 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:
nodeThe 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:
nameThe name of the material parameter to store an auto-binding for.
autoBindingA 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:
nameThe name of the material parameter to store an auto-binding for.
autoBindingA string matching one of the built-in AutoBinding enum constants.

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

Map of custom auto binding resolvers.

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.

The RenderState's parent.

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

 All Classes Functions Variables Typedefs Enumerations Enumerator