Cocos2d-x  v3.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
RenderState::StateBlock Class Reference

Defines a block of fixed-function render states that can be applied to a RenderState object. More...

Inherits Ref.

Public Types

enum  
 StateBlock bits to be used with invalidate.
 

Public Member Functions

 StateBlock ()
 The recommended way to create StateBlocks is by calling create. More...
 
 StateBlock ()
 The recommended way to create StateBlocks is by calling create. More...
 
 StateBlock ()
 The recommended way to create StateBlocks is by calling create. More...
 
 ~StateBlock ()
 Destructor.
 
void bind ()
 Binds the state in this StateBlock to the renderer. More...
 
void setBlendFunc (const BlendFunc &blendFunc)
 Explicitly sets the source and destination used in the blend function for this render state. More...
 
void setBlend (bool enabled)
 Toggles blending. More...
 
void setBlendSrc (Blend blend)
 Explicitly sets the source used in the blend function for this render state. More...
 
void setBlendDst (Blend blend)
 Explicitly sets the destination used in the blend function for this render state. More...
 
void setCullFace (bool enabled)
 Explicitly enables or disables backface culling. More...
 
void setCullFaceSide (CullFaceSide side)
 Sets the side of the facets to cull. More...
 
void setFrontFace (FrontFace winding)
 Sets the winding for front facing polygons. More...
 
void setDepthTest (bool enabled)
 Toggles depth testing. More...
 
void setDepthWrite (bool enabled)
 Toggles depth writing. More...
 
var setDepthWrite ( var enabled)
 Toggles depth writing. More...
 
local setDepthWrite ( local enabled)
 Toggles depth writing. More...
 
void setDepthFunction (DepthFunction func)
 Sets the depth function to use when depth testing is enabled. More...
 
void setState (const std::string &name, const std::string &value)
 Toggles stencil testing. More...
 
uint32_t getHash () const
 Get hash code of this render state. More...
 
bool isDirty () const
 Is this render state dirty? true dirty, false not dirty.
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
local retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor.
 

Static Public Member Functions

static StateBlockcreate ()
 Creates a new StateBlock with default render state settings. More...
 
static void invalidate (long stateBits)
 Invalidates the default StateBlock. More...
 
local invalidate ( local stateBits)
 Invalidates the default StateBlock. More...
 
static void restore (long stateOverrideBits)
 Restores the global Render State to the default state. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 
bool _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 
local _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 

Detailed Description

Defines a block of fixed-function render states that can be applied to a RenderState object.

Constructor & Destructor Documentation

The recommended way to create StateBlocks is by calling create.

Don't use new or delete on them.

var StateBlock ( )

The recommended way to create StateBlocks is by calling create.

Don't use new or delete on them.

local StateBlock ( )

The recommended way to create StateBlocks is by calling create.

Don't use new or delete on them.

Member Function Documentation

static StateBlock* create ( )
static

Creates a new StateBlock with default render state settings.

Created StateBlock.

var create ( )
static

Creates a new StateBlock with default render state settings.

Created StateBlock.

local create ( )
static

Creates a new StateBlock with default render state settings.

Created StateBlock.

void bind ( )

Binds the state in this StateBlock to the renderer.

This method handles both setting and restoring of render states to ensure that only the state explicitly defined by this StateBlock is applied to the renderer.

var bind ( )

Binds the state in this StateBlock to the renderer.

This method handles both setting and restoring of render states to ensure that only the state explicitly defined by this StateBlock is applied to the renderer.

local bind ( )

Binds the state in this StateBlock to the renderer.

This method handles both setting and restoring of render states to ensure that only the state explicitly defined by this StateBlock is applied to the renderer.

void setBlendFunc ( const BlendFunc blendFunc)

Explicitly sets the source and destination used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the blending factors are computed.

var setBlendFunc ( var  blendFunc)

Explicitly sets the source and destination used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the blending factors are computed.

local setBlendFunc ( local  blendFunc)

Explicitly sets the source and destination used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the blending factors are computed.

void setBlend ( bool  enabled)

Toggles blending.

true to enable, false to disable.

var setBlend ( var  enabled)

Toggles blending.

true to enable, false to disable.

local setBlend ( local  enabled)

Toggles blending.

true to enable, false to disable.

void setBlendSrc ( Blend  blend)

Explicitly sets the source used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the source blending factors are computed.

var setBlendSrc ( var  blend)

Explicitly sets the source used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the source blending factors are computed.

local setBlendSrc ( local  blend)

Explicitly sets the source used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the source blending factors are computed.

void setBlendDst ( Blend  blend)

Explicitly sets the destination used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the destination blending factors are computed.

var setBlendDst ( var  blend)

Explicitly sets the destination used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the destination blending factors are computed.

local setBlendDst ( local  blend)

Explicitly sets the destination used in the blend function for this render state.

Note that the blend function is only applied when blending is enabled. Specifies how the destination blending factors are computed.

void setCullFace ( bool  enabled)

Explicitly enables or disables backface culling.

true to enable, false to disable.

var setCullFace ( var  enabled)

Explicitly enables or disables backface culling.

true to enable, false to disable.

local setCullFace ( local  enabled)

Explicitly enables or disables backface culling.

true to enable, false to disable.

void setCullFaceSide ( CullFaceSide  side)

Sets the side of the facets to cull.

When not explicitly set, the default is to cull back-facing facets. The side to cull.

var setCullFaceSide ( var  side)

Sets the side of the facets to cull.

When not explicitly set, the default is to cull back-facing facets. The side to cull.

local setCullFaceSide ( local  side)

Sets the side of the facets to cull.

When not explicitly set, the default is to cull back-facing facets. The side to cull.

void setFrontFace ( FrontFace  winding)

Sets the winding for front facing polygons.

By default, counter-clockwise wound polygons are considered front facing. The winding for front facing polygons.

var setFrontFace ( var  winding)

Sets the winding for front facing polygons.

By default, counter-clockwise wound polygons are considered front facing. The winding for front facing polygons.

local setFrontFace ( local  winding)

Sets the winding for front facing polygons.

By default, counter-clockwise wound polygons are considered front facing. The winding for front facing polygons.

void setDepthTest ( bool  enabled)

Toggles depth testing.

By default, depth testing is disabled. true to enable, false to disable.

var setDepthTest ( var  enabled)

Toggles depth testing.

By default, depth testing is disabled. true to enable, false to disable.

local setDepthTest ( local  enabled)

Toggles depth testing.

By default, depth testing is disabled. true to enable, false to disable.

void setDepthWrite ( bool  enabled)

Toggles depth writing.

true to enable, false to disable.

var setDepthWrite ( var  enabled)

Toggles depth writing.

true to enable, false to disable.

local setDepthWrite ( local  enabled)

Toggles depth writing.

true to enable, false to disable.

void setDepthFunction ( DepthFunction  func)

Sets the depth function to use when depth testing is enabled.

When not explicitly set and when depth testing is enabled, the default depth function is DEPTH_LESS. The depth function.

var setDepthFunction ( var  func)

Sets the depth function to use when depth testing is enabled.

When not explicitly set and when depth testing is enabled, the default depth function is DEPTH_LESS. The depth function.

local setDepthFunction ( local  func)

Sets the depth function to use when depth testing is enabled.

When not explicitly set and when depth testing is enabled, the default depth function is DEPTH_LESS. The depth function.

void setState ( const std::string &  name,
const std::string &  value 
)

Toggles stencil testing.

By default, stencil testing is disabled. true to enable, false to disable. Sets the stencil writing mask.

By default, the stencil writing mask is all 1's. Bit mask controlling writing to individual stencil planes. Sets the stencil function.

By default, the function is set to STENCIL_ALWAYS, the reference value is 0, and the mask is all 1's. The stencil function. The stencil reference value. The stencil mask. Sets the stencil operation.

By default, stencil fail, stencil pass/depth fail, and stencil and depth pass are set to STENCIL_OP_KEEP. The stencil operation if the stencil test fails. The stencil operation if the stencil test passes, but the depth test fails. The stencil operation if both the stencil test and depth test pass. Sets a render state from the given name and value strings.

This method attempts to interpret the passed in strings as render state name and value. This is normally used when loading render states from material files. Name of the render state to set. Value of the specified render state.

var setState ( var  name,
var  value 
)

Toggles stencil testing.

By default, stencil testing is disabled. true to enable, false to disable. Sets the stencil writing mask.

By default, the stencil writing mask is all 1's. Bit mask controlling writing to individual stencil planes. Sets the stencil function.

By default, the function is set to STENCIL_ALWAYS, the reference value is 0, and the mask is all 1's. The stencil function. The stencil reference value. The stencil mask. Sets the stencil operation.

By default, stencil fail, stencil pass/depth fail, and stencil and depth pass are set to STENCIL_OP_KEEP. The stencil operation if the stencil test fails. The stencil operation if the stencil test passes, but the depth test fails. The stencil operation if both the stencil test and depth test pass. Sets a render state from the given name and value strings.

This method attempts to interpret the passed in strings as render state name and value. This is normally used when loading render states from material files. Name of the render state to set. Value of the specified render state.

local setState ( local  name,
local  value 
)

Toggles stencil testing.

By default, stencil testing is disabled. true to enable, false to disable. Sets the stencil writing mask.

By default, the stencil writing mask is all 1's. Bit mask controlling writing to individual stencil planes. Sets the stencil function.

By default, the function is set to STENCIL_ALWAYS, the reference value is 0, and the mask is all 1's. The stencil function. The stencil reference value. The stencil mask. Sets the stencil operation.

By default, stencil fail, stencil pass/depth fail, and stencil and depth pass are set to STENCIL_OP_KEEP. The stencil operation if the stencil test fails. The stencil operation if the stencil test passes, but the depth test fails. The stencil operation if both the stencil test and depth test pass. Sets a render state from the given name and value strings.

This method attempts to interpret the passed in strings as render state name and value. This is normally used when loading render states from material files. Name of the render state to set. Value of the specified render state.

uint32_t getHash ( ) const

Get hash code of this render state.

Hash code of this render state.

var getHash ( )

Get hash code of this render state.

Hash code of this render state.

local getHash ( )

Get hash code of this render state.

Hash code of this render state.

static void invalidate ( long  stateBits)
static

Invalidates the default StateBlock.

Only call it if you are calling GL calls directly. Invoke this function at the end of your custom draw call. This function restores the default render state its defaults values. Since this function might call GL calls, it must be called in a GL context is present. Bitwise-OR of the states that needs to be invalidated

var invalidate ( var  stateBits)
static

Invalidates the default StateBlock.

Only call it if you are calling GL calls directly. Invoke this function at the end of your custom draw call. This function restores the default render state its defaults values. Since this function might call GL calls, it must be called in a GL context is present. Bitwise-OR of the states that needs to be invalidated

local invalidate ( local  stateBits)
static

Invalidates the default StateBlock.

Only call it if you are calling GL calls directly. Invoke this function at the end of your custom draw call. This function restores the default render state its defaults values. Since this function might call GL calls, it must be called in a GL context is present. Bitwise-OR of the states that needs to be invalidated

static void restore ( long  stateOverrideBits)
static

Restores the global Render State to the default state.

The difference between invalidate() and restore(), is that restore() will restore the global Render State based on its current state. Only the states that were changed will be restored.

Rule of thumb:

  • call restore() if you want to restore to the default state after using StateBlock.
  • call invalidate() if you want to restore to the default state after calling manual GL calls. Bitwise-OR of the states that needs to be override.
var restore ( var  stateOverrideBits)
static

Restores the global Render State to the default state.

The difference between invalidate() and restore(), is that restore() will restore the global Render State based on its current state. Only the states that were changed will be restored.

Rule of thumb:

  • call restore() if you want to restore to the default state after using StateBlock.
  • call invalidate() if you want to restore to the default state after calling manual GL calls. Bitwise-OR of the states that needs to be override.
local restore ( local  stateOverrideBits)
static

Restores the global Render State to the default state.

The difference between invalidate() and restore(), is that restore() will restore the global Render State based on its current state. Only the states that were changed will be restored.

Rule of thumb:

  • call restore() if you want to restore to the default state after using StateBlock.
  • call invalidate() if you want to restore to the default state after calling manual GL calls. Bitwise-OR of the states that needs to be override.

The documentation for this class was generated from the following file: