Class RenderState
- All Implemented Interfaces:
Savable
- Direct Known Subclasses:
BlendState
,ClipState
,ColorMaskState
,CullState
,FogState
,FragmentProgramState
,GLSLShaderObjectsState
,LightState
,MaterialState
,OffsetState
,ShadingState
,StencilState
,TextureState
,VertexProgramState
,WireframeState
,ZBufferState
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 can affect its
children and it is OK to assign to more than one Spatial the same render state.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EnumSet
<RenderState.StateType> If false, each renderstate of that type is always applied in the renderer and only field by field checks are done to minimize jni overhead. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RenderState
abstract StateRecord
extract
(Stack<? extends RenderState> stack, Spatial spat) Extracts from the stack the correct renderstate that should apply to the given spatial.Class
<? extends RenderState> abstract RenderState.StateType
getType()
boolean
Returns if this render state is enabled during rendering.boolean
void
read
(InputCapsule capsule) void
setEnabled
(boolean value) Sets if this render state is enabled during rendering.void
setNeedsRefresh
(boolean refresh) This should be called by states when it knows internal data has been altered.static void
setQuickCompares
(boolean enabled) void
write
(OutputCapsule capsule)
-
Field Details
-
_quickCompare
If false, each renderstate of that type is always applied in the renderer and only field by field checks are done to minimize jni overhead. This is slower than setting to true, but relieves the programmer from situations where he has to remember to update the needsRefresh field of a state.
If true, each renderstate of that type is checked for == with the last applied renderstate of the same type. If same and the state's needsRefresh method returns false, then application of the renderstate is skipped. This can be much faster than setting false, but in certain circumstances, the programmer must manually set needsRefresh (for example, in a FogState, if you call getFogColor().set(....) to change the color, the fogstate will not set the needsRefresh field. In non-quick compare mode, this is not a problem because it will go into the apply method and do an actual check of the current fog color in opengl vs. the color in the state being applied.)
DEFAULTS:
- Blend: true
- Fog: true
- Light: false - because you can change a light object directly without telling the state
- Material: true
- Shading: true
- Texture: false - because you can change a texture object directly without telling the state
- Wireframe: false - because line attributes can change when drawing regular lines, affecting wireframe lines
- ZBuffer: true
- Cull: true
- VertexShader1: true
- FragmentShader1: true
- Stencil: false
- GLSLShader: true
- ColorMask: true
- Clip: true
- Offset: true
-
-
Constructor Details
-
RenderState
public RenderState()Constructs a new RenderState. The state is enabled by default.
-
-
Method Details
-
getType
- Returns:
- An statetype enum value for the subclass.
- See Also:
-
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.
-
extract
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.
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-
createStateRecord
-
needsRefresh
public boolean needsRefresh()- Returns:
- true if we should apply this state even if we think it is the current state of its type in the current context. Is reset to false after apply is finished.
-
setNeedsRefresh
public void setNeedsRefresh(boolean refresh) This should be called by states when it knows internal data has been altered.- Parameters:
refresh
- true if we should apply this state even if we think it is the current state of its type in the current context.
-
setQuickCompares
public static void setQuickCompares(boolean enabled) - Parameters:
enabled
-true
to enable the quick compares- See Also:
-
createState
-