com.jme.util
Class TextureManager

java.lang.Object
  extended by com.jme.util.TextureManager

public final class TextureManager
extends java.lang.Object

TextureManager provides static methods for building a Texture object. Typically, the information supplied is the filename and the texture properties.

Version:
$Id: TextureManager.java 4384 2009-06-03 01:34:40Z mulova $
Author:
Mark Powell, Joshua Slack -- cache code and enhancements

Field Summary
static boolean COMPRESS_BY_DEFAULT
           
 
Method Summary
static void addToCache(Texture t)
           
static void clearCache()
           
static void deleteTextureFromCard(Texture tex)
           
static void doTextureCleanup()
           
static Texture findCachedTexture(TextureKey textureKey)
           
static boolean hasAlpha(java.awt.Image image)
          hasAlpha returns true if the specified image has transparent pixels
static boolean isCreateOnHeap()
           
static boolean isGreyscale(java.awt.Image image)
          isGreyscale returns true if the specified image is greyscale.
static Image loadImage(java.awt.Image image, boolean flipImage)
          loadImage sets the image data.
static Image loadImage(java.lang.String fileName, boolean flipped)
           
static Image loadImage(java.lang.String fileExt, java.io.InputStream stream, boolean flipped)
           
static Image loadImage(TextureKey key)
           
static Image loadImage(java.net.URL file, boolean flipped)
           
static Texture loadTexture(java.awt.Image image, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, boolean flipped)
           
static Texture loadTexture(java.awt.Image image, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, float anisoLevel, boolean flipped)
           
static Texture loadTexture(java.awt.Image image, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, float anisoLevel, Image.Format imageFormat, boolean flipped)
           
static Texture loadTexture(java.lang.String file, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter)
          loadTexture loads a new texture defined by the parameter string.
static Texture loadTexture(java.lang.String file, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, float anisoLevel, boolean flipped)
          loadTexture loads a new texture defined by the parameter string.
static Texture loadTexture(java.lang.String file, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, Image.Format imageType, float anisoLevel, boolean flipped)
          loadTexture loads a new texture defined by the parameter string.
static Texture loadTexture(TextureKey tkey)
           
static Texture loadTexture(Texture texture, TextureKey tkey)
           
static Texture loadTexture(Texture texture, TextureKey tkey, Image imageData, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, float anisoLevel)
           
static Texture loadTexture(java.net.URL file)
          loadTexture loads a new texture defined by the parameter url.
static Texture loadTexture(java.net.URL file, boolean flipped)
          loadTexture loads a new texture defined by the parameter url.
static Texture loadTexture(java.net.URL file, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter)
          loadTexture loads a new texture defined by the parameter url.
static Texture loadTexture(java.net.URL file, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, float anisoLevel, boolean flipped)
           
static Texture loadTexture(java.net.URL file, Texture.MinificationFilter minFilter, Texture.MagnificationFilter magFilter, Image.Format imageType, float anisoLevel, boolean flipped)
          loadTexture loads a new texture defined by the parameter url.
static void preloadCache(Renderer r)
           
static void registerForCleanup(TextureKey textureKey, int textureId)
           
static void registerHandler(java.lang.String format, ImageLoader handler)
          Register an ImageLoader to handle all files with a specific extention.
static boolean releaseTexture(Texture texture)
           
static boolean releaseTexture(TextureKey tKey)
           
static void setCreateOnHeap(boolean createOnHeap)
           
static void unregisterHandler(java.lang.String format)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPRESS_BY_DEFAULT

public static boolean COMPRESS_BY_DEFAULT
Method Detail

loadTexture

public static Texture loadTexture(java.lang.String file,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter)
loadTexture loads a new texture defined by the parameter string. Filter parameters are used to define the filtering of the texture. If there is an error loading the file, null is returned.

Parameters:
file - the filename of the texture image.
minFilter - the filter for the near values.
magFilter - the filter for the far values.
Returns:
the loaded texture. If there is a problem loading the texture, null is returned.

loadTexture

public static Texture loadTexture(java.lang.String file,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  float anisoLevel,
                                  boolean flipped)
loadTexture loads a new texture defined by the parameter string. Filter parameters are used to define the filtering of the texture. If there is an error loading the file, null is returned.

Parameters:
file - the filename of the texture image.
minFilter - the filter for the near values.
magFilter - the filter for the far values.
anisoLevel - the aniso level for this texture
flipped - If true, the images Y values are flipped.
Returns:
the loaded texture. If there is a problem loading the texture, null is returned.

loadTexture

public static Texture loadTexture(java.lang.String file,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  Image.Format imageType,
                                  float anisoLevel,
                                  boolean flipped)
loadTexture loads a new texture defined by the parameter string. Filter parameters are used to define the filtering of the texture. If there is an error loading the file, null is returned.

Parameters:
file - the filename of the texture image.
minFilter - the filter for the near values.
magFilter - the filter for the far values.
imageType - the type to use for image data
anisoLevel - the aniso level for this texture
flipped - If true, the images Y values are flipped.
Returns:
the loaded texture. If there is a problem loading the texture, null is returned.

