public final class TextureManager
extends java.lang.Object
Texture
Modifier and Type | Field and Description |
---|---|
static int |
TEXTURE_NOTFOUND
The id of a none-existent texture
|
Modifier and Type | Method and Description |
---|---|
void |
addTexture(java.lang.String name)
Adds a texture with the given name to the manager.
|
void |
addTexture(java.lang.String name,
Texture tex)
Adds a texture with the given name to the manager.
|
void |
compress()
Compresses all texture known to the TextureManager so that they use less
main memory.
|
boolean |
containsTexture(java.lang.String name)
Checks if a texture has already been added to the texture-manager (or
better: if a texture with this name exists within the manager instance).
|
void |
deVirtualize(Texture tex)
Removes a texture from the virtualized set by recreating a state as if
this texture has never been virtualized, i.e. pixel data will be stored
in memory again the file which has been stored on disk has been removed.
|
void |
flush()
Flushes the textures in the manager.
|
Texture |
getDummyTexture()
Returns the current dummy texture.
|
static TextureManager |
getInstance()
Returns an instance of the TextureManager.
|
long |
getMemoryUsage()
Returns the VM memory used to store the texture data.
|
java.lang.String |
getNameByID(int id)
Gets the name with which the texture with the given ID has been added to
the manager.
|
java.lang.String |
getNameByTexture(Texture texture)
Returns the name with which the texture has been added to the manager.
|
java.util.HashSet<java.lang.String> |
getNames()
Gets all the names of the textures that have been added to the manager.
|
java.util.List<?> |
getState()
Dumps the current state of the TextureManager to a Vector.
|
Texture |
getTexture(java.lang.String name)
Returns the texture being named 'name'.
|
Texture |
getTextureByID(int id)
Returns the texture with the ID or null if no such texture can be found.
|
int |
getTextureCount()
Returns the number of textures the TextureManager holds.
|
int |
getTextureID(java.lang.String name)
Returns the numerical ID of the texture.
|
Virtualizer |
getVirtualizer()
Returns the current Virtualizer.
|
boolean |
isForgiving()
Returns if the TextureManager is in "forgiving" mode or not (default).
|
void |
preWarm(FrameBuffer buffer)
Does some work that may otherwise happen during runtime and can cause
hick-ups like uploading all known textures if needed before the renderer
is going to use them anyway.
|
boolean |
preWarm(FrameBuffer buffer,
int count)
Special purpose version of preWarm(), which takes a count value in
addition.
|
void |
removeAndUnload(java.lang.String name,
FrameBuffer from)
Combines removal and unload of a texture.
|
void |
removeTexture(java.lang.String name)
Removes a texture from the manager.
|
void |
replaceTexture(java.lang.String name,
Texture tex)
Replaces a texture with the given name with another one.
|
void |
setDummyTexture(Texture texture)
Sets a texture as dummy texture.
|
void |
setForgiving(boolean forgiving)
Sets "forgiving" mode.
|
void |
setState(java.util.List<?> dump)
Sets the state of the TextureManager.
|
void |
setVirtualizer(Virtualizer textureVirtualizer)
Sets a new Virtualizer.
|
void |
unloadTexture(FrameBuffer from,
Texture texture)
Unloads a texture from the contexts of the renderers of the given frame
buffer.
|
void |
virtualize(Texture tex)
Virtualizes a textures if a Virtualizer has been set.
|
public static final int TEXTURE_NOTFOUND
public static TextureManager getInstance()
public java.util.List<?> getState()
public void setState(java.util.List<?> dump)
dump
- the state dumppublic void addTexture(java.lang.String name)
name
- the (unique) name for this texturereplaceTexture(java.lang.String, com.threed.jpct.Texture)
public void addTexture(java.lang.String name, Texture tex)
name
- the (unique) name for this texturetex
- the texturepublic void replaceTexture(java.lang.String name, Texture tex)
name
- the (unique) name of the texture to replacetex
- the new texturepublic long getMemoryUsage()
public void unloadTexture(FrameBuffer from, Texture texture)
from
- the FrameBuffertexture
- the texture to unloadremoveAndUnload(java.lang.String, com.threed.jpct.FrameBuffer)
public void removeTexture(java.lang.String name)
name
- the name of the texture to be removedunloadTexture(com.threed.jpct.FrameBuffer, com.threed.jpct.Texture)
,
removeAndUnload(java.lang.String, com.threed.jpct.FrameBuffer)
,
replaceTexture(java.lang.String, com.threed.jpct.Texture)
public void removeAndUnload(java.lang.String name, FrameBuffer from)
name
- the texture's namefrom
- the FrameBufferunloadTexture(com.threed.jpct.FrameBuffer, com.threed.jpct.Texture)
,
removeTexture(java.lang.String)
public void flush()
FrameBuffer.freeMemory()
public void compress()
public void preWarm(FrameBuffer buffer)
buffer
- the current frame buffer.public boolean preWarm(FrameBuffer buffer, int count)
buffer
- the current frame buffer. The desired renderer should be
enabled.count
- the maximum number of processing requestspublic void setDummyTexture(Texture texture)
texture
- the new dummy texturepublic Texture getDummyTexture()
public boolean containsTexture(java.lang.String name)
name
- the name of the texturepublic int getTextureCount()
public int getTextureID(java.lang.String name)
name
- the name of the texturepublic Texture getTextureByID(int id)
id
- int the IDpublic Texture getTexture(java.lang.String name)
name
- the name of the texture that should be retrievedpublic java.util.HashSet<java.lang.String> getNames()
public java.lang.String getNameByID(int id)
id
- the texture's IDpublic java.lang.String getNameByTexture(Texture texture)
texture
- public void setVirtualizer(Virtualizer textureVirtualizer)
textureVirtualizer
- The Virtualizerpublic Virtualizer getVirtualizer()
public void virtualize(Texture tex)
tex
- the Texture to virtualize. If it is virtual already, no
actions will be taken.public void deVirtualize(Texture tex)
tex
- the Texture to de-virtualize. If it's not virtual anyway, no
actions will be taken.public boolean isForgiving()
public void setForgiving(boolean forgiving)
forgiving
- the mode