org.newdawn.slick.opengl
Class TextureImpl

java.lang.Object
  extended by org.newdawn.slick.opengl.TextureImpl
All Implemented Interfaces:
Texture
Direct Known Subclasses:
DeferredTexture

public class TextureImpl
extends java.lang.Object
implements Texture

A texture to be bound within JOGL. This object is responsible for keeping track of a given OpenGL texture and for calculating the texturing mapping coordinates of the full image. Since textures need to be powers of 2 the actual texture may be considerably bigged that the source image and hence the texture mapping coordinates need to be adjusted to matchup drawing the sprite against the texture.

Author:
Kevin Glass, Brian Matzon

Field Summary
protected static SGL GL
          The renderer to use for all GL operations
 
Constructor Summary
protected TextureImpl()
          For subclasses to utilise
  TextureImpl(java.lang.String ref, int target, int textureID)
          Create a new texture
 
Method Summary
 void bind()
          Bind the GL context to a texture
static void bindNone()
          Clear the binding of the texture
protected  java.nio.IntBuffer createIntBuffer(int size)
          Creates an integer buffer to hold specified ints - strictly a utility method
 float getHeight()
          Get the height of the physical texture
 int getImageHeight()
          Get the height of the original image
 int getImageWidth()
          Get the width of the original image
static Texture getLastBind()
          Retrieve the last texture bound through the texture interface
 byte[] getTextureData()
          Get the pixel data from the card for this texture
 int getTextureHeight()
          Get the height of the actual texture
 int getTextureID()
          Get the OpenGL texture ID for this texture
 java.lang.String getTextureRef()
          Get the reference from which this texture was loaded
 int getTextureWidth()
          Get the width of the actual texture
 float getWidth()
          Get the width of the physical texture
 boolean hasAlpha()
          Check if the texture has alpha
 void release()
          Destroy the texture reference
 void reload()
          Reload this texture
 void setAlpha(boolean alpha)
          If this texture has alpha
 void setCacheName(java.lang.String cacheName)
          Set the name this texture is stored against in the cache
 void setHeight(int height)
          Set the height of the image
 void setTextureData(int srcPixelFormat, int componentCount, int minFilter, int magFilter, java.nio.ByteBuffer textureBuffer)
          Set the texture data that this texture can be reloaded from
 void setTextureFilter(int textureFilter)
          Apply a given texture filter to the texture
 void setTextureHeight(int texHeight)
          Set the height of this texture
 void setTextureID(int textureID)
          Set the OpenGL texture ID for this texture
 void setTextureWidth(int texWidth)
          Set the width of this texture
 void setWidth(int width)
          Set the width of the image
static void unbind()
          Clear slick caching of the last bound texture so that an external texture binder can play with the context before returning control to slick.
 
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

Constructor Detail

TextureImpl

protected TextureImpl()
For subclasses to utilise


TextureImpl

public TextureImpl(java.lang.String ref,
                   int target,
                   int textureID)
Create a new texture

Parameters:
ref - The reference this texture was loaded from
target - The GL target
textureID - The GL texture ID
Method Detail

getLastBind

public static Texture getLastBind()
Retrieve the last texture bound through the texture interface

Returns:
The last texture bound

setCacheName

public void setCacheName(java.lang.String cacheName)
Set the name this texture is stored against in the cache

Parameters:
cacheName - The name the texture is stored against in the cache

hasAlpha

public boolean hasAlpha()
Description copied from interface: Texture
Check if the texture has alpha

Specified by:
hasAlpha in interface Texture
Returns:
True if the texture has alpha
See Also:
Texture.hasAlpha()

getTextureRef

public java.lang.String getTextureRef()
Description copied from interface: Texture
Get the reference from which this texture was loaded

Specified by:
getTextureRef in interface Texture
Returns:
The reference from which this texture was loaded
See Also:
Texture.getTextureRef()

setAlpha

