com.badlogic.gdx.graphics
Class GLTexture

java.lang.Object
  extended by com.badlogic.gdx.graphics.GLTexture
All Implemented Interfaces:
Disposable
Direct Known Subclasses:
Cubemap, Texture

public abstract class GLTexture
extends Object
implements Disposable

Class representing an OpenGL texture by its target and handle. Keeps track of its state like the TextureFilter and TextureWrap. Also provides some (protected) static methods to create TextureData and upload image data.

Author:
badlogic, Xoppa

Field Summary
 int glTarget
          The target of this texture, used when binding the texture, e.g.
 
Constructor Summary
GLTexture(int glTarget)
          Generates a new OpenGL texture with the specified target.
GLTexture(int glTarget, int glHandle)
           
 
Method Summary
 void bind()
          Binds this texture.
 void bind(int unit)
          Binds the texture to the given texture unit.
 void dispose()
          Releases all resources of this object.
abstract  int getDepth()
           
static boolean getEnforcePotImage()
           
abstract  int getHeight()
           
 Texture.TextureFilter getMagFilter()
           
 Texture.TextureFilter getMinFilter()
           
 int getTextureObjectHandle()
           
 Texture.TextureWrap getUWrap()
           
 Texture.TextureWrap getVWrap()
           
abstract  int getWidth()
           
abstract  boolean isManaged()
           
static void setEnforcePotImages(boolean enforcePotImages)
           
 void setFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)
          Sets the Texture.TextureFilter for this texture for minification and magnification.
 void setWrap(Texture.TextureWrap u, Texture.TextureWrap v)
          Sets the Texture.TextureWrap for this texture on the u and v axis.
 void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)
          Sets the Texture.TextureFilter for this texture for minification and magnification.
 void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force)
          Sets the Texture.TextureFilter for this texture for minification and magnification.
 void unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v)
          Sets the Texture.TextureWrap for this texture on the u and v axis.
 void unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v, boolean force)
          Sets the Texture.TextureWrap for this texture on the u and v axis.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

glTarget

public final int glTarget
The target of this texture, used when binding the texture, e.g. GL_TEXTURE_2D

Constructor Detail

GLTexture

public GLTexture(int glTarget)
Generates a new OpenGL texture with the specified target.


GLTexture

public GLTexture(int glTarget,
                 int glHandle)
Method Detail

getWidth

public abstract int getWidth()
Returns:
the width of the texture in pixels

getHeight

public abstract int getHeight()
Returns:
the height of the texture in pixels

getDepth

public abstract int getDepth()
Returns:
the depth of the texture in pixels

isManaged

public abstract boolean isManaged()
Returns:
whether this texture is managed or not.

bind

public void bind()
Binds this texture. The texture will be bound to the currently active texture unit specified via GLCommon.glActiveTexture(int).


bind

public void bind(int unit)
Binds the texture to the given texture unit. Sets the currently active texture unit via GLCommon.glActiveTexture(int).

Parameters:
unit - the unit (0 to MAX_TEXTURE_UNITS).

getMinFilter

public Texture.TextureFilter getMinFilter()
Returns:
The Texture.TextureFilter used for minification.

getMagFilter

public Texture.TextureFilter getMagFilter()
Returns:
The Texture.TextureFilter used for magnification.

getUWrap

public Texture.TextureWrap getUWrap()
Returns:
The Texture.TextureWrap used for horizontal (U) texture coordinates.

getVWrap

public Texture.TextureWrap getVWrap()
Returns:
The Texture.TextureWrap used for vertical (V) texture coordinates.

getTextureObjectHandle

public int getTextureObjectHandle()
Returns:
The OpenGL handle for this texture.

unsafeSetWrap

public void unsafeSetWrap(Texture.TextureWrap u,
                          Texture.TextureWrap v)
Sets the Texture.TextureWrap for this texture on the u and v axis. Assumes the texture is bound and active!

Parameters:
u - the u wrap
v - the v wrap

unsafeSetWrap

public void unsafeSetWrap(Texture.TextureWrap u,
                          Texture.TextureWrap v,
                          boolean force)
Sets the Texture.TextureWrap for this texture on the u and v axis. Assumes the texture is bound and active!

Parameters:
u - the u wrap
v - the v wrap
force - True to always set the values, even if they are the same as the current values.

setWrap

public void setWrap(Texture.TextureWrap u,
                    Texture.TextureWrap v)
Sets the Texture.TextureWrap for this texture on the u and v axis. This will bind this texture!

Parameters:
u - the u wrap
v - the v wrap

unsafeSetFilter

public void unsafeSetFilter(Texture.TextureFilter minFilter,
                            Texture.TextureFilter magFilter)
Sets the Texture.TextureFilter for this texture for minification and magnification. Assumes the texture is bound and active!

Parameters:
minFilter - the minification filter
magFilter - the magnification filter

unsafeSetFilter

public void unsafeSetFilter(Texture.TextureFilter minFilter,
                            Texture.TextureFilter magFilter,
                            boolean force)
Sets the Texture.TextureFilter for this texture for minification and magnification. Assumes the texture is bound and active!

Parameters:
minFilter - the minification filter
magFilter - the magnification filter
force - True to always set the values, even if they are the same as the current values.

setFilter

public void setFilter(Texture.TextureFilter minFilter,
                      Texture.TextureFilter magFilter)
Sets the Texture.TextureFilter for this texture for minification and magnification. This will bind this texture!

Parameters:
minFilter - the minification filter
magFilter - the magnification filter

dispose

public void dispose()
Description copied from interface: Disposable
Releases all resources of this object.

Specified by:
dispose in interface Disposable

setEnforcePotImages

public static void setEnforcePotImages(boolean enforcePotImages)
Parameters:
enforcePotImages - whether to enforce power of two images in OpenGL ES 1.0 or not.

getEnforcePotImage

public static boolean getEnforcePotImage()


Copyright © 2013. All Rights Reserved.