com.neovisionaries.android.opengl
Class BlendSettings

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

public class BlendSettings
extends Object

Blend settings.

 // E X A M P L E

 new BlendSettings()
     .setSourceFactor(BlendFactor.ONE)
     .setOperator(BlendOperator.ADD)
     .apply();
 

Author:
Takahiko Kawasaki
See Also:
glBlendFunc, glBlendFuncSeparate, glBlendColor, glBlendEquationSeparate

Constructor Summary
BlendSettings()
           
 
Method Summary
 BlendSettings apply()
          Apply the settings values that this instance holds to the underlying OpenGL ES implementation.
 BlendSettings disable()
          Disable blending (call glDisable(GL_BLEND)).
 BlendSettings enable()
          Enable blending (call glEnable(GL_BLEND)).
 BlendOperator getAlphaOperator()
          Get the blending operator for alpha.
 float[] getColor()
          Get the constant blending color.
 BlendFactor getDestinationAlphaFactor()
          Get the blending factor for alpha of destination.
 BlendFactor getDestinationRGBFactor()
          Get the blending factor for RGB of destination.
 BlendOperator getRGBOperator()
          Get the blending operator for RGB.
 BlendFactor getSourceAlphaFactor()
          Get the blending factor for alpha of source.
 BlendFactor getSourceRGBFactor()
          Get the blending factor for RGB of source.
 BlendSettings setAlphaOperator(BlendOperator operator)
          Set the blending operator for alpha.
 BlendSettings setColor(float red, float green, float blue, float alpha)
          Set the constant blending color.
 BlendSettings setDestinationAlphaFactor(BlendFactor factor)
          Set the blending factor for alpha of destination.
 BlendSettings setDestinationFactor(BlendFactor factor)
          Set the blending factor for destination.
 BlendSettings setDestinationRGBFactor(BlendFactor factor)
          Set the blending factor for RGB of destination.
 BlendSettings setOperator(BlendOperator operator)
          Set the blending operator for both RGB and alpha.
 BlendSettings setRGBOperator(BlendOperator operator)
          Set the blending operator for RGB.
 BlendSettings setSourceAlphaFactor(BlendFactor factor)
          Set the blending factor for alpha of source.
 BlendSettings setSourceFactor(BlendFactor factor)
          Set the blending factor for source.
 BlendSettings setSourceRGBFactor(BlendFactor factor)
          Set the blending factor for RGB of source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlendSettings

public BlendSettings()
Method Detail

setSourceFactor

public BlendSettings setSourceFactor(BlendFactor factor)
Set the blending factor for source. The default value is BlendFactor.ONE.

The given value is used for both RGB and alpha factors.

Parameters:
factor - A blending factor. If null is given, BlendFactor.ONE is used.
Returns:
This BlendSettings object.
See Also:
glBlendFunc, glBlendFuncSeparate

setSourceRGBFactor

public BlendSettings setSourceRGBFactor(BlendFactor factor)
Set the blending factor for RGB of source. The default value is BlendFactor.ONE.

Parameters:
factor - A blending factor. If null is given, BlendFactor.ONE is used.
Returns:
This BlendSettings object.
See Also:
glBlendFunc, glBlendFuncSeparate

setSourceAlphaFactor

public BlendSettings setSourceAlphaFactor(BlendFactor factor)
Set the blending factor for alpha of source. The default value is BlendFactor.ONE.

If the version of the underlying OpenGL ES implementation is less than 2.0, calling this method has no meaning because glBlendFuncSeparate() is not available.

Parameters:
factor - A blending factor. If null is given, BlendFactor.ONE is used.
Returns:
This BlendSettings object.
See Also:
glBlendFunc, glBlendFuncSeparate

getSourceRGBFactor

public BlendFactor getSourceRGBFactor()
Get the blending factor for RGB of source.

Returns:
The blending factor for RGB of source.
See Also:
glBlendFunc, glBlendFuncSeparate

getSourceAlphaFactor

public BlendFactor getSourceAlphaFactor()
Get the blending factor for alpha of source.

Returns:
The blending factor for alpha of source.
See Also:
glBlendFunc, glBlendFuncSeparate

setDestinationFactor

public BlendSettings setDestinationFactor(BlendFactor factor)
Set the blending factor for destination. The default value is BlendFactor.ONE.

The given value is used for both RGB and alpha factors.

