Package com.ardor3d.util
Class TextureManager
java.lang.Object
com.ardor3d.util.TextureManager
TextureManager
provides static methods for building or retrieving a Texture
object from
cache.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addToCache
(Texture texture) Add a given texture to the cachestatic void
cleanAllTextures
(Renderer deleter) Delete all textures from card.static void
cleanAllTextures
(Renderer deleter, RenderContext context, Map<Object, Future<Void>> futureStore) Deletes all textures from card for a specific gl context.static void
Delete all textures from card.static void
cleanExpiredTextures
(Renderer deleter) Delete any textures from the card that have been recently garbage collected in Java.static void
Delete any textures from the card that have been recently garbage collected in Java.static Texture
findCachedTexture
(TextureKey textureKey) Locate a texture in the cache by keystatic Texture
load
(ResourceSource source, Texture.MinificationFilter minFilter, boolean flipVertically) Loads a texture from the given source.static Texture
load
(ResourceSource source, Texture.MinificationFilter minFilter, TextureStoreFormat format, boolean flipVertically) Loads a texture from the given source.static Texture
load
(String name, Texture.MinificationFilter minFilter, boolean flipVertically) Loads a texture by attempting to locate the given name using ResourceLocatorTool.static Texture
load
(String name, Texture.MinificationFilter minFilter, TextureStoreFormat format, boolean flipVertically) Loads a texture by attempting to locate the given name using ResourceLocatorTool.static Texture
loadFromImage
(Image image, Texture.MinificationFilter minFilter) Creates a texture from a given Ardor3D Image object.static Texture
loadFromImage
(Image image, Texture.MinificationFilter minFilter, TextureStoreFormat format) Creates a texture from a given Ardor3D Image object.static Texture
loadFromKey
(TextureKey tkey, Image imageData, Texture store) Load a texture from the given TextureKey.static void
static Texture
-
Method Details
-
load
public static Texture load(String name, Texture.MinificationFilter minFilter, boolean flipVertically) Loads a texture by attempting to locate the given name using ResourceLocatorTool.- Parameters:
name
- the name of the texture image.minFilter
- the filter for the near values. Used to determine if we should generate mipmaps.flipVertically
- If true, the image is flipped vertically during image loading.- Returns:
- the loaded texture.
-
load
public static Texture load(String name, Texture.MinificationFilter minFilter, TextureStoreFormat format, boolean flipVertically) Loads a texture by attempting to locate the given name using ResourceLocatorTool.- Parameters:
name
- the name of the texture image.minFilter
- the filter for the near values. Used to determine if we should generate mipmaps.format
- the specific format to use when storing this texture on the card.flipVertically
- If true, the image is flipped vertically during image loading.- Returns:
- the loaded texture.
-
load
public static Texture load(ResourceSource source, Texture.MinificationFilter minFilter, boolean flipVertically) Loads a texture from the given source.- Parameters:
source
- the source of the texture image.minFilter
- the filter for the near values. Used to determine if we should generate mipmaps.flipVertically
- If true, the image is flipped vertically during image loading.- Returns:
- the loaded texture.
-
load
public static Texture load(ResourceSource source, Texture.MinificationFilter minFilter, TextureStoreFormat format, boolean flipVertically) Loads a texture from the given source.- Parameters:
source
- the source of the texture image.minFilter
- the filter for the near values. Used to determine if we should generate mipmaps.format
- the specific format to use when storing this texture on the card.flipVertically
- If true, the image is flipped vertically during image loading.- Returns:
- the loaded texture.
-
loadFromImage
Creates a texture from a given Ardor3D Image object.- Parameters:
image
- the Ardor3D image.minFilter
- the filter for the near values. Used to determine if we should generate mipmaps.- Returns:
- the loaded texture.
-
loadFromImage
public static Texture loadFromImage(Image image, Texture.MinificationFilter minFilter, TextureStoreFormat format) Creates a texture from a given Ardor3D Image object.- Parameters:
image
- the Ardor3D image.minFilter
- the filter for the near values. Used to determine if we should generate mipmaps.format
- the specific format to use when storing this texture on the card.- Returns:
- the loaded texture.
-
loadFromKey
Load a texture from the given TextureKey. If imageData is given, use that, otherwise load it using the key's source information. If store is given, populate and return that Texture object.- Parameters:
tkey
- our texture key. Must not be null.imageData
- optional Image data. If present, this is used instead of loading from source.store
- if not null, this Texture object is populated and returned instead of a new Texture object.- Returns:
- the resulting texture.
-
addToCache
Add a given texture to the cache- Parameters:
texture
- our texture
-
findCachedTexture
Locate a texture in the cache by key- Parameters:
textureKey
- our key- Returns:
- the texture, or null if not found.
-
removeFromCache
-
cleanAllTextures
Delete all textures from card. This will gather all texture ids believed to be on the card and try to delete them. If a deleter is passed in, textures that are part of the currently active context (if one is active) will be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter textures that are not part of the current context, then we will queue those textures to be deleted later using the GameTaskQueueManager.- Parameters:
deleter
- if not null, this renderer will be used to immediately delete any textures in the currently active context. All other textures will be queued to delete in their own contexts.
-
cleanAllTextures
Delete all textures from card. This will gather all texture ids believed to be on the card and try to delete them. If a deleter is passed in, textures that are part of the currently active context (if one is active) will be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter textures that are not part of the current context, then we will queue those textures to be deleted later using the GameTaskQueueManager. If a non null map is passed into futureStore, it will be populated with Future objects for each queued context. These objects may be used to discover when the deletion tasks have all completed.- Parameters:
deleter
- if not null, this renderer will be used to immediately delete any textures in the currently active context. All other textures will be queued to delete in their own contexts.futureStore
- if not null, this map will be populated with any Future task handles created during cleanup.
-
cleanAllTextures
public static void cleanAllTextures(Renderer deleter, RenderContext context, Map<Object, Future<Void>> futureStore) Deletes all textures from card for a specific gl context. This will gather all texture ids believed to be on the card for the given context and try to delete them. If a deleter is passed in, textures that are part of the currently active context (if one is active) will be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter textures that are not part of the current context, then we will queue those textures to be deleted later using the GameTaskQueueManager. If a non null map is passed into futureStore, it will be populated with Future objects for each queued context. These objects may be used to discover when the deletion tasks have all completed.- Parameters:
deleter
- if not null, this renderer will be used to immediately delete any textures in the currently active context. All other textures will be queued to delete in their own contexts.context
- the context to delete for.futureStore
- if not null, this map will be populated with any Future task handles created during cleanup.
-
cleanExpiredTextures
Delete any textures from the card that have been recently garbage collected in Java. If a deleter is passed in, gc'd textures that are part of the currently active context (if one is active) will be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter gc'd textures that are not part of the current context, then we will queue those textures to be deleted later using the GameTaskQueueManager.- Parameters:
deleter
- if not null, this renderer will be used to immediately delete any gc'd textures in the currently active context. All other gc'd textures will be queued to delete in their own contexts.
-
cleanExpiredTextures
Delete any textures from the card that have been recently garbage collected in Java. If a deleter is passed in, gc'd textures that are part of the currently active context (if one is active) will be deleted immediately. If a deleter is not passed in, we do not have an active context, or we encounter gc'd textures that are not part of the current context, then we will queue those textures to be deleted later using the GameTaskQueueManager. If a non null map is passed into futureStore, it will be populated with Future objects for each queued context. These objects may be used to discover when the deletion tasks have all completed.- Parameters:
deleter
- if not null, this renderer will be used to immediately delete any gc'd textures in the currently active context. All other gc'd textures will be queued to delete in their own contexts.futureStore
- if not null, this map will be populated with any Future task handles created during cleanup.
-
preloadCache
-