Class TextureKey

java.lang.Object
com.ardor3d.util.TextureKey
All Implemented Interfaces:
Savable

public final class TextureKey extends Object implements Savable
TextureKey provides a way for the TextureManager to cache and retrieve Texture objects.
  • Field Details

    • _source

      protected ResourceSource _source
      The source of the image used in this Texture.
    • _flipped

      protected boolean _flipped
      Whether we had asked the loader of the image to flip vertically.
    • _format

      protected TextureStoreFormat _format
      The stored format of our image.
    • _id

      protected String _id
      An optional id, used to differentiate keys where the rest of the values are the same. RTT operations are a good example.
    • _minFilter

      protected Texture.MinificationFilter _minFilter
      The minification filter used on our texture (generally determines what mipmaps are created - if any - and how.)
    • _idCache

      protected final transient ContextIdReference<TextureKey> _idCache
      cache of OpenGL context specific texture ids for the associated texture.
    • _code

      protected transient int _code
      cached hashcode value.
    • _keyCache

      protected static final List<WeakReference<TextureKey>> _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

      public static TextureKey initSavable()
      DO NOT USE. FOR INTERNAL USE ONLY
      Returns:
      the texture key
    • setDirty

      public void setDirty()
    • isDirty

      public boolean isDirty(Object glContext)
    • setClean

      public void setClean(Object glContext)
    • getRTTKey

      public static TextureKey getRTTKey(Texture.MinificationFilter minFilter)
      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

      public static boolean clearKey(TextureKey key)
    • getTextureIdForContext

      public Integer getTextureIdForContext(Object glContext)
      Parameters:
      glContext - the object representing the OpenGL context a texture belongs to. See RenderContext.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

      public Set<Object> getContextObjects()
      Returns:
      a Set of context objects that currently reference this texture.
    • removeFromIdCache

      public void removeFromIdCache(Object glContext)

      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. See RenderContext.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

      public void setTextureIdForContext(Object glContext, int textureId)
      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. See RenderContext.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

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getMinificationFilter

      public Texture.MinificationFilter getMinificationFilter()
    • getFormat

      public TextureStoreFormat getFormat()
    • isFlipped

      public boolean isFlipped()
      Returns:
      Returns the flipped.
    • getSource

      public ResourceSource getSource()
      Returns:
      Returns the source.
    • getId

      public String getId()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getClassTag

      public Class<? extends TextureKey> getClassTag()
      Specified by:
      getClassTag in interface Savable
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException