maspack.render
Class TextureLoader

java.lang.Object
  extended by maspack.render.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 (Modified by Kees van den Doel)

Constructor Summary
TextureLoader(javax.media.opengl.GL2 gl)
          Create a new texture loader based on the game panel
 
Method Summary
 Texture getTexture(java.lang.String resourceName)
          Load a texture
 Texture getTexture(java.lang.String resourceName, int target, int dstPixelFormat, int minFilter, int magFilter)
          Load a texture into OpenGL from a image reference on disk.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextureLoader

public TextureLoader(javax.media.opengl.GL2 gl)
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.lang.String resourceName)
                   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.lang.String resourceName,
                          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