com.neovisionaries.android.opengl
Class StencilSettings

java.lang.Object
  extended by com.neovisionaries.android.opengl.StencilSettings

public class StencilSettings
extends Object

Stencil settings.

 // E X A M P L E

 new StencilSettings()
     .setActionSet(
         new StencilActionSet(
             StencilAction.REPLACE,
             StencilAction.DECR,
             StencilAction.DECR
         )
     )
     .setComparator(
         new StencilComparator(
             StencilComparisonOperator.LESS,
             0x7,
             0x3
         )
     )
     .apply();
 

Author:
Takahiko Kawasaki
See Also:
glStencilFunc, glStencilFuncSeparate, glStencilOp, glStencilOpSeparate

Constructor Summary
StencilSettings()
           
 
Method Summary
 StencilSettings apply()
          Apply the settings values that this instance holds to the underlying OpenGL ES implementation.
 StencilSettings disable()
          Disable the stencil test.
 StencilSettings enable()
          Enable the stencil test.
 StencilActionSet getBackActionSet()
          Get the action set for the back face.
 StencilComparator getBackComparator()
          Get the stencil comparator for the back face.
 StencilActionSet getFrontActionSet()
          Get the action set for the front face.
 StencilComparator getFrontComparator()
          Get the stencil comparator for the front face.
 StencilSettings setActionSet(StencilActionSet actionSet)
          This method is an alias of setActionSet(actionSet, null).
 StencilSettings setActionSet(StencilActionSet actionSet, Face face)
          Set an action set for the specified face.
 StencilSettings setComparator(StencilComparator comparator)
          This method is an alias of setComparator(comparator, null).
 StencilSettings setComparator(StencilComparator comparator, Face face)
          Set a stencil comparator for the specified face.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StencilSettings

public StencilSettings()
Method Detail

getFrontActionSet

public StencilActionSet getFrontActionSet()
Get the action set for the front face.

The default action set is an instance created by StencilActionSet().

Returns:
The action set for the front face.

getBackActionSet

public StencilActionSet getBackActionSet()
Get the action set for the back face.

The default action set is an instance created by StencilActionSet().

Returns:
The action set for the back face.

setActionSet

public StencilSettings setActionSet(StencilActionSet actionSet)
This method is an alias of setActionSet(actionSet, null).


setActionSet

public StencilSettings setActionSet(StencilActionSet actionSet,
                                    Face face)
Set an action set for the specified face.

If the major version number of the underlying OpenGL ES implementation is less than 2 (OpenGL ES 1.1, for example), it is no use setting an action set for the back face. It is because glStencilOpSeparate is not available. In this case, an action set for the front face is used for both the front face and the back face.

Parameters:
actionSet - An action set. The given action set is copied by using the copy constructor of StencilActionSet.
face - A face for which the action set is used. If null is given, Face.FRONT_AND_BACK is used, meaning that the given action set is used for both the front face and the back face.
Returns:
This StencilSettings object.

getFrontComparator

public StencilComparator getFrontComparator()
Get the stencil comparator for the front face.

The default stencil comparator is an instance created by StencilComparator().

Returns:
The stencil comparator for the front face.

getBackComparator

public StencilComparator getBackComparator()
Get the stencil comparator for the back face.

The default stencil comparator is an instance created by StencilComparator().

Returns:
The stencil comparator for the back face.

setComparator

public StencilSettings setComparator(StencilComparator comparator)
This method is an alias of setComparator(comparator, null).

Parameters:
comparator - A stencil comparator.
Returns:
This StecilSettings object.

setComparator

public StencilSettings setComparator(StencilComparator comparator,
                                     Face face)
Set a stencil comparator for the specified face.

If the major version number of the underlying OpenGL ES implementation is less than 2 (OpenGL ES 1.1, for example), it is no use setting a stencil comparator for the back face. It is because glStencilFuncSeparate is not available. In this case, a stencil comparator for the front face is used for both the front face and the back face.

Parameters:
comparator - A stencil comparator. The given comparator is copied by using the copy constructor of StencilComparator.
face - A face for which the comparator is used. If null is given, Face.FRONT_AND_BACK is used, meaning that the given comparator is used for both the front face and the back face.
Returns:
This StencilSettings object.

enable

public StencilSettings enable()
Enable the stencil test. glEnable(STENCIL_TEST) is called.

Returns:
This StencilSettings object.

disable

public StencilSettings disable()
Disable the stencil test. glDisable(STENCIL_TEST) is called.

Returns:
This StencilSettings object.

apply

public StencilSettings apply()
Apply the settings values that this instance holds to the underlying OpenGL ES implementation.

If the OpenGL ES version is equal to or greater than 2.0, methods listed below are executed.

  1. enable()
  2. glStencilOpSeparate() (for the front face)
  3. glStencilOpSeparator() (for the back face)
  4. glStencilFuncSeparate() (for the front face)
  5. glStencilFuncSeparator() (for the back face)

Otherwise, the following two are executed.

  1. enable()
  2. glStencilOp()
  3. glStencilFunc()

Returns:
This StencilSettings object.
See Also:
enable(), glStencilFunc, glStencilFuncSeparate, glStencilOp, glStencilOpSeparate