org.xith3d.render
Class Renderer

java.lang.Object
  extended by org.xith3d.render.Renderer
Direct Known Subclasses:
DefaultRenderer

public abstract class Renderer
extends java.lang.Object

The Renderer is the main class for managing the transformation from the scene graph to the 3D card. The Renderer is in charge of atom shader sorting, transparency passes, etc.

The actual OpenGL calls are made by the rendering peer which is supplied when the renderer is created. The renderer supports several different modes of operation including offscreen, render to texture, render to image and rendering to screen.


Nested Class Summary
static class Renderer.OpaqueSortingPolicy
           
static class Renderer.TransparentSortingPolicy
           
 
Field Summary
protected static int renderersWorking
           
 
Constructor Summary
Renderer()
           
 
Method Summary
protected abstract  void addCanvas3D(Canvas3D canvas)
          Adds a Canvas3D to the Renderer.
protected abstract  void addPickRequest(PickRequest pickRequest)
          Adds a PickRequest to the Renderer.
protected abstract  RenderPass addRenderPass(int index, RenderPass renderPass)
          Adds a new RenderPass to this Renderer at the given position.
protected abstract  RenderPass addRenderPass(RenderPass renderPass)
          Adds a new RenderPass to this Renderer at the end of the list.
abstract  void addRenderTarget(RenderTarget renderTarget, RenderPass pass)
          Adds a RenderTarget to the Renderer.
abstract  RenderPass addRenderTarget(RenderTarget renderTarget, RenderPassConfig passConfig)
          Adds a RenderTarget to the Renderer.
abstract  void addScenegraphModificationListener(ScenegraphModificationsListener modListener)
          Adds a new ScenegraphModificationListener to the List.
abstract  Canvas3D getCanvas3D(int index)
           
abstract  long getLastFrameId()
           
abstract  int getNumberOfCanvas3Ds()
           
abstract  long getNumRenderedShapes()
           
abstract  long getNumRenderedTriangles()
           
abstract  RenderBinSorter getOpaqueSorter()
           
abstract  Renderer.OpaqueSortingPolicy getOpaqueSortingPolicy()
           
abstract  RenderPass getRenderPass(int index)
           
abstract  java.util.List<RenderPass> getRenderPasses()
           
abstract  java.util.List<RenderPass> getRenderPasses(BranchGroup branchGroup)
           
abstract  int getRenderPassesCount()
           
abstract  java.util.List<RenderTarget> getRenderTargets()
           
abstract  java.util.List<ScenegraphModificationsListener> getScenegraphModificationListeners()
           
abstract  SoundProcessor getSoundProcessor()
          Deprecated. use SoundProcessor.getInstance() instead to set the sound driver.
abstract  RenderBinSorter getTransparentSorter()
           
abstract  Renderer.TransparentSortingPolicy getTransparentSortingPolicy()
           
abstract  boolean isLayeredMode()
           
abstract  boolean isRendering()
           
protected abstract  void removeAllRenderPasses()
          Removes all RenderPasses from this Renderer.
protected abstract  void removeCanvas3D(Canvas3D canvas)
          Removes a Canvas3D from the Renderer.
protected abstract  Canvas3D removeCanvas3D(int i)
          Removes a Canvas3D from the Renderer.
protected abstract  boolean removeRenderPass(int index)
          Removes the RenderPass from this Renderer.
protected abstract  boolean removeRenderPass(RenderPass renderPass)
          Removes the RenderPass from this Renderer.
protected abstract  boolean removeRenderPasses(BranchGroup branchGroup)
          Removes the RenderPass from this Renderer, which is assotiated to the given BranchGroup.
abstract  void removeRenderTarget(RenderTarget renderTarget)
          Removes a RenderTarget from the Renderer.
abstract  void removeScenegraphModificationListener(ScenegraphModificationsListener modListener)
          Removes a ScenegraphModificationListener from the List.
abstract  long renderOnce(Canvas3D canvas, long nanoTime, long nanoStep)
          Renders the next frame to the given Canvas3D.
abstract  long renderOnce(java.util.List<RenderPass> renderPasses, java.util.List<? extends java.util.List<GroupNode>> groupsLists, Canvas3D canvas, long nanoTime, long nanoStep)
          Renders one frame on a specified universe and canvas.
