org.lee.mugen.core.renderer.lwjgl
Class TextureLoader

java.lang.Object
  extended by org.lee.mugen.core.renderer.lwjgl.TextureLoader

public class TextureLoader
extends java.lang.Object

A utility class to load textures for JOGL. This source is based on a texture that can be found in the Java Gaming (www.javagaming.org) Wiki. It has been simplified slightly for explicit 2D graphics use. OpenGL uses a particular image format. Since the images that are loaded from disk may not match this format this loader introduces a intermediate image which the source image is copied into. In turn, this image is used as source for the OpenGL texture.

Author:
Kevin Glass, Brian Matzon

Constructor Summary
TextureLoader()
          Create a new texture loader based on the game panel
 
Method Summary
protected  java.nio.IntBuffer createIntBuffer(int size)
          Creates an integer buffer to hold specified ints - strictly a utility method
 Texture createTexture(int width, int height)
           
 void free(Texture texture)
           
 Texture getTexture(java.awt.image.BufferedImage img)
          Load a texture
 Texture getTexture(java.awt.image.BufferedImage img, int target, int dstPixelFormat, int minFilter, int magFilter)
          Load a texture into OpenGL from a image reference on disk.
 Texture getTexture(int detpth, int width, int height, int texWidth, int texHeight, java.nio.ByteBuffer byteBuffer, int filter, int dstPixelFormat)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextureLoader

public TextureLoader()
Create a new texture loader based on the game panel

Parameters:
gl - The GL content in which the textures should be loaded
Method Detail

getTexture

public Texture getTexture(java.awt.image.BufferedImage img)
                   throws java.io.IOException
Load a texture

Parameters:
resourceName - The location of the resource to load
Returns:
The loaded texture
Throws:
java.io.IOException - Indicates a failure to access the resource

getTexture

public Texture getTexture(java.awt.image.BufferedImage img,
                          int target,
                          int dstPixelFormat,
                          int minFilter,
                          int magFilter)
                   throws java.io.IOException
Load a texture into OpenGL from a image reference on disk.

Parameters:
resourceName - The location of the resource to load
target - The GL target to load the texture against
dstPixelFormat - The pixel format of the screen
minFilter - The minimising filter
magFilter - The magnification filter
Returns:
The loaded texture
Throws:
java.io.IOException - Indicates a failure to access the resource

createIntBuffer

protected 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

createTexture

public Texture createTexture(int width,
                             int height)
                      throws java.io.IOException
Throws:
java.io.IOException

getTexture

public Texture getTexture(int detpth,
                          int width,
                          int height,
                          int texWidth,
                          int texHeight,
                          java.nio.ByteBuffer byteBuffer,
                          int filter,
                          int dstPixelFormat)
                   throws java.io.IOException
Throws:
java.io.IOException

free

public void free(Texture texture)