org.jrabbit.base.graphics.transforms
Class BlendOp

java.lang.Object
  extended by org.jrabbit.base.graphics.transforms.BlendOp
All Implemented Interfaces:
GLTransform
Direct Known Subclasses:
BlendOp.Additive, BlendOp.Normal, BlendOp.Overlay, BlendOp.Premultiplied, BlendOp.Replace

public class BlendOp
extends java.lang.Object
implements GLTransform

A BlendOp provides a simple method to switch to another type of pixel blending and back. Basically, a BlendOp is an object that stores instructions for glBlendFunc. Whenever it is bound, it pushes the color buffer bit (to store previous blending) and calls glBlendFunc() with the stored values. If you don't have an understanding of how glBlendFunc works, it's recommended that you stick with the default versions of this class.

Author:
Chris Molini

Nested Class Summary
static class BlendOp.Additive
          Enforces "additive" blending - where colors only get brighter, not darker.
static class BlendOp.Normal
          Enforces "normal" blending - where images retain their full color, and replace each other depending on how transparent they are.
static class BlendOp.Overlay
          Enforces blending that will cause any images to be limited to the color they are being rendered on top of.
static class BlendOp.Premultiplied
          Enforces blending that is designed for use with premultiplied-alpha images.
static class BlendOp.Replace
          Enforces "replacement" blending - alpha is not taken into account, and one set of pixel colors completely replaces another.
 
Field Summary
static BlendOp ADDITIVE
          A BlendOp with additive blending.
protected  int dstFactor
          The destination blending factor.
static BlendOp NORMAL
          A BlendOp with normal blending.
static BlendOp OVERLAY
          A BlendOp with overlay blending.
static BlendOp PREMULTIPLIED
          A BlendOp with premultiplied blending.
static BlendOp REPLACE
          A BlendOp with replacement blending.
protected  int srcFactor
          The source blending factor.
 
Constructor Summary
BlendOp(int srcFactor, int dstFactor)
          Creates a BlendOp that will supply the indicated values to glBlendFunc.
 
Method Summary
 void bind()
          Pushes the current color settings (including blending) onto the stack and then sets the new blending factors.
 int dstFactor()
          Accessed a value used to blend.
 boolean equals(java.lang.Object object)
          As equals(), but if the supplied object is a BlendOp, it checks to see if their blending factors are the same.
 void release()
          Pops the attribute stack.
 void set(BlendOp blend)
          Defines the BlendOp to have the same blending settings as another.
 void setDstFactor(int dstFactor)
          Redefines the value to use for destination pixel blending.
 void setSrcFactor(int srcFactor)
          Redefines the value to use for source pixel blending.
 int srcFactor()
          Accessed a value used to blend.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMAL

public static BlendOp NORMAL
A BlendOp with normal blending.


REPLACE

public static BlendOp REPLACE
A BlendOp with replacement blending.


ADDITIVE

public static BlendOp ADDITIVE
A BlendOp with additive blending.


OVERLAY

public static BlendOp OVERLAY
A BlendOp with overlay blending.


PREMULTIPLIED

public static BlendOp PREMULTIPLIED
A BlendOp with premultiplied blending.


srcFactor

protected int srcFactor
The source blending factor.


dstFactor

protected int dstFactor
The destination blending factor.

Constructor Detail

BlendOp

public BlendOp(int srcFactor,
               int dstFactor)
Creates a BlendOp that will supply the indicated values to glBlendFunc. The indicated values should be one of the appropriate GL symbolic constants (GL_ONE, GL_SRC_ALPHA, etc).

Parameters:
srcFactor - The value to multiply source pixels by.
dstFactor - The value to multiply the destination pixels by.
Method Detail

set

public void set(BlendOp blend)
Defines the BlendOp to have the same blending settings as another.

Parameters:
blend - The BlendOp to copy.

setSrcFactor

public void setSrcFactor(int srcFactor)
Redefines the value to use for source pixel blending.

Parameters:
srcFactor - The new value to multiply pixels by.

srcFactor

public int srcFactor()
Accessed a value used to blend.

Returns:
The source color blending factor.

setDstFactor

public void setDstFactor(int dstFactor)
Redefines the value to use for destination pixel blending.

Parameters:
srcFactor - The new value to multiply pixels by.

dstFactor

public int dstFactor()
Accessed a value used to blend.

Returns:
The destination color blending factor.

bind

public void bind()
Pushes the current color settings (including blending) onto the stack and then sets the new blending factors.

Specified by:
bind in interface GLTransform

release

public void release()
Pops the attribute stack. If the order of popping and pushing is being taken care of, this should pop the color settings initially placed on the stack, and everything should return to the previous settings.

Specified by:
release in interface GLTransform

equals

public boolean equals(java.lang.Object object)
As equals(), but if the supplied object is a BlendOp, it checks to see if their blending factors are the same.

Overrides:
equals in class java.lang.Object
Parameters:
object - The java Object to check against.
Returns:
Whether or not the two objects are identical or equivalent.