Package com.ardor3d.util
Class TextureKey
java.lang.Object
com.ardor3d.util.TextureKey
- All Implemented Interfaces:
Savable
TextureKey
provides a way for the TextureManager to cache and retrieve Texture
objects.-
Field Summary
Modifier and TypeFieldDescriptionprotected int
cached hashcode value.protected boolean
Whether we had asked the loader of the image to flip vertically.protected TextureStoreFormat
The stored format of our image.protected String
An optional id, used to differentiate keys where the rest of the values are the same.protected final ContextIdReference
<TextureKey> cache of OpenGL context specific texture ids for the associated texture.protected static final List
<WeakReference<TextureKey>> cache of texturekey objects allowing us to find an existing texture key.protected Texture.MinificationFilter
The minification filter used on our texture (generally determines what mipmaps are created - if any - and how.)protected ResourceSource
The source of the image used in this Texture. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
clearKey
(TextureKey key) boolean
Class
<? extends TextureKey> getId()
static TextureKey
getKey
(ResourceSource source, boolean flipped, TextureStoreFormat storeFormat, Texture.MinificationFilter minFilter) static TextureKey
getKey
(ResourceSource source, boolean flipped, TextureStoreFormat storeFormat, String id, Texture.MinificationFilter minFilter) static TextureKey
getRTTKey
(Texture.MinificationFilter minFilter) Get a new unique TextureKey.getTextureIdForContext
(Object glContext) int
hashCode()
static TextureKey
DO NOT USE.boolean
boolean
void
read
(InputCapsule capsule) void
Clears all currently associated texture ids for this texture.void
removeFromIdCache
(Object glContext) Removes any texture id for this texture for the given OpenGL context.void
void
setDirty()
void
setTextureIdForContext
(Object glContext, int textureId) Sets the id for a texture in regards to the given OpenGL context.toString()
void
write
(OutputCapsule capsule)
-
Field Details
-
_source
The source of the image used in this Texture. -
_flipped
protected boolean _flippedWhether we had asked the loader of the image to flip vertically. -
_format
The stored format of our image. -
_id
An optional id, used to differentiate keys where the rest of the values are the same. RTT operations are a good example. -
_minFilter
The minification filter used on our texture (generally determines what mipmaps are created - if any - and how.) -
_idCache
cache of OpenGL context specific texture ids for the associated texture. -
_code
protected transient int _codecached hashcode value. -
_keyCache
cache of texturekey objects allowing us to find an existing texture key.
-
-
Constructor Details
-
TextureKey
protected TextureKey()DO NOT USE. FOR INTERNAL USE ONLY
-
-
Method Details
-
initSavable
DO NOT USE. FOR INTERNAL USE ONLY- Returns:
- the texture key
-
setDirty
public void setDirty() -
isDirty
-
setClean
-
getRTTKey
Get a new unique TextureKey. This is meant for use by RTT and other situations where we know we are making a unique texture.- Parameters:
minFilter
- our minification filter value.- Returns:
- the new TextureKey
-
getKey
public static TextureKey getKey(ResourceSource source, boolean flipped, TextureStoreFormat storeFormat, Texture.MinificationFilter minFilter) -
getKey
public static TextureKey getKey(ResourceSource source, boolean flipped, TextureStoreFormat storeFormat, String id, Texture.MinificationFilter minFilter) -
clearKey
-
getTextureIdForContext
- Parameters:
glContext
- the object representing the OpenGL context a texture belongs to. SeeRenderContext.getGlContextRep()
- Returns:
- the texture id of a texture in the given context. If the texture is not found in the given context, 0 is returned.
-
getContextObjects
- Returns:
- a Set of context objects that currently reference this texture.
-
removeFromIdCache
Removes any texture id for this texture for the given OpenGL context.
Note: This does not remove the texture from the card and is provided for use by code that does remove textures from the card.
- Parameters:
glContext
- the object representing the OpenGL context this texture belongs to. SeeRenderContext.getGlContextRep()
-
removeFromIdCache
public void removeFromIdCache()Clears all currently associated texture ids for this texture.
Note: This does not remove the texture from the card and is provided for use by code that does remove textures from the card.
-
setTextureIdForContext
Sets the id for a texture in regards to the given OpenGL context.- Parameters:
glContext
- the object representing the OpenGL context a texture belongs to. SeeRenderContext.getGlContextRep()
textureId
- the texture id of a texture. To be valid, this must not be 0.- Throws:
IllegalArgumentException
- if textureId is equal to 0.
-
equals
-
hashCode
public int hashCode() -
getMinificationFilter
-
getFormat
-
isFlipped
public boolean isFlipped()- Returns:
- Returns the flipped.
-
getSource
- Returns:
- Returns the source.
-
getId
-
toString
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-