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 floatanisotropicFilterLevelprotected intglHandleintglTargetThe target of this texture, used when binding the texture, e.g.protected Texture.TextureFiltermagFilterprotected Texture.TextureFilterminFilterprotected Texture.TextureWrapuWrapprotected Texture.TextureWrapvWrap
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidbind()Binds this texture.voidbind(int unit)Binds the texture to the given texture unit.protected voiddelete()Destroys the OpenGL Texture as specified by the glHandle.voiddispose()Releases all resources of this object.floatgetAnisotropicFilter()abstract intgetDepth()abstract intgetHeight()Texture.TextureFiltergetMagFilter()static floatgetMaxAnisotropicFilterLevel()Texture.TextureFiltergetMinFilter()intgetTextureObjectHandle()Texture.TextureWrapgetUWrap()Texture.TextureWrapgetVWrap()abstract intgetWidth()abstract booleanisManaged()protected abstract voidreload()floatsetAnisotropicFilter(float level)Sets the anisotropic filter level for the texture.voidsetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)Sets theTexture.TextureFilterfor this texture for minification and magnification.voidsetWrap(Texture.TextureWrap u, Texture.TextureWrap v)Sets theTexture.TextureWrapfor this texture on the u and v axis.floatunsafeSetAnisotropicFilter(float level)Sets the anisotropic filter level for the texture.floatunsafeSetAnisotropicFilter(float level, boolean force)Sets the anisotropic filter level for the texture.voidunsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter)Sets theTexture.TextureFilterfor this texture for minification and magnification.voidunsafeSetFilter(Texture.TextureFilter minFilter, Texture.TextureFilter magFilter, boolean force)Sets theTexture.TextureFilterfor this texture for minification and magnification.voidunsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v)Sets theTexture.TextureWrapfor this texture on the u and v axis.voidunsafeSetWrap(Texture.TextureWrap u, Texture.TextureWrap v, boolean force)Sets theTexture.TextureWrapfor this texture on the u and v axis.protected static voiduploadImageData(int target, TextureData data)static voiduploadImageData(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.TextureFilterused for minification.
-
getMagFilter
public Texture.TextureFilter getMagFilter()
- Returns:
- The
Texture.TextureFilterused for magnification.
-
getUWrap
public Texture.TextureWrap getUWrap()
- Returns:
- The
Texture.TextureWrapused for horizontal (U) texture coordinates.
-
getVWrap
public Texture.TextureWrap getVWrap()
- Returns:
- The
Texture.TextureWrapused 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.TextureWrapfor 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.TextureWrapfor 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.TextureWrapfor 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.TextureFilterfor 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.TextureFilterfor 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.TextureFilterfor 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:DisposableReleases all resources of this object.- Specified by:
disposein interfaceDisposable
-
uploadImageData
protected static void uploadImageData(int target, TextureData data)
-
uploadImageData
public static void uploadImageData(int target, TextureData data, int miplevel)
-
-