com.jme.scene.state
Class RenderState

java.lang.Object
  extended bycom.jme.scene.state.RenderState
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AlphaState, AttributeState, CullState, DitherState, FogState, FragmentProgramState, GLSLShaderObjectsState, LightState, MaterialState, ShadeState, StencilState, TextureState, VertexProgramState, WireframeState, ZBufferState

public abstract class RenderState
extends java.lang.Object
implements java.io.Serializable

RenderState is the base class for all states that affect the rendering of a piece of geometry. They aren't created directly, but are created for users from the renderer. The renderstate of a parent affects its children and it is OK to assign to more than one Spatial the same render state.

Version:
$Id: RenderState.java,v 1.22 2005/01/03 19:00:16 renanse Exp $
Author:
Mark Powell, Jack Lindamood (javadoc only)
See Also:
Serialized Form

Field Summary
static int RS_ALPHA
          The value returned by getType() for AlphaState.
static int RS_ATTRIBUTE
          The value returned by getType() for AttributeState.
static int RS_CULL
          The value returned by getType() for CullState.
static int RS_DITHER
          The value returend by getType() for DitherState.
static int RS_FOG
          The value returned by getType() for FogState.
static int RS_FRAGMENT_PROGRAM
          The value returned by getType() for FragmentProgramState.
static int RS_GLSL_SHADER_OBJECTS
          The value returned by getType() for ShaderObjectsState.
static int RS_LIGHT
          The value returned by getType() for LightState.
static int RS_MATERIAL
          The value returend by getType() for MaterialState.
static int RS_MAX_STATE
          The total number of diffrent types of RenderState.
static int RS_SHADE
          The value returned by getType() for ShadeState.
static int RS_STENCIL
          The value returned by getType() for StencilState.
static int RS_TEXTURE
          The value returned by getType() for TextureState.
static int RS_VERTEX_PROGRAM
          The value returned by getType() for VertexProgramState.
static int RS_WIREFRAME
          The value returned by getType() for WireframeState.
static int RS_ZBUFFER
          The value returned by getType() for ZBufferState.
 
Constructor Summary
RenderState()
          Construts a new RenderState.
 
Method Summary
abstract  void apply()
          This function is defined in the RenderState that is actually used by the Renderer.
 RenderState extract(java.util.Stack stack, Spatial spat)
          Extracts from the stack the correct renderstate that should apply to the given spatial.
abstract  int getType()
          Defined by the subclass, this returns an int identifying the renderstate.
 boolean isEnabled()
          Returns if this render state is enabled during rendering.
 void setEnabled(boolean value)
          Sets if this render state is enabled during rendering.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RS_ALPHA

public static final int RS_ALPHA
The value returned by getType() for AlphaState.

See Also:
Constant Field Values

RS_DITHER

public static final int RS_DITHER
The value returend by getType() for DitherState.

See Also:
Constant Field Values

RS_FOG

public static final int RS_FOG
The value returned by getType() for FogState.

See Also:
Constant Field Values

RS_LIGHT

public static final int RS_LIGHT
The value returned by getType() for LightState.

See Also:
Constant Field Values

RS_MATERIAL

public static final int RS_MATERIAL
The value returend by getType() for MaterialState.

See Also:
Constant Field Values

RS_SHADE

public static final int RS_SHADE
The value returned by getType() for ShadeState.

See Also:
Constant Field Values

RS_TEXTURE

public static final int RS_TEXTURE
The value returned by getType() for TextureState.

See Also:
Constant Field Values

RS_WIREFRAME

public static final int RS_WIREFRAME
The value returned by getType() for WireframeState.

See Also:
Constant Field Values

RS_ZBUFFER

public static final int RS_ZBUFFER
The value returned by getType() for ZBufferState.

See Also:
Constant Field Values

RS_CULL

public static final int RS_CULL
The value returned by getType() for CullState.

See Also:
Constant Field Values

RS_VERTEX_PROGRAM

public static final int RS_VERTEX_PROGRAM
The value returned by getType() for VertexProgramState.

See Also:
Constant Field Values

RS_FRAGMENT_PROGRAM

public static final int RS_FRAGMENT_PROGRAM
The value returned by getType() for FragmentProgramState.

See Also:
Constant Field Values

RS_ATTRIBUTE

public static final int RS_ATTRIBUTE
The value returned by getType() for AttributeState.

See Also:
Constant Field Values

RS_STENCIL

public static final int RS_STENCIL
The value returned by getType() for StencilState.

See Also:
Constant Field Values

RS_GLSL_SHADER_OBJECTS

public static final int RS_GLSL_SHADER_OBJECTS
The value returned by getType() for ShaderObjectsState.

See Also:
Constant Field Values

RS_MAX_STATE

public static final int RS_MAX_STATE
The total number of diffrent types of RenderState.

See Also:
Constant Field Values
Constructor Detail

RenderState

public RenderState()
Construts a new RenderState. The state is enabled by default.

Method Detail

getType

public abstract int getType()
Defined by the subclass, this returns an int identifying the renderstate. For example, RS_CULL or RS_TEXTURE.

Returns:
An int identifying this render state.

isEnabled

public boolean isEnabled()
Returns if this render state is enabled during rendering. Disabled states are ignored.

Returns:
True if this state is enabled.

setEnabled

public void setEnabled(boolean value)
Sets if this render state is enabled during rendering. Disabled states are ignored.

Parameters:
value - False if the state is to be disabled, true otherwise.

apply

public abstract void apply()
This function is defined in the RenderState that is actually used by the Renderer. It contains the code that, when executed, applies the render state for the given render system. This should only be called internally and not by users directly.


extract

public RenderState extract(java.util.Stack stack,
                           Spatial spat)
Extracts from the stack the correct renderstate that should apply to the given spatial. This is mainly used for RenderStates that can be cumulitive such as TextureState or LightState. By default, the top of the static is returned. This function should not be called by users directly.

Parameters:
stack - The stack to extract render states from.
spat - The spatial to apply the render states too.
Returns:
The render state to use.