net.jinx.video.multipass
Class TranslucentPass

java.lang.Object
  extended by net.jinx.video.multipass.TranslucentPass
All Implemented Interfaces:
Pass

public class TranslucentPass
extends java.lang.Object
implements Pass

TranslucentPass is used for drawing objects that are translucent, optionally by using the Painter's Algorithm. This is necessary because translucent objects cannot be drawn properly using the OpenGL Z buffer, so they must instead be sorted using the Painter's Algorithm before drawing them.

The Painter's Algorithm involves drawing objects in order from most distant to closest, just as a painter paints on a canvas. Using the Painter's Algorithm takes O(n log n) time to render n objects, as opposed to O(n); it's not much of a performance hit, but if you're not concerned with things looking absolutely perfect, you can get a higher frame rate by turning this option off.

API Stability: Beta.


Constructor Summary
TranslucentPass()
          This is the same as TranslucentPass(true).
TranslucentPass(boolean paintersMode)
          Constructs a new TranslucentPass.
 
Method Summary
 void addTranslucent(Context c, Translucent t)
          Adds a Translucent to this Pass for use with the Painter's Algorithm.
 void begin(Context c)
          Begins this TranslucentPass by setting the OpenGL depth mask to false.
 void end(Context c)
          Ends this TranslucentPass by setting the OpenGL depth mask to true after any collected Translucent objects are drawn using the Painter's Algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TranslucentPass

public TranslucentPass(boolean paintersMode)
Constructs a new TranslucentPass.

Parameters:
paintersMode - If true, then the Translucent instances submitted for rendering via the addTranslucent(Translucent) method will be drawn in the order specified by the Painter's Algorithm. If false, then they'll be drawn in their natural order.

TranslucentPass

public TranslucentPass()
This is the same as TranslucentPass(true).

Method Detail

begin

public void begin(Context c)
Begins this TranslucentPass by setting the OpenGL depth mask to false.

Specified by:
begin in interface Pass

addTranslucent

public void addTranslucent(Context c,
                           Translucent t)
Adds a Translucent to this Pass for use with the Painter's Algorithm. If the Painter's Algorithm is not being used, then they're drawn immediately.

Throws:
java.lang.IllegalStateException - if this pass has not started.

end

public void end(Context c)
Ends this TranslucentPass by setting the OpenGL depth mask to true after any collected Translucent objects are drawn using the Painter's Algorithm.

Specified by:
end in interface Pass