Parameters:
factor - A blending factor. If null is given, BlendFactor.ONE is used.
Returns:
This BlendSettings object.
See Also:
glBlendFunc, glBlendFuncSeparate

setDestinationRGBFactor

public BlendSettings setDestinationRGBFactor(BlendFactor factor)
Set the blending factor for RGB of destination. The default value is BlendFactor.ONE.

Parameters:
factor - A blending factor. If null is given, BlendFactor.ONE is used.
Returns:
This BlendSettings object.
See Also:
glBlendFunc, glBlendFuncSeparate

setDestinationAlphaFactor

public BlendSettings setDestinationAlphaFactor(BlendFactor factor)
Set the blending factor for alpha of destination. The default value is BlendFactor.ONE.

If the version of the underlying OpenGL ES implementation is less than 2.0, calling this method has no meaning because glBlendFuncSeparate() is not available.

Parameters:
factor - A blending factor. If null is given, BlendFactor.ONE is used.
Returns:
This BlendSettings object.
See Also:
glBlendFunc, glBlendFuncSeparate

getDestinationRGBFactor

public BlendFactor getDestinationRGBFactor()
Get the blending factor for RGB of destination.

Returns:
The blending factor for RGB of destination.
See Also:
glBlendFunc, glBlendFuncSeparate

getDestinationAlphaFactor

public BlendFactor getDestinationAlphaFactor()
Get the blending factor for alpha of destination.

Returns:
The blending factor for alpha of destination.
See Also:
glBlendFunc, glBlendFuncSeparate

setColor

public BlendSettings setColor(float red,
                              float green,
                              float blue,
                              float alpha)
Set the constant blending color. The default value is (0, 0, 0, 0).

If the version of the underlying OpenGL ES implementation is less than 2.0, calling this method has no meaning because glBlendColor() is not available.

Parameters:
red -
green -
blue -
alpha -
Returns:
This BlendSettings object.
See Also:
glBlendColor

getColor

public float[] getColor()
Get the constant blending color.

Returns:
The constant blending color.
See Also:
glBlendColor

setOperator

public BlendSettings setOperator(BlendOperator operator)
Set the blending operator for both RGB and alpha. The default value is BlendOperator.ADD.

If the version of the underlying OpenGL ES implementation is less than 2.0, calling this method has no meaning because neither glBlendEquation() nor glBlendEquationsSeparate() is available.

Parameters:
operator - A blending operator.
Returns:
This BlendSettings object.
See Also:
glBlendEquation, glBlendEquationSeparate

setRGBOperator

public BlendSettings setRGBOperator(BlendOperator operator)
Set the blending operator for RGB. The default value is BlendOperator.ADD.

If the version of the underlying OpenGL ES implementation is less than 2.0, calling this method has no meaning because neither glBlendEquation() nor glBlendEquationsSeparate() is available.

Parameters:
operator - A blending operator.
Returns:
This BlendSettings object.
See Also:
glBlendEquation, glBlendEquationSeparate

setAlphaOperator

public BlendSettings setAlphaOperator(BlendOperator operator)
Set the blending operator for alpha. The default value is BlendOperator.ADD.

If the version of the underlying OpenGL ES implementation is less than 2.0, calling this method has no meaning because neither glBlendEquation() nor glBlendEquationsSeparate() is available.

Parameters:
operator - A blending operator.
Returns:
This BlendSettings object.
See Also:
glBlendEquation, glBlendEquationSeparate

getRGBOperator

public BlendOperator getRGBOperator()
Get the blending operator for RGB.

Returns:
The blending operator for RGB.

getAlphaOperator

public BlendOperator getAlphaOperator()
Get the blending operator for alpha.

Returns:
The blending operator for alpha.

enable

public BlendSettings enable()
Enable blending (call glEnable(GL_BLEND)).

Returns:
This BlendSettings object.

disable

public BlendSettings disable()
Disable blending (call glDisable(GL_BLEND)).

Returns:
This BlendSettings object.

apply

public BlendSettings 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. glBlendFuncSeparate()
  3. glBlendColor()
  4. glBlendEquationSeparate()

Otherwise, the following two are executed.

  1. enable()
  2. glBlendFunc()

Returns:
This BlendSettings object.
See Also:
enable(), glBlendFunc, glBlendFuncSeparate, glBlendColor, glBlendEquationSeparate