|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjme.texture.TextureManager
TextureManager
maintains all textures within the running
application. It is a singleton class, and therefore can be used anywhere
in the program. TextureManager
maintains a list of texture
id's with the name of the file as the key.
loadTexture
method with the file name and the filter parameters.
It takes a boolean value of as the last parameter to determine to use
mipmapping or not. If the file is already loaded, the texture is NOT
reloaded, but the corresponding id is returned instead.
TextureManager
also takes care of retrieving id's, binding
a texture and deleting textures.
Method Summary | |
void |
batchLoad(java.util.ArrayList keys)
batchLoad loads a collection of textures defined by an
ArrayList . |
void |
batchLoad(java.util.ArrayList keys,
boolean flipped)
batchLoad loads a collection of textures defined by an
ArrayList . |
void |
bind(int id)
bind binds a texture based on a given id. |
boolean |
bind(java.lang.String file)
bind sets the current texture to that defined by the
filename key. |
void |
deleteAll()
deleteAll removes all textures from the video memory as
well as the TextureManager list. |
boolean |
deleteTexture(java.lang.String file)
deleteTexture removes the texture from video memory. |
int |
getNumberOfTextures()
getNumberOfTextures returns how many textures are currently
being maintained by the TextureManager . |
int |
getTexture(java.lang.String file)
getTexture retrieves a texture id based on the filename. |
static TextureManager |
getTextureManager()
getTextureManager retrieves the instance of
TextureManager . |
int |
loadTexture(javax.swing.ImageIcon image,
int minFilter,
int magFilter,
boolean isMipMapped)
loadTexture loads a new texture defined by a loaded
ImageIcon. |
int |
loadTexture(javax.swing.ImageIcon image,
int minFilter,
int magFilter,
boolean isMipmapped,
boolean flipped)
loadTexture loads a new texture defined by a loaded
ImageIcon. |
int |
loadTexture(java.lang.String file,
int minFilter,
int magFilter,
boolean isMipMapped)
loadTexture loads a new texture defined by the parameter
string. |
int |
loadTexture(java.lang.String file,
int minFilter,
int magFilter,
boolean isMipmapped,
boolean flipped)
loadTexture loads a new texture defined by the parameter
string. |
void |
reload()
reload reloads all loaded textures after making a call
to saveKeys . |
void |
reload(boolean flipped)
reload reloads all loaded textures after making a call
to saveKeys . |
static void |
reset()
reset clears all textures from the list and sets the
instance to null. |
java.util.ArrayList |
saveKeys()
saveKeys makes a copy of all the texture keys (file names). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public void reload()
reload
reloads all loaded textures after making a call
to saveKeys
. This is useful for
reloading textures if the GL object has been recreated.
public void reload(boolean flipped)
reload
reloads all loaded textures after making a call
to saveKeys
. This is useful for
reloading textures if the GL object has been recreated.
flipped
- true flips the bits of the image, false does not. True
by default.public void batchLoad(java.util.ArrayList keys)
batchLoad
loads a collection of textures defined by an
ArrayList
.
keys
- the list of files to open.public void batchLoad(java.util.ArrayList keys, boolean flipped)
batchLoad
loads a collection of textures defined by an
ArrayList
.
keys
- the list of files to open.flipped
- true flips the bits of the image, false does not. True
by default.public java.util.ArrayList saveKeys()
saveKeys
makes a copy of all the texture keys (file names).
This is useful for reloading prior to deleting all textures.
ArrayList
of the keys.public int loadTexture(javax.swing.ImageIcon image, int minFilter, int magFilter, boolean isMipMapped)
loadTexture
loads a new texture defined by a loaded
ImageIcon. If a texture with the same filename has previously been loaded,
that id is returned rather than reloading. Filter parameters are used
to define the filtering of the texture. Whether the texture is to be
mipmapped or not is denoted by the isMipmapped boolean flag. If there
is an error loading the file, -1 is returned.
image
- the ImageIcon of the texture image.minFilter
- the filter for the near values.magFilter
- the filter for the far values.
public int loadTexture(javax.swing.ImageIcon image, int minFilter, int magFilter, boolean isMipmapped, boolean flipped)
loadTexture
loads a new texture defined by a loaded
ImageIcon. If a texture with the same filename has previously been loaded,
that id is returned rather than reloading. Filter parameters are used
to define the filtering of the texture. Whether the texture is to be
mipmapped or not is denoted by the isMipmapped boolean flag. If there
is an error loading the file, -1 is returned.
image
- the ImageIcon of the texture image.minFilter
- the filter for the near values.magFilter
- the filter for the far values.isMipmapped
- determines if we will load the texture mipmapped
or not. True load the texture mipmapped, false do not.flipped
- true flips the bits of the image, false does not. True
by default.
public int loadTexture(java.lang.String file, int minFilter, int magFilter, boolean isMipMapped)
loadTexture
loads a new texture defined by the parameter
string. If a texture with the same filename has previously been loaded,
that id is returned rather than reloading. Filter parameters are used
to define the filtering of the texture. Whether the texture is to be
mipmapped or not is denoted by the isMipmapped boolean flag. If there
is an error loading the file, -1 is returned.
file
- the filename of the texture image.minFilter
- the filter for the near values.magFilter
- the filter for the far values.
public int loadTexture(java.lang.String file, int minFilter, int magFilter, boolean isMipmapped, boolean flipped)
loadTexture
loads a new texture defined by the parameter
string. If a texture with the same filename has previously been loaded,
that id is returned rather than reloading. Filter parameters are used
to define the filtering of the texture. Whether the texture is to be
mipmapped or not is denoted by the isMipmapped boolean flag. If there
is an error loading the file, -1 is returned.
file
- the filename of the texture image.minFilter
- the filter for the near values.magFilter
- the filter for the far values.isMipmapped
- determines if we will load the texture mipmapped
or not. True load the texture mipmapped, false do not.
public int getTexture(java.lang.String file)
getTexture
retrieves a texture id based on the filename.
Use this method if you are certain that the file has previously been
loaded using loadTexture
. If the texture has not been
loaded previously -1 is returned as the id.
file
- the filename to retrieve the id of.
public boolean bind(java.lang.String file)
bind
sets the current texture to that defined by the
filename key. The filename must have been previously loaded using
the loadTexture
method. If the texture is bound correctly,
true is returned, otherwise false is returned.
file
- the filename key to bind.
public void bind(int id)
bind
binds a texture based on a given id. It is up to the
client to insure that the id is valid. If unsure about the id value, use
bind(String)
with the texture filename as the key. If the
id is valid, the texture is bound, otherwise it is not. There is not
success check.
id
- the texture id to bind.public boolean deleteTexture(java.lang.String file)
deleteTexture
removes the texture from video memory. The
texture removed is defined by the filename key. If the texture file
has not been loaded or has previously been deleted false is returned.
True is returned if the texture was successfully removed.
file
- the texture filename to remove.
public void deleteAll()
deleteAll
removes all textures from the video memory as
well as the TextureManager
list. This effectively "resets"
the manager.
public int getNumberOfTextures()
getNumberOfTextures
returns how many textures are currently
being maintained by the TextureManager
.
public static TextureManager getTextureManager()
getTextureManager
retrieves the instance of
TextureManager
.
TextureManager
.public static void reset()
reset
clears all textures from the list and sets the
instance to null. This will guarantee that the next call to
getTexutreManager
will create a new instance of
TextureManager
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |