Package com.ardor3d.renderer.state
Class TextureState
java.lang.Object
com.ardor3d.renderer.state.RenderState
com.ardor3d.renderer.state.TextureState
- All Implemented Interfaces:
Savable
TextureState
maintains a texture state for a given node and it's children. The number of states that a
TextureState can maintain at one time is equal to the number of texture units available on the GPU. It is not within
the scope of this class to generate the texture, and is recommended that TextureManager
be used to
create the Texture objects.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ardor3d.renderer.state.RenderState
RenderState.StateStack, RenderState.StateType
-
Field Summary
Modifier and TypeFieldDescriptionprotected static Texture
The texture(s).static ResourceSource
protected static boolean
static final int
Fields inherited from class com.ardor3d.renderer.state.RenderState
_quickCompare
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes all textures in this texture state.extract
(Stack<? extends RenderState> stack, Spatial spat) Extracts from the stack the correct renderstate that should apply to the given spatial.getCorrectionType
returns the correction mode for the texture state.static Texture
static Image
int
Returns the max index in this TextureState that contains a non-null Texture.int
Returns the number of textures this texture manager is maintaining.getTexture
gets the texture that is assigned to the first texture unit.getTexture
(int textureUnit) getTexture
retrieves the texture being used by the state in a particular texture unit.final TextureKey
getTextureKey
(int textureUnit) Fast access for retrieving a TextureKey.getType()
void
read
(InputCapsule capsule) boolean
removeTexture
(int textureUnit) boolean
removeTexture
(Texture tex) void
setCorrectionType
sets the image correction type for this texture state.void
setTexture
(Texture texture) setTexture
sets a single texture to the first texture unit.void
setTexture
(Texture texture, int textureUnit) setTexture
sets the texture object to be used by the state.void
write
(OutputCapsule capsule) Methods inherited from class com.ardor3d.renderer.state.RenderState
createState, getClassTag, isEnabled, needsRefresh, setEnabled, setNeedsRefresh, setQuickCompares
-
Field Details
-
MAX_TEXTURES
public static final int MAX_TEXTURES- See Also:
-
_defaultTexture
-
defaultTextureLoaded
protected static boolean defaultTextureLoaded -
_texture
The texture(s). -
_keyCache
-
DEFAULT_TEXTURE_SOURCE
-
-
Constructor Details
-
TextureState
public TextureState()Constructor instantiates a newTextureState
object.
-
-
Method Details
-
getType
- Specified by:
getType
in classRenderState
- Returns:
- An statetype enum value for the subclass.
- See Also:
-
setTexture
setTexture
sets a single texture to the first texture unit.- Parameters:
texture
- the texture to set.
-
getTexture
getTexture
gets the texture that is assigned to the first texture unit.- Returns:
- the texture in the first texture unit.
-
setTexture
setTexture
sets the texture object to be used by the state. The texture unit that this texture uses is set, if the unit is not valid, i.e. less than zero or greater than the number of texture units supported by the graphics card, it is ignored.- Parameters:
texture
- the texture to be used by the state.textureUnit
- the texture unit this texture will fill.
-
getTexture
getTexture
retrieves the texture being used by the state in a particular texture unit.- Parameters:
textureUnit
- the texture unit to retrieve the texture from.- Returns:
- the texture being used by the state. If the texture unit is invalid, null is returned.
-
removeTexture
-
removeTexture
public boolean removeTexture(int textureUnit) -
clearTextures
public void clearTextures()Removes all textures in this texture state. Does not delete them from the graphics card. -
setCorrectionType
setCorrectionType
sets the image correction type for this texture state.- Parameters:
type
- the correction type for this texture.- Throws:
IllegalArgumentException
- if type is null
-
getCorrectionType
getCorrectionType
returns the correction mode for the texture state.- Returns:
- the correction type for the texture state.
-
getNumberOfSetTextures
public int getNumberOfSetTextures()Returns the number of textures this texture manager is maintaining.- Returns:
- the number of textures.
-
getMaxTextureIndexUsed
public int getMaxTextureIndexUsed()Returns the max index in this TextureState that contains a non-null Texture.- Returns:
- the max index, or -1 if no textures are contained by this state.
-
getTextureKey
Fast access for retrieving a TextureKey. A return is guaranteed whentextureUnit
is any number under or equal to the highest texture unit currently in use. This value can be retrieved withgetNumberOfSetTextures
. A higher value might result in unexpected behavior such as an exception being thrown.- Parameters:
textureUnit
- The texture unit from which to retrieve the TextureKey.- Returns:
- the TextureKey, or null if there is none.
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classRenderState
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classRenderState
- Throws:
IOException
-
getDefaultTextureImage
-
getDefaultTexture
-
createStateRecord
- Specified by:
createStateRecord
in classRenderState
-
extract
Description copied from class:RenderState
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.- Overrides:
extract
in classRenderState
- Parameters:
stack
- The stack to extract render states from.spat
- The spatial to apply the render states too.- Returns:
- The render state to use.
-