org.newdawn.slick.opengl
Class InternalTextureLoader

java.lang.Object
  extended by org.newdawn.slick.opengl.InternalTextureLoader

public class InternalTextureLoader
extends java.lang.Object

A texture loaded based on many old versions that will load image data from a file and produce OpenGL textures.

Author:
kevin
See Also:
ImageData

Field Summary
protected static SGL GL
          The renderer to use for all GL operations
 
Method Summary
 void clear()
          Clear out the cached textures
 void clear(java.lang.String name)
          Remove a particular named image from the cache
static java.nio.IntBuffer createIntBuffer(int size)
          Creates an integer buffer to hold specified ints - strictly a utility method
 Texture createTexture(int width, int height)
          Create an empty texture
 Texture createTexture(int width, int height, int filter)
          Create an empty texture
static int createTextureID()
          Create a new texture ID
static InternalTextureLoader get()
          Get the single instance of this texture loader
static int get2Fold(int fold)
          Get the closest greater power of 2 to the fold number
 Texture getTexture(java.io.File source, boolean flipped, int filter)
          Get a texture from a specific file
 Texture getTexture(java.io.File source, boolean flipped, int filter, int[] transparent)
          Get a texture from a specific file
 Texture getTexture(ImageData dataSource, int filter)
          Get a texture from a image file
 Texture getTexture(java.io.InputStream in, java.lang.String resourceName, boolean flipped, int filter)
          Get a texture from a image file
 TextureImpl getTexture(java.io.InputStream in, java.lang.String resourceName, boolean flipped, int filter, int[] transparent)
          Get a texture from a image file
 Texture getTexture(java.lang.String resourceName, boolean flipped, int filter)
          Get a texture from a resource location
 Texture getTexture(java.lang.String resourceName, boolean flipped, int filter, int[] transparent)
          Get a texture from a resource location
 boolean isDeferredLoading()
          Check if we're using deferred loading
 void reload()
          Reload all the textures loaded in this loader
 int reload(TextureImpl texture, int srcPixelFormat, int componentCount, int minFilter, int magFilter, java.nio.ByteBuffer textureBuffer)
          Reload a given texture blob
 void set16BitMode()
          Tell the loader to produce 16 bit textures
 void setDeferredLoading(boolean deferred)
          True if we should only record the request to load in the intention of loading the texture later
 void setHoldTextureData(boolean holdTextureData)
          Indicate where texture data should be held for reinitialising at a future point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GL

protected static SGL GL
The renderer to use for all GL operations

Method Detail

get

public static InternalTextureLoader get()
Get the single instance of this texture loader

Returns:
The single instance of the texture loader

setHoldTextureData

public void setHoldTextureData(boolean holdTextureData)
Indicate where texture data should be held for reinitialising at a future point.

Parameters:
holdTextureData - True if we should hold texture data

setDeferredLoading

public void setDeferredLoading(boolean deferred)
True if we should only record the request to load in the intention of loading the texture later

Parameters:
deferred - True if the we should load a token

isDeferredLoading

public boolean isDeferredLoading()
Check if we're using deferred loading

Returns:
True if we're loading deferred textures

clear

public void clear(java.lang.String name)
Remove a particular named image from the cache

Parameters:
name - The name of the image to be cleared

clear

public void clear()
Clear out the cached textures


set16BitMode

public void set16BitMode()
Tell the loader to produce 16 bit textures


createTextureID

public static int createTextureID()
Create a new texture ID

Returns:
A new texture ID

getTexture

public Texture getTexture(java.io.File source,
                          boolean flipped,
                          int filter)
                   throws java.io.IOException
Get a texture from a specific file

Parameters:
source - The file to load the texture from
flipped - True if we should flip the texture on the y axis while loading
filter - The filter to use
Returns:
The texture loaded
Throws:
java.io.IOException - Indicates a failure to load the image

getTexture

public Texture getTexture(java.io.File source,
                          boolean flipped,
                          int filter,
                          int[] transparent)
                   throws java.io.IOException
Get a texture from a specific file

