Package com.badlogic.gdx.graphics
Class Texture
java.lang.Object
com.badlogic.gdx.graphics.GLTexture
com.badlogic.gdx.graphics.Texture
- All Implemented Interfaces:
Disposable
A Texture wraps a standard OpenGL ES texture.
A Texture can be managed. If the OpenGL context is lost all managed textures get invalidated. This happens when a user switches to another application or receives an incoming call. Managed textures get reloaded automatically.
A Texture has to be bound via the GLTexture.bind()
method in order for it to be applied to geometry. The texture will be
bound to the currently active texture unit specified via GL20.glActiveTexture(int)
.
You can draw Pixmap
s to a texture at any time. The changes will be automatically uploaded to texture memory. This is of
course not extremely fast so use it with care. It also only works with unmanaged textures.
A Texture must be disposed when it is no longer used
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static enum
-
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Texture()
Texture
(int width, int height, Pixmap.Format format) protected
Texture
(int glTarget, int glHandle, TextureData data) Texture
(FileHandle file) Texture
(FileHandle file, boolean useMipMaps) Texture
(FileHandle file, Pixmap.Format format, boolean useMipMaps) Texture
(Pixmap pixmap, Pixmap.Format format, boolean useMipMaps) Texture
(TextureData data) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears all managed textures.void
dispose()
Disposes all resources associated with the texturevoid
Draws the givenPixmap
to the texture at position x, y.int
getDepth()
int
static String
static int
int
getWidth()
static void
Invalidate all managed textures.boolean
void
load
(TextureData data) protected void
reload()
Used internally to reload after context loss.static void
setAssetManager
(AssetManager manager) Sets theAssetManager
.toString()
Methods inherited from class com.badlogic.gdx.graphics.GLTexture
bind, bind, delete, getAnisotropicFilter, getMagFilter, getMaxAnisotropicFilterLevel, getMinFilter, getTextureObjectHandle, getUWrap, getVWrap, setAnisotropicFilter, setFilter, setWrap, unsafeSetAnisotropicFilter, unsafeSetAnisotropicFilter, unsafeSetFilter, unsafeSetFilter, unsafeSetWrap, unsafeSetWrap, uploadImageData, uploadImageData
-
Constructor Details
-
Texture
protected Texture() -
Texture
-
Texture
-
Texture
-
Texture
-
Texture
-
Texture
-
Texture
-
Texture
-
Texture
-
Texture
-
-
Method Details
-
load
-
reload
protected void reload()Used internally to reload after context loss. Creates a new GL handle then callsload(TextureData)
. Use this only if you know what you do! -
draw
Draws the givenPixmap
to the texture at position x, y. No clipping is performed so you have to make sure that you draw only inside the texture region. Note that this will only draw to mipmap level 0!- Parameters:
pixmap
- The Pixmapx
- The x coordinate in pixelsy
- The y coordinate in pixels
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getDepth
public int getDepth() -
getTextureData
-
isManaged
public boolean isManaged() -
dispose
public void dispose()Disposes all resources associated with the texture- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classGLTexture
-
toString
-
clearAllTextures
Clears all managed textures. This is an internal method. Do not use it! -
invalidateAllTextures
Invalidate all managed textures. This is an internal method. Do not use it! -
setAssetManager
Sets theAssetManager
. When the context is lost, textures managed by the asset manager are reloaded by the manager on a separate thread (provided that a suitableAssetLoader
is registered with the manager). Textures not managed by the AssetManager are reloaded via the usual means on the rendering thread.- Parameters:
manager
- the asset manager.
-
getManagedStatus
-
getNumManagedTextures
public static int getNumManagedTextures()- Returns:
- the number of managed textures currently loaded
-