com.jme.renderer
Interface Renderer

All Known Implementing Classes:
LWJGLRenderer

public interface Renderer

Renderer defines an interface that handles displaying of graphics data to the context. Creation of this object is typically handled via a call to a DisplaySystem subclass. All rendering state and tasks can be handled through this interface. Example Usage:
NOTE: This example uses the DisplaySystem class to obtain the Renderer. DisplaySystem ds = new LWJGLDisplaySystem();
ds.createWindow(640,480,16,60,false);
Renderer r = ds.getRenderer();
r.draw(point);

Version:
$Id: Renderer.java,v 1.51 2005/04/05 23:45:47 renanse Exp $
Author:
Mark Powell
See Also:
DisplaySystem

Field Summary
static int QUEUE_INHERIT
          The Spatial will inherit its render queue state from its parent.
static int QUEUE_OPAQUE
          The Spatial will render in the opaque bucket.
static int QUEUE_ORTHO
          The Spatial will render in the ortho bucket.
static int QUEUE_SKIP
          The Spatial will skip render queueing.
static int QUEUE_TRANSPARENT
          The Spatial will render in the transparent bucket.
 
Method Summary
 boolean checkAndAdd(Spatial s)
          Check a given Spatial to see if it should be queued.
 void clearBuffers()
          clearBuffers clears both the depth buffer and the back buffer.
 void clearColorBuffer()
          clearBackBuffer clears the back buffer of the renderer.
 void clearStatistics()
          Reset rendering tracking statistical information.
 void clearStrictBuffers()
          clearBuffers clears both the depth buffer and the back buffer restricting the clear to the rectangle defined by the width and height of the renderer.
 void clearZBuffer()
          clearZBuffer clears the depth buffer of the renderer.
 AlphaState createAlphaState()
          createAlphaState retrieves the alpha state object for the proper renderer.
 AttributeState createAttributeState()
          createAttributeState retrieves the attribute saving state object for the proper renderer.
 Camera createCamera(int width, int height)
          createCamera retrieves a default camera for this renderer.
 CullState createCullState()
          createCullState retrieves the cull state object for the proper renderer.
 DitherState createDitherState()
          createDitherState retrieves the dither state object for the proper renderer.
 FogState createFogState()
          createFogState retrieves the fog state object for the proper renderer.
 FragmentProgramState createFragmentProgramState()
          Retrieves the fragment program state object for the proper renderer.
 GLSLShaderObjectsState createGLSLShaderObjectsState()
          createShaderObjectsState retrieves the shader object state object for the proper renderer.
 LightState createLightState()
          createLightState retrieves the light state object for the proper renderer.
 MaterialState createMaterialState()
          createMaterialState retrieves the material state object for the proper renderer.
 ShadeState createShadeState()
          createShadeState retrieves the shade state object for the proper renderer.
 StencilState createStencilState()
          Retrieves the stencil state object for the proper renderer.
 TextureState createTextureState()
          createTextureState retrieves the texture state object for the proper renderer.
 VertexProgramState createVertexProgramState()
          Retrieves the vertex program state object for the proper renderer.
 WireframeState createWireframeState()
          createWireframeState retrieves the wireframe state object for the proper renderer.
 ZBufferState createZBufferState()
          Retrieves the Z buffer state object for the proper renderer.
 void displayBackBuffer()
          displayBackBuffer swaps the back buffer with the currently displayed buffer.
 void draw(CompositeMesh c)
          draw renders a composite mesh to the back buffer.
 void draw(Curve c)
          draw renders a curve to the back buffer.
 void draw(Line l)
          draw renders a line to the back buffer.
 void draw(Point p)
          draw renders a single point to the back buffer.
 void draw(Spatial s)
          draw renders a scene.
 void draw(Text t)
          draw renders text to the back buffer.
 void draw(TriMesh t)
          draw renders a triangle mesh to the back buffer.
 void draw(WidgetRenderer wr)
          draw renders a Widget that is associated with the WidgetRenderer object to the back buffer.
 void drawBounds(BoundingVolume bv)
          drawBounds renders the bounds of a Geometry.
 void drawBounds(Geometry g)
          drawBounds renders the bounds of a Geometry.
 void drawBounds(Spatial s)
          drawBounds renders the bounds of a Geometry.
 void enableStatistics(boolean value)
          If true, statistical upkeep of information is done during rendering.
 ColorRGBA getBackgroundColor()
          getBackgroundColor retrieves the color used for the window background.
 Camera getCamera()
          createCamera retrieves the camera this renderer is using.
 int getHeight()
          Retrieve the height set on this renderer.
 RenderQueue getQueue()
          Get the render queue associated with this Renderer.
 java.lang.String getStatistics()
          Returns statistical data as a String.
 java.lang.StringBuffer getStatistics(java.lang.StringBuffer a)
          Stores the statistical data into the passed string buffer and returns a when finished.
 int getWidth()
          Retrieve the width set on this renderer.
 void grabScreenContents(java.nio.IntBuffer buff, int x, int y, int w, int h)
          grabScreenContents reads a block of pixels from the current framebuffer.
 boolean isHeadless()
          Returns true if the renderer is running in Headless mode (ie.
 boolean isProcessingQueue()
          Return true if this renderer is in the middle of processing its RenderQueue.
 void reinit(int width, int height)
          Reinitialize the renderer with the given width/height.
 void setBackgroundColor(ColorRGBA c)
          setBackgroundColor sets the color of window.
 void setCamera(Camera camera)
          setCamera sets the reference to the applications camera object.
 void setHeadless(boolean headless)
          Set if the renderer is running in Headless mode.
 void setOrtho()
          setOrtho sets the display system to be in orthographic mode.
 void setOrthoCenter()
          setOrthoCenter sets the display system to be in orthographic mode.
 boolean supportsVBO()
          Return true if the system running this supports VBO
 boolean takeScreenShot(java.lang.String filename)
          takeScreenShot saves the current buffer to a png file.
 void unsetOrtho()
          unsetOrhto unsets the display system from orthographic mode back into regular projection mode.
 

Field Detail

QUEUE_INHERIT

public static final int QUEUE_INHERIT
The Spatial will inherit its render queue state from its parent.

See Also:
Constant Field Values

QUEUE_SKIP

public static final int QUEUE_SKIP
The Spatial will skip render queueing.

See Also:
Constant Field Values

QUEUE_OPAQUE

public static final int QUEUE_OPAQUE
The Spatial will render in the opaque bucket.

See Also:
Constant Field Values

QUEUE_TRANSPARENT

public static final int QUEUE_TRANSPARENT
The Spatial will render in the transparent bucket.

See Also:
Constant Field Values

QUEUE_ORTHO

public static final int QUEUE_ORTHO
The Spatial will render in the ortho bucket.

See Also:
Constant Field Values
Method Detail

setCamera

public void setCamera(Camera camera)
setCamera sets the reference to the applications camera object.

Parameters:
camera - the camera object to use with this Renderer.

getCamera

public Camera getCamera()
createCamera retrieves the camera this renderer is using.

Returns:
the camera this renderer is using.

createCamera

public Camera createCamera(int width,
                           int height)
createCamera retrieves a default camera for this renderer.

Parameters:
width - the width of the frame.
height - the height of the frame.
Returns:
a default camera for this renderer.

createAlphaState

public AlphaState createAlphaState()
createAlphaState retrieves the alpha state object for the proper renderer.

Returns:
the AlphaState object that can make use of the proper renderer.

createAttributeState

public AttributeState createAttributeState()
createAttributeState retrieves the attribute saving state object for the proper renderer.

Returns:
the AttributeState object that can make use of the proper renderer.

createCullState

public CullState createCullState()
createCullState retrieves the cull state object for the proper renderer.

Returns:
the CullState object that can make use of the proper renderer.

createDitherState

public DitherState createDitherState()
createDitherState retrieves the dither state object for the proper renderer.

Returns:
the DitherState object that can make use of the proper renderer.

createFogState

public FogState createFogState()
createFogState retrieves the fog state object for the proper renderer.

Returns:
the FogState object that can make use of the proper renderer.

createLightState

public LightState createLightState()
createLightState retrieves the light state object for the proper renderer.

Returns:
the LightState object that can make use of the proper renderer.

createMaterialState

public MaterialState createMaterialState()
createMaterialState retrieves the material state object for the proper renderer.

Returns:
the MaterialState object that can make use of the proper renderer.

createShadeState

public ShadeState createShadeState()
createShadeState retrieves the shade state object for the proper renderer.

Returns:
the ShadeState object that can make use of the proper renderer.

createTextureState

public TextureState createTextureState()
createTextureState retrieves the texture state object for the proper renderer.

Returns:
the TextureState object that can make use of the proper renderer.

createWireframeState

public WireframeState createWireframeState()
createWireframeState retrieves the wireframe state object for the proper renderer.

Returns:
the WireframeState object that can make use of the proper renderer.

createZBufferState

public ZBufferState createZBufferState()
Retrieves the Z buffer state object for the proper renderer.

Returns:
The ZBufferState object that can make use of the proper renderer.

createVertexProgramState

public VertexProgramState createVertexProgramState()
Retrieves the vertex program state object for the proper renderer.

Returns:
The VertexProgramState object that can make use of the proper renderer.

createFragmentProgramState

public FragmentProgramState createFragmentProgramState()
Retrieves the fragment program state object for the proper renderer.

Returns:
The VertexProgramState object that can make use of the proper renderer.

createGLSLShaderObjectsState

public GLSLShaderObjectsState createGLSLShaderObjectsState()
createShaderObjectsState retrieves the shader object state object for the proper renderer.

Returns:
the ShaderObjectsState object that can make use of the proper renderer.

createStencilState

public StencilState createStencilState()
Retrieves the stencil state object for the proper renderer.

Returns:
The StencilState object that can make use of the proper renderer.

enableStatistics

public void enableStatistics(boolean value)
If true, statistical upkeep of information is done during rendering.

Parameters:
value - Should the renderer keep track of statistical information?

clearStatistics

public void clearStatistics()
Reset rendering tracking statistical information.


getStatistics

public java.lang.String getStatistics()
Returns statistical data as a String. The data is renderer specific but usually contains triangle and vertex counts at a minimum.

Returns:
Statistical data for the renderer.

getStatistics

public java.lang.StringBuffer getStatistics(java.lang.StringBuffer a)
Stores the statistical data into the passed string buffer and returns a when finished. This is a more efficient version of getStatistics. Previous information in the StringBuffer is lost.

Parameters:
a - The string buffer to store the result in.
Returns:
The string buffer a, after storage.

setBackgroundColor

public void setBackgroundColor(ColorRGBA c)
setBackgroundColor sets the color of window. This color will be shown for any pixel that is not set via typical rendering operations.

Parameters:
c - the color to set the background to.

getBackgroundColor

public ColorRGBA getBackgroundColor()
getBackgroundColor retrieves the color used for the window background.

Returns:
the background color that is currently set to the background.

clearZBuffer

public void clearZBuffer()
clearZBuffer clears the depth buffer of the renderer. The Z buffer allows sorting of pixels by depth or distance from the view port. Clearing this buffer prepares it for the next frame.


clearColorBuffer

public void clearColorBuffer()
clearBackBuffer clears the back buffer of the renderer. The backbuffer is the buffer being rendered to before it is displayed to the screen. Clearing this buffer frees it for rendering the next frame.


clearBuffers

public void clearBuffers()
clearBuffers clears both the depth buffer and the back buffer.


clearStrictBuffers

public void clearStrictBuffers()
clearBuffers clears both the depth buffer and the back buffer restricting the clear to the rectangle defined by the width and height of the renderer.


displayBackBuffer

public void displayBackBuffer()
displayBackBuffer swaps the back buffer with the currently displayed buffer. Swapping (page flipping) allows the renderer to display a prerenderer display without any flickering.


setOrtho

public void setOrtho()
setOrtho sets the display system to be in orthographic mode. If the system has already been set to orthographic mode a JmeException is thrown. The origin (0,0) is the bottom left of the screen.


setOrthoCenter

public void setOrthoCenter()
setOrthoCenter sets the display system to be in orthographic mode. If the system has already been set to orthographic mode a JmeException is thrown. The origin (0,0) is the center of the screen.


unsetOrtho

public void unsetOrtho()
unsetOrhto unsets the display system from orthographic mode back into regular projection mode. If the system is not in orthographic mode a JmeException is thrown.


takeScreenShot

public boolean takeScreenShot(java.lang.String filename)
takeScreenShot saves the current buffer to a png file. The filename is provided, .png will be appended to the end of the name.

Parameters:
filename - the name of the screenshot file.
Returns:
true if the screen capture was successful, false otherwise.

grabScreenContents

public void grabScreenContents(java.nio.IntBuffer buff,
                               int x,
                               int y,
                               int w,
                               int h)
grabScreenContents reads a block of pixels from the current framebuffer.

Parameters:
buff - a buffer to store contents in.
x - - x starting point of block
y - - y starting point of block
w - - width of block
h - - height of block

draw

public void draw(Spatial s)
draw renders a scene. As it recieves a base class of Spatial the renderer hands off management of the scene to spatial for it to determine when a Geometry leaf is reached.

Parameters:
s - the scene to render.

drawBounds

public void drawBounds(Spatial s)
drawBounds renders the bounds of a Geometry. As it recieves a base class of Geometry the renderer hands off management of the scene to spatial for it to determine when a Geometry leaf is reached.

Parameters:
s - the Spatial to render bounds for.

drawBounds

public void drawBounds(BoundingVolume bv)
drawBounds renders the bounds of a Geometry. As it recieves a base class of BoundingVolume the renderer hands off management of the scene to spatial for it to determine when a Geometry leaf is reached.

Parameters:
bv - the BoundingVolume to render.

drawBounds

public void drawBounds(Geometry g)
drawBounds renders the bounds of a Geometry. As it recieves a base class of Geometry the renderer hands off management of the scene to spatial for it to determine when a Geometry leaf is reached.

Parameters:
g - the Geometry to render.

draw

public void draw(Point p)
draw renders a single point to the back buffer.

Parameters:
p - the point to be rendered.

draw

public void draw(Line l)
draw renders a line to the back buffer.

Parameters:
l - the line to be rendered.

draw

public void draw(Curve c)
draw renders a curve to the back buffer.

Parameters:
c - the curve to be rendered.

draw

public void draw(Text t)
draw renders text to the back buffer.

Parameters:
t - the text object to be rendered.

draw

public void draw(TriMesh t)
draw renders a triangle mesh to the back buffer.

Parameters:
t - the mesh to be rendered.

draw

public void draw(CompositeMesh c)
draw renders a composite mesh to the back buffer.


draw

public void draw(WidgetRenderer wr)
draw renders a Widget that is associated with the WidgetRenderer object to the back buffer.

Parameters:
wr - the WidgetPanel to be rendered.

getQueue

public RenderQueue getQueue()
Get the render queue associated with this Renderer.

Returns:
RenderQueue

isProcessingQueue

public boolean isProcessingQueue()
Return true if this renderer is in the middle of processing its RenderQueue.

Returns:
boolean

checkAndAdd

public boolean checkAndAdd(Spatial s)
Check a given Spatial to see if it should be queued. return true if it was queued.

Parameters:
s - Spatial to check
Returns:
true if it was queued.

supportsVBO

public boolean supportsVBO()
Return true if the system running this supports VBO

Returns:
boolean

isHeadless

public boolean isHeadless()
Returns true if the renderer is running in Headless mode (ie. it renders only to a non-visible context.)

Returns:
boolean

setHeadless

public void setHeadless(boolean headless)
Set if the renderer is running in Headless mode. Some renderers may not provide support for this mode.

Parameters:
headless - boolean

getWidth

public int getWidth()
Retrieve the width set on this renderer.

Returns:
width

getHeight

public int getHeight()
Retrieve the height set on this renderer.

Returns:
height

reinit

public void reinit(int width,
                   int height)
Reinitialize the renderer with the given width/height. Also calls resize on the attached camera if present.

Parameters:
width - int
height - int