public void setAlpha(boolean alpha)
If this texture has alpha

Parameters:
alpha - True, If this texture has alpha

bindNone

public static void bindNone()
Clear the binding of the texture


unbind

public static void unbind()
Clear slick caching of the last bound texture so that an external texture binder can play with the context before returning control to slick.


bind

public void bind()
Description copied from interface: Texture
Bind the GL context to a texture

Specified by:
bind in interface Texture
See Also:
Texture.bind()

setHeight

public void setHeight(int height)
Set the height of the image

Parameters:
height - The height of the image

setWidth

public void setWidth(int width)
Set the width of the image

Parameters:
width - The width of the image

getImageHeight

public int getImageHeight()
Description copied from interface: Texture
Get the height of the original image

Specified by:
getImageHeight in interface Texture
Returns:
The height of the original image
See Also:
Texture.getImageHeight()

getImageWidth

public int getImageWidth()
Description copied from interface: Texture
Get the width of the original image

Specified by:
getImageWidth in interface Texture
Returns:
The width of the original image
See Also:
Texture.getImageWidth()

getHeight

public float getHeight()
Description copied from interface: Texture
Get the height of the physical texture

Specified by:
getHeight in interface Texture
Returns:
The height of physical texture
See Also:
Texture.getHeight()

getWidth

public float getWidth()
Description copied from interface: Texture
Get the width of the physical texture

Specified by:
getWidth in interface Texture
Returns:
The width of physical texture
See Also:
Texture.getWidth()

getTextureHeight

public int getTextureHeight()
Description copied from interface: Texture
Get the height of the actual texture

Specified by:
getTextureHeight in interface Texture
Returns:
The height of the actual texture
See Also:
Texture.getTextureHeight()

getTextureWidth

public int getTextureWidth()
Description copied from interface: Texture
Get the width of the actual texture

Specified by:
getTextureWidth in interface Texture
Returns:
The width of the actual texture
See Also:
Texture.getTextureWidth()

setTextureHeight

public void setTextureHeight(int texHeight)
Set the height of this texture

Parameters:
texHeight - The height of the texture

setTextureWidth

public void setTextureWidth(int texWidth)
Set the width of this texture

Parameters:
texWidth - The width of the texture

release

public void release()
Description copied from interface: Texture
Destroy the texture reference

Specified by:
release in interface Texture
See Also:
Texture.release()

getTextureID

public int getTextureID()
Description copied from interface: Texture
Get the OpenGL texture ID for this texture

Specified by:
getTextureID in interface Texture
Returns:
The OpenGL texture ID
See Also:
Texture.getTextureID()

setTextureID

public void setTextureID(int textureID)
Set the OpenGL texture ID for this texture

Parameters:
textureID - The OpenGL texture ID

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

getTextureData

public byte[] getTextureData()
Description copied from interface: Texture
Get the pixel data from the card for this texture

Specified by:
getTextureData in interface Texture
Returns:
The texture data from the card for this texture
See Also:
Texture.getTextureData()

setTextureFilter

public void setTextureFilter(int textureFilter)
Description copied from interface: Texture
Apply a given texture filter to the texture

Specified by:
setTextureFilter in interface Texture
Parameters:
textureFilter - The texture filter to apply (GL_LINEAR, GL_NEAREST, etc..)
See Also:
Texture.setTextureFilter(int)

setTextureData

public void setTextureData(int srcPixelFormat,
                           int componentCount,
                           int minFilter,
                           int magFilter,
                           java.nio.ByteBuffer textureBuffer)
Set the texture data that this texture can be reloaded from

Parameters:
srcPixelFormat - The pixel format
componentCount - The component count
minFilter - The OpenGL minification filter
magFilter - The OpenGL magnification filter
textureBuffer - The texture buffer containing the data for the texture

reload

public void reload()
Reload this texture



Copyright © 2006 New Dawn Software. All Rights Reserved.