abstract  long renderOnce(long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
abstract  long renderOnce(RenderPass renderPass, Canvas3D canvas, long nanoTime, long nanoStep)
          Renders one frame on a specified universe and canvas.
abstract  long renderOnce(RenderPass renderPass, GroupNode group, Canvas3D canvas, long nanoTime, long nanoStep)
          Renders one frame on a specified universe and canvas.
abstract  long renderOnce(RenderPass renderPass, GroupNode group, long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
abstract  long renderOnce(RenderPass renderPass, long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
abstract  long renderOnce(View view, long nanoTime, long nanoStep)
          Renders a single frame to all Canvas3Ds.
abstract  void setLayeredMode(boolean layeredMode)
          Sets if the rendering is done in layered mode or not.
abstract  void setOpaqueSorter(RenderBinSorter sorter)
          Sets the opaque RenderBinSorter for this Renderer.
abstract  void setOpaqueSortingPolicy(Renderer.OpaqueSortingPolicy policy)
          Sets the opaque sorting policy for this Renderer.
abstract  void setTransparentSorter(RenderBinSorter sorter)
          Sets the transparent RenderBinSorter for this Renderer.
abstract  void setTransparentSortingPolicy(Renderer.TransparentSortingPolicy policy)
          Sets the transparency sorting policy for this Renderer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

renderersWorking

protected static int renderersWorking
Constructor Detail

Renderer

public Renderer()
Method Detail

getSoundProcessor

@Deprecated
public abstract SoundProcessor getSoundProcessor()
Deprecated. use SoundProcessor.getInstance() instead to set the sound driver.


addScenegraphModificationListener

public abstract void addScenegraphModificationListener(ScenegraphModificationsListener modListener)
Adds a new ScenegraphModificationListener to the List. It will be notified of any scenegraph change at runtime.

Parameters:
modListener - the new ScenegraphModificationsListener to add

removeScenegraphModificationListener

public abstract void removeScenegraphModificationListener(ScenegraphModificationsListener modListener)
Removes a ScenegraphModificationListener from the List.

Parameters:
modListener - the ScenegraphModificationsListener to be removed

getScenegraphModificationListeners

public abstract java.util.List<ScenegraphModificationsListener> getScenegraphModificationListeners()
Returns:
a List of all registered ScenegraphModificationListeners

addCanvas3D

protected abstract void addCanvas3D(Canvas3D canvas)
Adds a Canvas3D to the Renderer.

Parameters:
canvas -

removeCanvas3D

protected abstract void removeCanvas3D(Canvas3D canvas)
Removes a Canvas3D from the Renderer.

Parameters:
canvas -

removeCanvas3D

protected abstract Canvas3D removeCanvas3D(int i)
Removes a Canvas3D from the Renderer.

Parameters:
i -
Returns:
the removed Canvas3D

getNumberOfCanvas3Ds

public abstract int getNumberOfCanvas3Ds()
Returns:
the number of Canvas3Ds in this Renderer.

getCanvas3D

public abstract Canvas3D getCanvas3D(int index)
Returns:
the n-th Canvas3D from the Renderer.

addRenderTarget

public abstract void addRenderTarget(RenderTarget renderTarget,
                                     RenderPass pass)
Adds a RenderTarget to the Renderer.

Parameters:
renderTarget -
pass -

addRenderTarget

public abstract RenderPass addRenderTarget(RenderTarget renderTarget,
                                           RenderPassConfig passConfig)
Adds a RenderTarget to the Renderer.

Parameters:
renderTarget -
passConfig -

removeRenderTarget

public abstract void removeRenderTarget(RenderTarget renderTarget)
Removes a RenderTarget from the Renderer.

Parameters:
renderTarget -

getRenderTargets

public abstract java.util.List<RenderTarget> getRenderTargets()
Returns:
a list of all registered RenderTargets.

addRenderPass

protected abstract RenderPass addRenderPass(RenderPass renderPass)
Adds a new RenderPass to this Renderer at the end of the list. In layered rendering mode it is important, that the first added pass will be rendered first and the last added rendered last.

Parameters:
renderPass - the RenderPass to add
Returns:
the given RenderPass object

addRenderPass

protected abstract RenderPass addRenderPass(int index,
                                            RenderPass renderPass)
Adds a new RenderPass to this Renderer at the given position. In layered rendering mode it is important, that the first pass in the list will be rendered first and the last rendered last.

Parameters:
index - the position the RenderPass is to be placed at in the list
renderPass - the RenderPass to add
Returns:
the given RenderPass object

removeRenderPasses

protected abstract boolean removeRenderPasses(BranchGroup branchGroup)
Removes the RenderPass from this Renderer, which is assotiated to the given BranchGroup.

Parameters:
branchGroup - the BranchGroup, which's RenderPass is to be removed
Returns:
true, if the RenderPass existed in the Renderer

removeRenderPass

protected abstract boolean removeRenderPass(RenderPass renderPass)
Removes the RenderPass from this Renderer.

Parameters:
renderPass - the RenderPass to be removed
Returns:
true, if the RenderPass existed in the Renderer

removeRenderPass

protected abstract boolean removeRenderPass(int index)
Removes the RenderPass from this Renderer.

Parameters:
index - the index of the RenderPass to be removed
Returns:
true, if the RenderPass existed in the Renderer

removeAllRenderPasses

protected abstract void removeAllRenderPasses()
Removes all RenderPasses from this Renderer.


getRenderPassesCount

public abstract int getRenderPassesCount()
Returns:
the number of RenderPasses registered in this Renderer.

getRenderPasses

public abstract java.util.List<RenderPass> getRenderPasses(BranchGroup branchGroup)
Parameters:
branchGroup - the BranchGroup the RenderPasses are linked with
Returns:
the List of RenderPasses registered here with this BranchGroup.

getRenderPass

public abstract RenderPass getRenderPass(int index)
Parameters:
index - the index of the desired RenderPass
Returns:
the RenderPass registered here with this index.

getRenderPasses

public abstract java.util.List<RenderPass> getRenderPasses()
Returns:
the list of RenderPasses registered with this Renderer.

setLayeredMode

public abstract void setLayeredMode(boolean layeredMode)
Sets if the rendering is done in layered mode or not.

Parameters:
layeredMode - if true, rendering will be done in layered mode

isLayeredMode

public abstract boolean isLayeredMode()
Returns:
if the rendering is done in layered mode.

setOpaqueSorter

public abstract void setOpaqueSorter(RenderBinSorter sorter)
Sets the opaque RenderBinSorter for this Renderer.
This automatically sets the sorting policy to CUSTOM.

Parameters:
sorter - the RenderBinSorter to use for opaque shapes
See Also:
setOpaqueSortingPolicy(org.xith3d.render.Renderer.OpaqueSortingPolicy)

getOpaqueSorter

public abstract RenderBinSorter getOpaqueSorter()
Returns:
sorter the RenderBinSorter to use for opaque shapes
See Also:
getOpaqueSortingPolicy()

setTransparentSorter

public abstract void setTransparentSorter(RenderBinSorter sorter)
Sets the transparent RenderBinSorter for this Renderer.
This automatically sets the sorting policy to CUSTOM.

Parameters:
sorter - the RenderBinSorter to use for transparent shapes

getTransparentSorter

public abstract RenderBinSorter getTransparentSorter()
Returns:
sorter the RenderBinSorter to use for transparent shapes
See Also:
getTransparentSortingPolicy()

setOpaqueSortingPolicy

public abstract void setOpaqueSortingPolicy(Renderer.OpaqueSortingPolicy policy)
Sets the opaque sorting policy for this Renderer.

Parameters:
policy - the new policy

getOpaqueSortingPolicy

public abstract Renderer.OpaqueSortingPolicy getOpaqueSortingPolicy()
Returns:
the current opaque sorting policy for this Renderer

setTransparentSortingPolicy

public abstract void setTransparentSortingPolicy(Renderer.TransparentSortingPolicy policy)
Sets the transparency sorting policy for this Renderer.

Parameters:
policy - the new policy

getTransparentSortingPolicy

public abstract Renderer.TransparentSortingPolicy getTransparentSortingPolicy()
Returns:
the current transparency sorting policy for this Renderer.

getLastFrameId

public abstract long getLastFrameId()
Returns:
the last used frame-id

addPickRequest

protected abstract void addPickRequest(PickRequest pickRequest)
Adds a PickRequest to the Renderer.
It is handled with the next rendered frame.

Parameters:
pickRequest -

renderOnce

public abstract long renderOnce(java.util.List<RenderPass> renderPasses,
                                java.util.List<? extends java.util.List<GroupNode>> groupsLists,
                                Canvas3D canvas,
                                long nanoTime,
                                long nanoStep)
Renders one frame on a specified universe and canvas.

Parameters:
renderPasses -
groupsLists -
canvas -
nanoTime -
nanoStep -

renderOnce

public abstract long renderOnce(RenderPass renderPass,
                                GroupNode group,
                                Canvas3D canvas,
                                long nanoTime,
                                long nanoStep)
Renders one frame on a specified universe and canvas.

Parameters:
renderPass -
group -
canvas -
nanoTime -
nanoStep -

renderOnce

public abstract long renderOnce(RenderPass renderPass,
                                Canvas3D canvas,
                                long nanoTime,
                                long nanoStep)
Renders one frame on a specified universe and canvas.

Parameters:
renderPass -
canvas -

renderOnce

public abstract long renderOnce(Canvas3D canvas,
                                long nanoTime,
                                long nanoStep)
Renders the next frame to the given Canvas3D.

Parameters:
canvas - the canvas to be rendered

renderOnce

public abstract long renderOnce(View view,
                                long nanoTime,
                                long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.


renderOnce

public abstract long renderOnce(RenderPass renderPass,
                                GroupNode group,
                                long nanoTime,
                                long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.


renderOnce

public abstract long renderOnce(RenderPass renderPass,
                                long nanoTime,
                                long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.


renderOnce

public abstract long renderOnce(long nanoTime,
                                long nanoStep)
Renders a single frame to all Canvas3Ds. This will collect all the renderable atoms and invoke the renderer.


getNumRenderedShapes

public abstract long getNumRenderedShapes()
Returns:
the number of shapes actually being rendered

getNumRenderedTriangles

public abstract long getNumRenderedTriangles()
Returns:
the number of rendered triangles

isRendering

public abstract boolean isRendering()
Returns:
true, if the view is currently rendering a frame