APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.graphics

public abstract Class GLTexture

extends Object
implements Disposable
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.Disposable
Known Direct Subclasses
com.badlogic.gdx.graphics.Texture, com.badlogic.gdx.graphics.Texture3D, com.badlogic.gdx.graphics.TextureArray, com.badlogic.gdx.graphics.Cubemap
Imports
com.badlogic.gdx.Gdx, com.badlogic.gdx.graphics.Pixmap.Blending, .Texture.TextureFilter, .Texture.TextureWrap, .TextureData.TextureDataType, com.badlogic.gdx.graphics.glutils.MipMapGenerator, com.badlogic.gdx.math.MathUtils, com.badlogic.gdx.utils.BufferUtils, .Disposable, java.nio.Buffer, .FloatBuffer

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

Modifier and TypeField and Description
protected float
protected int
public final int
glTarget

The target of this texture, used when binding the texture, e.g. GL_TEXTURE_2D

protected Texture.TextureFilter
private static float
protected Texture.TextureFilter
protected Texture.TextureWrap
protected Texture.TextureWrap

Constructor Summary

AccessConstructor and Description
public
GLTexture(int glTarget)

Generates a new OpenGL texture with the specified target.

public
GLTexture(int glTarget, int glHandle)

Method Summary

Modifier and TypeMethod and Description
public void
bind()

Binds this texture.

public void
bind(int
the unit (0 to MAX_TEXTURE_UNITS).
unit
)

Binds the texture to the given texture unit.

protected void
delete()

Destroys the OpenGL Texture as specified by the glHandle.

public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Releases all resources of this object.

public float
getAnisotropicFilter()

Returns: The currently set anisotropic filtering level for the texture, or 1.0f if none has been set.

public abstract int
getDepth()

Returns: the depth of the texture in pixels

public abstract int
getHeight()

Returns: the height of the texture in pixels

public Texture.TextureFilter
getMagFilter()

Returns: The Texture.TextureFilter used for magnification.

public static float
getMaxAnisotropicFilterLevel()

Returns: The maximum supported anisotropic filtering level supported by the device.

public Texture.TextureFilter
getMinFilter()

Returns: The Texture.TextureFilter used for minification.

public int
getTextureObjectHandle()

Returns: The OpenGL handle for this texture.

public Texture.TextureWrap
getUWrap()

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

public Texture.TextureWrap
getVWrap()

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

public abstract int
getWidth()

Returns: the width of the texture in pixels

public abstract boolean
isManaged()

Returns: whether this texture is managed or not.

protected abstract void
public float

Returns:

The actual level set, which may be lower than the provided value due to device limitations.
setAnisotropicFilter
(float
The desired level of filtering. The maximum level supported by the device up to this value will be used.
level
)

Sets the anisotropic filter level for the texture.

public void
setFilter(Texture.TextureFilter
the minification filter
minFilter
,
Texture.TextureFilter
the magnification filter
magFilter
)

Sets the TextureFilter for this texture for minification and magnification.

public void
setWrap(Texture.TextureWrap
the u wrap
u
,
Texture.TextureWrap
the v wrap
v
)

Sets the TextureWrap for this texture on the u and v axis.

public float

Returns:

The actual level set, which may be lower than the provided value due to device limitations.
unsafeSetAnisotropicFilter
(float
The desired level of filtering. The maximum level supported by the device up to this value will be used.
level
)

Sets the anisotropic filter level for the texture.

public float

Returns:

The actual level set, which may be lower than the provided value due to device limitations.
unsafeSetAnisotropicFilter
(float
The desired level of filtering. The maximum level supported by the device up to this value will be used.
level
,
boolean
True to always set the value, even if it is the same as the current values.
force
)

Sets the anisotropic filter level for the texture.

public void
unsafeSetFilter(Texture.TextureFilter
the minification filter
minFilter
,
Texture.TextureFilter
the magnification filter
magFilter
)

Sets the TextureFilter for this texture for minification and magnification.

public void
unsafeSetFilter(Texture.TextureFilter
the minification filter
minFilter
,
Texture.TextureFilter
the magnification filter
magFilter
,
boolean
True to always set the values, even if they are the same as the current values.
force
)

Sets the TextureFilter for this texture for minification and magnification.

public void
unsafeSetWrap(Texture.TextureWrap
the u wrap
u
,
Texture.TextureWrap
the v wrap
v
)

Sets the TextureWrap for this texture on the u and v axis.

public void
unsafeSetWrap(Texture.TextureWrap
the u wrap
u
,
Texture.TextureWrap
the v wrap
v
,
boolean
True to always set the values, even if they are the same as the current values.
force
)

Sets the TextureWrap for this texture on the u and v axis.

protected static void
uploadImageData(int target, TextureData data)

public static void
uploadImageData(int target, TextureData data, int miplevel)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

anisotropicFilterLevelback to summary
protected float anisotropicFilterLevel
glHandleback to summary
protected int glHandle
glTargetback to summary
public final int glTarget

The target of this texture, used when binding the texture, e.g. GL_TEXTURE_2D

magFilterback to summary
protected Texture.TextureFilter magFilter
maxAnisotropicFilterLevelback to summary
private static float maxAnisotropicFilterLevel
minFilterback to summary
protected Texture.TextureFilter minFilter
uWrapback to summary
protected Texture.TextureWrap uWrap
vWrapback to summary
protected Texture.TextureWrap vWrap

Constructor Detail

GLTextureback to summary
public GLTexture(int glTarget)

Generates a new OpenGL texture with the specified target.

GLTextureback to summary
public GLTexture(int glTarget, int glHandle)

Method Detail

bindback to summary
public void bind()

Binds this texture. The texture will be bound to the currently active texture unit specified via GL20#glActiveTexture(int).

bindback to summary
public void bind(int unit)

Binds the texture to the given texture unit. Sets the currently active texture unit via GL20#glActiveTexture(int).

Parameters
unit:int

the unit (0 to MAX_TEXTURE_UNITS).

deleteback to summary
protected void delete()

Destroys the OpenGL Texture as specified by the glHandle.

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Doc from com.badlogic.gdx.utils.Disposable.dispose.

Releases all resources of this object.

Annotations
@Override
getAnisotropicFilterback to summary
public float getAnisotropicFilter()
Returns:float

The currently set anisotropic filtering level for the texture, or 1.0f if none has been set.

getDepthback to summary
public abstract int getDepth()
Returns:int

the depth of the texture in pixels

getHeightback to summary
public abstract int getHeight()
Returns:int

the height of the texture in pixels

getMagFilterback to summary
public Texture.TextureFilter getMagFilter()
Returns:Texture.TextureFilter

The Texture.TextureFilter used for magnification.

getMaxAnisotropicFilterLevelback to summary
public static float getMaxAnisotropicFilterLevel()
Returns:float

The maximum supported anisotropic filtering level supported by the device.

getMinFilterback to summary
public Texture.TextureFilter getMinFilter()
Returns:Texture.TextureFilter

The Texture.TextureFilter used for minification.

getTextureObjectHandleback to summary
public int getTextureObjectHandle()
Returns:int

The OpenGL handle for this texture.

getUWrapback to summary
public Texture.TextureWrap getUWrap()
Returns:Texture.TextureWrap

The Texture.TextureWrap used for horizontal (U) texture coordinates.

getVWrapback to summary
public Texture.TextureWrap getVWrap()
Returns:Texture.TextureWrap

The Texture.TextureWrap used for vertical (V) texture coordinates.

getWidthback to summary
public abstract int getWidth()
Returns:int

the width of the texture in pixels

isManagedback to summary
public abstract boolean isManaged()
Returns:boolean

whether this texture is managed or not.

reloadback to summary
protected abstract void reload()
setAnisotropicFilterback to summary
public float setAnisotropicFilter(float level)

Sets the anisotropic filter level for the texture. This will bind the texture!

Parameters
level:float

The desired level of filtering. The maximum level supported by the device up to this value will be used.

Returns:float

The actual level set, which may be lower than the provided value due to device limitations.

setFilterback to summary
public void setFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)

Sets the TextureFilter for this texture for minification and magnification. This will bind this texture!

Parameters
minFilter:Texture.TextureFilter

the minification filter

magFilter:Texture.TextureFilter

the magnification filter

setWrapback to summary
public void setWrap(Texture.TextureWrap u, Texture.TextureWrap v)

Sets the TextureWrap for this texture on the u and v axis. This will bind this texture!

Parameters
u:Texture.TextureWrap

the u wrap

v:Texture.TextureWrap

the v wrap

unsafeSetAnisotropicFilterback to summary
public float unsafeSetAnisotropicFilter(float level)

Sets the anisotropic filter level for the texture. Assumes the texture is bound and active!

Parameters
level:float

The desired level of filtering. The maximum level supported by the device up to this value will be used.

Returns:float

The actual level set, which may be lower than the provided value due to device limitations.

unsafeSetAnisotropicFilterback to summary
public float unsafeSetAnisotropicFilter(float level, boolean force)

Sets the anisotropic filter level for the texture. Assumes the texture is bound and active!

Parameters
level:float

The desired level of filtering. The maximum level supported by the device up to this value will be used.

force:boolean

True to always set the value, even if it is the same as the current values.

Returns:float

The actual level set, which may be lower than the provided value due to device limitations.

unsafeSetFilterback to summary
public void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)

Sets the TextureFilter for this texture for minification and magnification. Assumes the texture is bound and active!

Parameters
minFilter:Texture.TextureFilter

the minification filter

magFilter:Texture.TextureFilter

the magnification filter

unsafeSetFilterback to summary
public void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force)

Sets the TextureFilter for this texture for minification and magnification. Assumes the texture is bound and active!

Parameters
minFilter:Texture.TextureFilter

the minification filter

magFilter:Texture.TextureFilter

the magnification filter

force:boolean

True to always set the values, even if they are the same as the current values.

unsafeSetWrapback to summary
public void unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v)

Sets the TextureWrap for this texture on the u and v axis. Assumes the texture is bound and active!

Parameters
u:Texture.TextureWrap

the u wrap

v:Texture.TextureWrap

the v wrap

unsafeSetWrapback to summary
public void unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v, boolean force)

Sets the TextureWrap for this texture on the u and v axis. Assumes the texture is bound and active!

Parameters
u:Texture.TextureWrap

the u wrap

v:Texture.TextureWrap

the v wrap

force:boolean

True to always set the values, even if they are the same as the current values.

uploadImageDataback to summary
protected static void uploadImageData(int target, TextureData data)
uploadImageDataback to summary
public static void uploadImageData(int target, TextureData data, int miplevel)