public class Texture extends GLTexture
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
Modifier and Type | Class and Description |
---|---|
static class |
Texture.TextureFilter |
static class |
Texture.TextureWrap |
Constructor and Description |
---|
Texture(FileHandle file) |
Texture(FileHandle file,
boolean useMipMaps) |
Texture(FileHandle file,
Pixmap.Format format,
boolean useMipMaps) |
Texture(int width,
int height,
Pixmap.Format format) |
Texture(Pixmap pixmap) |
Texture(Pixmap pixmap,
boolean useMipMaps) |
Texture(Pixmap pixmap,
Pixmap.Format format,
boolean useMipMaps) |
Texture(String internalPath) |
Texture(TextureData data) |
Modifier and Type | Method and Description |
---|---|
static void |
clearAllTextures(Application app)
Clears all managed textures.
|
void |
dispose()
Disposes all resources associated with the texture
|
void |
draw(Pixmap pixmap,
int x,
int y)
Draws the given
Pixmap to the texture at position x, y. |
int |
getDepth() |
int |
getHeight() |
static String |
getManagedStatus() |
static int |
getNumManagedTextures() |
TextureData |
getTextureData() |
int |
getWidth() |
static void |
invalidateAllTextures(Application app)
Invalidate all managed textures.
|
boolean |
isManaged() |
void |
load(TextureData data) |
static void |
setAssetManager(AssetManager manager)
Sets the
AssetManager . |
bind, bind, getMagFilter, getMinFilter, getTextureObjectHandle, getUWrap, getVWrap, setFilter, setWrap, unsafeSetFilter, unsafeSetFilter, unsafeSetWrap, unsafeSetWrap, uploadImageData
public Texture(String internalPath)
public Texture(FileHandle file)
public Texture(FileHandle file, boolean useMipMaps)
public Texture(FileHandle file, Pixmap.Format format, boolean useMipMaps)
public Texture(Pixmap pixmap)
public Texture(Pixmap pixmap, boolean useMipMaps)
public Texture(Pixmap pixmap, Pixmap.Format format, boolean useMipMaps)
public Texture(int width, int height, Pixmap.Format format)
public Texture(TextureData data)
public void load(TextureData data)
public void draw(Pixmap pixmap, int x, int y)
Pixmap
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!pixmap
- The Pixmapx
- The x coordinate in pixelsy
- The y coordinate in pixelspublic int getWidth()
public int getHeight()
public int getDepth()
public TextureData getTextureData()
public boolean isManaged()
public void dispose()
dispose
in interface Disposable
dispose
in class GLTexture
public static void clearAllTextures(Application app)
public static void invalidateAllTextures(Application app)
public static void setAssetManager(AssetManager manager)
AssetManager
. When the context is lost, textures managed by the asset manager are reloaded by the manager
on a separate thread (provided that a suitable AssetLoader
is registered with the manager). Textures not managed by
the AssetManager are reloaded via the usual means on the rendering thread.manager
- the asset manager.public static String getManagedStatus()
public static int getNumManagedTextures()
Copyright © 2015. All rights reserved.