Package com.badlogic.gdx.graphics
Class GLTexture
- java.lang.Object
-
- com.badlogic.gdx.graphics.GLTexture
-
- All Implemented Interfaces:
Disposable
- Direct Known Subclasses:
Cubemap
,Texture
,Texture3D
,TextureArray
public abstract class GLTexture extends java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description protected float
anisotropicFilterLevel
protected int
glHandle
int
glTarget
The target of this texture, used when binding the texture, e.g.protected Texture.TextureFilter
magFilter
protected Texture.TextureFilter
minFilter
protected Texture.TextureWrap
uWrap
protected Texture.TextureWrap
vWrap
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
bind()
Binds this texture.void
bind(int unit)
Binds the texture to the given texture unit.protected void
delete()
Destroys the OpenGL Texture as specified by the glHandle.void
dispose()
Releases all resources of this object.float
getAnisotropicFilter()
abstract int
getDepth()
abstract int
getHeight()
Texture.TextureFilter
getMagFilter()
static float
getMaxAnisotropicFilterLevel()
Texture.TextureFilter
getMinFilter()
int
getTextureObjectHandle()
Texture.TextureWrap
getUWrap()
Texture.TextureWrap
getVWrap()
abstract int
getWidth()
abstract boolean
isManaged()
protected abstract void
reload()
float
setAnisotropicFilter(float level)
Sets the anisotropic filter level for the texture.void
setFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)
Sets theTexture.TextureFilter
for this texture for minification and magnification.void
setWrap(Texture.TextureWrap u, Texture.TextureWrap v)
Sets theTexture.TextureWrap
for this texture on the u and v axis.float
unsafeSetAnisotropicFilter(float level)
Sets the anisotropic filter level for the texture.float
unsafeSetAnisotropicFilter(float level, boolean force)
Sets the anisotropic filter level for the texture.void
unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)
Sets theTexture.TextureFilter
for this texture for minification and magnification.void
unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force)
Sets theTexture.TextureFilter
for this texture for minification and magnification.void
unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v)
Sets theTexture.TextureWrap
for this texture on the u and v axis.void
unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v, boolean force)
Sets theTexture.TextureWrap
for this texture on the u and v axis.protected static void
uploadImageData(int target, TextureData data)
static void
uploadImageData(int target, TextureData data, int miplevel)
-
-
-
Field Detail
-
glTarget
public final int glTarget
The target of this texture, used when binding the texture, e.g. GL_TEXTURE_2D
-
glHandle
protected int glHandle
-
minFilter
protected Texture.TextureFilter minFilter
-
magFilter
protected Texture.TextureFilter magFilter
-
uWrap
protected Texture.TextureWrap uWrap
-
vWrap
protected Texture.TextureWrap vWrap
-
anisotropicFilterLevel
protected float anisotropicFilterLevel
-
-
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.
-
reload
protected abstract void reload()
-
bind
public void bind()
Binds this texture. The texture will be bound to the currently active texture unit specified viaGL20.glActiveTexture(int)
.
-
bind
public void bind(int unit)
Binds the texture to the given texture unit. Sets the currently active texture unit viaGL20.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 theTexture.TextureWrap
for this texture on the u and v axis. Assumes the texture is bound and active!- Parameters:
u
- the u wrapv
- the v wrap
-
unsafeSetWrap
public void unsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v, boolean force)
Sets theTexture.TextureWrap
for this texture on the u and v axis. Assumes the texture is bound and active!- Parameters:
u
- the u wrapv
- the v wrapforce
- 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 theTexture.TextureWrap
for this texture on the u and v axis. This will bind this texture!- Parameters:
u
- the u wrapv
- the v wrap
-
unsafeSetFilter
public void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)
Sets theTexture.TextureFilter
for this texture for minification and magnification. Assumes the texture is bound and active!- Parameters:
minFilter
- the minification filtermagFilter
- the magnification filter
-
unsafeSetFilter
public void unsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force)
Sets theTexture.TextureFilter
for this texture for minification and magnification. Assumes the texture is bound and active!- Parameters:
minFilter
- the minification filtermagFilter
- the magnification filterforce
- 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 theTexture.TextureFilter
for this texture for minification and magnification. This will bind this texture!- Parameters:
minFilter
- the minification filtermagFilter
- the magnification filter
-
unsafeSetAnisotropicFilter
public float unsafeSetAnisotropicFilter(float level)
Sets the anisotropic filter level for the texture. Assumes the texture is bound and active!- Parameters:
level
- The desired level of filtering. The maximum level supported by the device up to this value will be used.- Returns:
- The actual level set, which may be lower than the provided value due to device limitations.
-
unsafeSetAnisotropicFilter
public float unsafeSetAnisotropicFilter(float level, boolean force)
Sets the anisotropic filter level for the texture. Assumes the texture is bound and active!- Parameters:
level
- The desired level of filtering. The maximum level supported by the device up to this value will be used.force
- True to always set the value, even if it is the same as the current values.- Returns:
- The actual level set, which may be lower than the provided value due to device limitations.
-
setAnisotropicFilter
public float setAnisotropicFilter(float level)
Sets the anisotropic filter level for the texture. This will bind the texture!- Parameters:
level
- The desired level of filtering. The maximum level supported by the device up to this value will be used.- Returns:
- The actual level set, which may be lower than the provided value due to device limitations.
-
getAnisotropicFilter
public float getAnisotropicFilter()
- Returns:
- The currently set anisotropic filtering level for the texture, or 1.0f if none has been set.
-
getMaxAnisotropicFilterLevel
public static float getMaxAnisotropicFilterLevel()
- Returns:
- The maximum supported anisotropic filtering level supported by the device.
-
delete
protected void delete()
Destroys the OpenGL Texture as specified by the glHandle.
-
dispose
public void dispose()
Description copied from interface:Disposable
Releases all resources of this object.- Specified by:
dispose
in interfaceDisposable
-
uploadImageData
protected static void uploadImageData(int target, TextureData data)
-
uploadImageData
public static void uploadImageData(int target, TextureData data, int miplevel)
-
-