loadTexture

public static Texture loadTexture(java.net.URL file)
loadTexture loads a new texture defined by the parameter url. If there is an error loading the file, null is returned.

Parameters:
file - the url of the texture image.
flipped - If true, the images Y values are flipped.
Returns:
the loaded texture. If there is a problem loading the texture, null is returned.

loadTexture

public static Texture loadTexture(java.net.URL file,
                                  boolean flipped)
loadTexture loads a new texture defined by the parameter url. If there is an error loading the file, null is returned.

Parameters:
file - the url of the texture image.
flipped - If true, the images Y values are flipped.
Returns:
the loaded texture. If there is a problem loading the texture, null is returned.

loadTexture

public static Texture loadTexture(java.net.URL file,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter)
loadTexture loads a new texture defined by the parameter url. Filter parameters are used to define the filtering of the texture. If there is an error loading the file, null is returned.

Parameters:
file - the url of the texture image.
minFilter - the filter for the near values.
magFilter - the filter for the far values.
Returns:
the loaded texture. If there is a problem loading the texture, null is returned.

loadTexture

public static Texture loadTexture(java.net.URL file,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  float anisoLevel,
                                  boolean flipped)

loadTexture

public static Texture loadTexture(java.net.URL file,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  Image.Format imageType,
                                  float anisoLevel,
                                  boolean flipped)
loadTexture loads a new texture defined by the parameter url. Filter parameters are used to define the filtering of the texture. If there is an error loading the file, null is returned.

Parameters:
file - the url of the texture image.
minFilter - the filter for the near values.
magFilter - the filter for the far values.
imageType - the image type to use. if Image.Format.Guess, the type is determined by jME. If S3TC/DXT is available we use that. if Image.Format.GuessNoCompression, the type is determined by jME without using S3TC, even if available. See com.jme.image.Image.Format for possible types.
flipped - If true, the images Y values are flipped.
Returns:
the loaded texture. If there is a problem loading the texture, null is returned.
See Also:
Image.Format

loadTexture

public static Texture loadTexture(TextureKey tkey)

loadTexture

public static Texture loadTexture(Texture texture,
                                  TextureKey tkey)

loadTexture

public static Texture loadTexture(Texture texture,
                                  TextureKey tkey,
                                  Image imageData,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  float anisoLevel)

addToCache

public static void addToCache(Texture t)

loadTexture

public static Texture loadTexture(java.awt.Image image,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  boolean flipped)

loadTexture

public static Texture loadTexture(java.awt.Image image,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  float anisoLevel,
                                  boolean flipped)

loadTexture

public static Texture loadTexture(java.awt.Image image,
                                  Texture.MinificationFilter minFilter,
                                  Texture.MagnificationFilter magFilter,
                                  float anisoLevel,
                                  Image.Format imageFormat,
                                  boolean flipped)

loadImage

public static Image loadImage(TextureKey key)

loadImage

public static Image loadImage(java.net.URL file,
                              boolean flipped)

loadImage

public static Image loadImage(java.lang.String fileName,
                              boolean flipped)

loadImage

public static Image loadImage(java.lang.String fileExt,
                              java.io.InputStream stream,
                              boolean flipped)

loadImage

public static Image loadImage(java.awt.Image image,
                              boolean flipImage)
loadImage sets the image data. It will set the jme Image's format to RGB8 or RGBA8 or Alpha8 depending on the incoming java Image. (greyscale will be sent back as Alpha8)

Parameters:
image - The image data.
flipImage - if true will flip the image's y values.
Returns:
the loaded image.

hasAlpha

public static boolean hasAlpha(java.awt.Image image)
hasAlpha returns true if the specified image has transparent pixels

Parameters:
image - Image to check
Returns:
true if the specified image has transparent pixels

isGreyscale

public static boolean isGreyscale(java.awt.Image image)
isGreyscale returns true if the specified image is greyscale.

Parameters:
image - Image to check
Returns:
true if the specified image is greyscale.

releaseTexture

public static boolean releaseTexture(Texture texture)

releaseTexture

public static boolean releaseTexture(TextureKey tKey)

clearCache

public static void clearCache()

registerHandler

public static void registerHandler(java.lang.String format,
                                   ImageLoader handler)
Register an ImageLoader to handle all files with a specific extention. An ImageLoader can be registered to handle several formats without problems.

Parameters:
format - The file extention for the format this ImageLoader will handle. Make sure to include the dot (eg. ".BMP"). This value is case insensitive (".Bmp" will register for ".BMP", ".bmp", etc.)
handler -

unregisterHandler

public static void unregisterHandler(java.lang.String format)

registerForCleanup

public static void registerForCleanup(TextureKey textureKey,
                                      int textureId)

doTextureCleanup

public static void doTextureCleanup()

deleteTextureFromCard

public static void deleteTextureFromCard(Texture tex)

findCachedTexture

public static Texture findCachedTexture(TextureKey textureKey)

preloadCache

public static void preloadCache(Renderer r)

setCreateOnHeap

public static void setCreateOnHeap(boolean createOnHeap)

isCreateOnHeap

public static boolean isCreateOnHeap()