Parameters:
source - The file to load the texture from
flipped - True if we should flip the texture on the y axis while loading
filter - The filter to use
transparent - The colour to interpret as transparent or null if none
Returns:
The texture loaded
Throws:
java.io.IOException - Indicates a failure to load the image

getTexture

public Texture getTexture(java.lang.String resourceName,
                          boolean flipped,
                          int filter)
                   throws java.io.IOException
Get a texture from a resource location

Parameters:
resourceName - The location to load the texture from
flipped - True if we should flip the texture on the y axis while loading
filter - The filter to use when scaling the texture
Returns:
The texture loaded
Throws:
java.io.IOException - Indicates a failure to load the image

getTexture

public Texture getTexture(java.lang.String resourceName,
                          boolean flipped,
                          int filter,
                          int[] transparent)
                   throws java.io.IOException
Get a texture from a resource location

Parameters:
resourceName - The location to load the texture from
flipped - True if we should flip the texture on the y axis while loading
filter - The filter to use when scaling the texture
transparent - The colour to interpret as transparent or null if none
Returns:
The texture loaded
Throws:
java.io.IOException - Indicates a failure to load the image

getTexture

public Texture getTexture(java.io.InputStream in,
                          java.lang.String resourceName,
                          boolean flipped,
                          int filter)
                   throws java.io.IOException
Get a texture from a image file

Parameters:
in - The stream from which we can load the image
resourceName - The name to give this image in the internal cache
flipped - True if we should flip the image on the y-axis while loading
filter - The filter to use when scaling the texture
Returns:
The texture loaded
Throws:
java.io.IOException - Indicates a failure to load the image

getTexture

public TextureImpl getTexture(java.io.InputStream in,
                              java.lang.String resourceName,
                              boolean flipped,
                              int filter,
                              int[] transparent)
                       throws java.io.IOException
Get a texture from a image file

Parameters:
in - The stream from which we can load the image
resourceName - The name to give this image in the internal cache
flipped - True if we should flip the image on the y-axis while loading
filter - The filter to use when scaling the texture
transparent - The colour to interpret as transparent or null if none
Returns:
The texture loaded
Throws:
java.io.IOException - Indicates a failure to load the image

createTexture

public Texture createTexture(int width,
                             int height)
                      throws java.io.IOException
Create an empty texture

Parameters:
width - The width of the new texture
height - The height of the new texture
Returns:
The created empty texture
Throws:
java.io.IOException - Indicates a failure to create the texture on the graphics hardware

createTexture

public Texture createTexture(int width,
                             int height,
                             int filter)
                      throws java.io.IOException
Create an empty texture

Parameters:
width - The width of the new texture
height - The height of the new texture
Returns:
The created empty texture
Throws:
java.io.IOException - Indicates a failure to create the texture on the graphics hardware

getTexture

public Texture getTexture(ImageData dataSource,
                          int filter)
                   throws java.io.IOException
Get a texture from a image file

Parameters:
dataSource - The image data to generate the texture from
filter - The filter to use when scaling the texture
Returns:
The texture created
Throws:
java.io.IOException - Indicates the texture is too big for the hardware

get2Fold

public static int get2Fold(int fold)
Get the closest greater power of 2 to the fold number

Parameters:
fold - The target number
Returns:
The power of 2

createIntBuffer

public static java.nio.IntBuffer createIntBuffer(int size)
Creates an integer buffer to hold specified ints - strictly a utility method

Parameters:
size - how many int to contain
Returns:
created IntBuffer

reload

public void reload()
Reload all the textures loaded in this loader


reload

public int reload(TextureImpl texture,
                  int srcPixelFormat,
                  int componentCount,
                  int minFilter,
                  int magFilter,
                  java.nio.ByteBuffer textureBuffer)
Reload a given texture blob

Parameters:
texture - The texture being reloaded
srcPixelFormat - The source pixel format
componentCount - The component count
minFilter - The minification filter
magFilter - The magnification filter
textureBuffer - The pixel data
Returns:
The ID of the newly created texture


Copyright © 2006 New Dawn Software. All Rights Reserved.