org.xith3d.render
Class RenderPeer

java.lang.Object
  extended by org.xith3d.render.RenderPeer

public abstract class RenderPeer
extends java.lang.Object

The RenderPeer is used to abstract the layer that does the actual drawing from the architecture of the renderer.


Nested Class Summary
static class RenderPeer.RenderMode
           
 
Field Summary
protected  boolean backgroundCachingEnabled
           
protected  float[] clearColor
           
protected  int colorMask
           
protected  boolean disableClearBuffer
          disableClearBuffer set to true if application does not want renderer to clear any buffers
protected  boolean forceNoSwap
           
protected  boolean fullOverpaint
          fullOverpaint set to true if client guarantees that all the screen always completely painted and no reason to clear color buffer
protected  java.nio.IntBuffer selectBuffer
           
 
Constructor Summary
RenderPeer(CanvasPeer canvasPeer, StateUnitPeerRegistry shaderRegistry, OpenGLStatesCache statesCache)
           
RenderPeer(CanvasPeer canvasPeer, StateUnitPeerRegistry shaderRegistry, OpenGLStatesCache statesCache, RenderOptions renderOptions)
           
 
Method Summary
protected static void checkGCRequested()
           
protected  java.lang.Object convertSelectBuffer(int hits, java.util.List<RenderPass> renderPasses, boolean pickAll)
          Convert select buffer to List.
 void forceState(int stateType)
           
protected  RenderAtom<?> getAtomByGlobalIndex(int index, java.util.List<RenderPass> renderPasses)
           
 CanvasPeer getCanvasPeer()
           
 PickResult getPickResult()
           
 java.util.List<PickResult> getPickResults()
           
 RenderOptions getRenderOptions()
           
 StateUnitPeerRegistry getShaderRegistry()
           
 OpenGLStatesCache getStatesCache()
           
abstract  java.lang.Object render(java.lang.Object glObj, View view, java.util.List<RenderPass> renderPasses, boolean layeredMode, long frameId, long nanoTime, long nanoStep, PickRequest pickRequest)
          Renders a single frame using the View and RenderBins provided in the RenderPasses object.
 int renderAtom(RenderAtom<?> atom, java.lang.Object glObj, CanvasPeer canvasPeer, OpenGLCapabilities glCaps, OpenGLStatesCache statesCache, View view, RenderOptions options, long nanoTime, long nanoStep, RenderPeer.RenderMode renderMode, long frameId)
          Renders an Atom.
protected  void renderDone(long frameId)
          The frame is complete.
protected  void renderStart(PickRequest pickRequest)
           
protected  void resetStateUnitStateArrays()
          Called when begining a new frame to draw.
 void setBackgroundCachingEnabled(boolean enabled)
          Sets flag that enables caching of the background in buffer region.
protected  void setCanvasPeer(CanvasPeer canvasPeer)
           
 void setClearColor(float r, float g, float b, float a)
          Sets the color with which to clear the screen before each frame.
 void setColorMask(boolean enableRed, boolean enableGreen, boolean enableBlue, boolean enableAlpha)
          Sets the colormask for the rendering
 void setDisableClearBuffer(boolean val)
          Disables or enables buffer clear operations.
 void setForceNoSwap(boolean forceNoSwap)
           
 void setFullOverpaint(boolean val)
          Sets "Full Overpaint" flag.
protected static void setGCRequested(boolean gcReq)
           
 void setRenderOptions(RenderOptions renderOptions)
          Sets the rendering options that this RenderPeer will abide by.
abstract  void takeScreenshot(java.io.File file, boolean alpha)
          Takes a screenshot of the current rendering
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

forceNoSwap

protected boolean forceNoSwap

disableClearBuffer

protected boolean disableClearBuffer
disableClearBuffer set to true if application does not want renderer to clear any buffers


fullOverpaint

protected boolean fullOverpaint
fullOverpaint set to true if client guarantees that all the screen always completely painted and no reason to clear color buffer


clearColor

protected float[] clearColor

colorMask

protected int colorMask

backgroundCachingEnabled

protected boolean backgroundCachingEnabled

selectBuffer

protected java.nio.IntBuffer selectBuffer
Constructor Detail

RenderPeer

public RenderPeer(CanvasPeer canvasPeer,
                  StateUnitPeerRegistry shaderRegistry,
                  OpenGLStatesCache statesCache,
                  RenderOptions renderOptions)

RenderPeer

public RenderPeer(CanvasPeer canvasPeer,
                  StateUnitPeerRegistry shaderRegistry,
                  OpenGLStatesCache statesCache)
Method Detail

setGCRequested

protected static void setGCRequested(boolean gcReq)

checkGCRequested

protected static final void checkGCRequested()

setCanvasPeer

protected void setCanvasPeer(CanvasPeer canvasPeer)

getCanvasPeer

public final CanvasPeer getCanvasPeer()

getShaderRegistry

public final StateUnitPeerRegistry getShaderRegistry()
Returns:
the ShaderRegistry, which is responsible for the Shader handling.

setRenderOptions

public void setRenderOptions(RenderOptions renderOptions)
Sets the rendering options that this RenderPeer will abide by.

Parameters:
renderOptions - the rendering options, that this RenderPeer will abide by.

getRenderOptions

public final RenderOptions getRenderOptions()
Returns:
the rendering options that this CanvasPeer abides by.

getStatesCache

public final OpenGLStatesCache getStatesCache()
Returns:
the OpenGLStatesCache of this render context.

setClearColor

public final void setClearColor(float r,
                                float g,
                                float b,
                                float a)
Sets the color with which to clear the screen before each frame.

Parameters:
r - the red component
g - the green component
b - the blue component
a - the alpha component

setDisableClearBuffer

public final void setDisableClearBuffer(boolean val)
Disables or enables buffer clear operations. If DisableClearBuffer set to true, client guarantees that all it will take care of correct frame buffer clearing/filling. This may provide speedups for example in cases where multiple transparent objects rebdered over opaque background, and depth buffer testing/writing disabled. Default value for DisableClearBuffer flag is false.

Parameters:
val - New value for DisableClearBuffer flag

setFullOverpaint

public final void setFullOverpaint(boolean val)
Sets "Full Overpaint" flag. If Full Overpaint set to true, client guarantees that all the screen always completely painted and no reason to clear color buffer Default value for "Full Overpaint" flag is false.

Parameters:
val - New value for "Full Overpaint" flag

setForceNoSwap

public final void setForceNoSwap(boolean forceNoSwap)

setColorMask

public final void setColorMask(boolean enableRed,
                               boolean enableGreen,
                               boolean enableBlue,
                               boolean enableAlpha)
Sets the colormask for the rendering

Parameters:
enableRed -
enableGreen -
enableBlue -
enableAlpha -

setBackgroundCachingEnabled

public void setBackgroundCachingEnabled(boolean enabled)
Sets flag that enables caching of the background in buffer region.

Parameters:
enabled - New value for background cache enable/disable flag

resetStateUnitStateArrays

protected final void resetStateUnitStateArrays()
Called when begining a new frame to draw. It fills up the state and shader arrays.


renderStart

protected void renderStart(PickRequest pickRequest)

forceState

public final void forceState(int stateType)

renderAtom

public final int renderAtom(RenderAtom<?> atom,
                            java.lang.Object glObj,
                            CanvasPeer canvasPeer,
                            OpenGLCapabilities glCaps,
                            OpenGLStatesCache statesCache,
                            View view,
                            RenderOptions options,
                            long nanoTime,
                            long nanoStep,
                            RenderPeer.RenderMode renderMode,
                            long frameId)
Renders an Atom.

Parameters:
options -
atom -
view -
frameId -
Returns:
the number of rendered Triangles

getPickResults

public final java.util.List<PickResult> getPickResults()

getPickResult

public final PickResult getPickResult()

getAtomByGlobalIndex

protected final RenderAtom<?> getAtomByGlobalIndex(int index,
                                                   java.util.List<RenderPass> renderPasses)

convertSelectBuffer

protected final java.lang.Object convertSelectBuffer(int hits,
                                                     java.util.List<RenderPass> renderPasses,
                                                     boolean pickAll)
Convert select buffer to List.


renderDone

protected final void renderDone(long frameId)
The frame is complete. The implementation should return as fast as possible, so possibly another thread should be used to wait for the drawing to be complete.


render

public abstract java.lang.Object render(java.lang.Object glObj,
                                        View view,
                                        java.util.List<RenderPass> renderPasses,
                                        boolean layeredMode,
                                        long frameId,
                                        long nanoTime,
                                        long nanoStep,
                                        PickRequest pickRequest)
Renders a single frame using the View and RenderBins provided in the RenderPasses object.

Parameters:
glObj - the OpenGL handle object
view - the View used to render
renderPasses - the List of RenderPasses to iterate and render
layeredMode - if true, the RenderPasses are handled in layered mode
frameId - the current frame's id
pickRequest - null for normal rendering

takeScreenshot

public abstract void takeScreenshot(java.io.File file,
                                    boolean alpha)
Takes a screenshot of the current rendering

Parameters:
file - the file to save the screenshot to
alpha - with alpha channel?