com.badlogic.gdx.graphics
Class Texture

java.lang.Object
  extended by com.badlogic.gdx.graphics.GLTexture
      extended by com.badlogic.gdx.graphics.Texture
All Implemented Interfaces:
Disposable

public class Texture
extends GLTexture

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 GLCommon.glActiveTexture(int).

You can draw Pixmaps 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

Author:
[email protected]

Nested Class Summary
static class Texture.TextureFilter
           
static class Texture.TextureWrap
           
 
Field Summary
 
Fields inherited from class com.badlogic.gdx.graphics.GLTexture
glTarget
 
Constructor Summary
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)
           
 
Method Summary
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.
 
Methods inherited from class com.badlogic.gdx.graphics.GLTexture
bind, bind, getEnforcePotImage, getMagFilter, getMinFilter, getTextureObjectHandle, getUWrap, getVWrap, setEnforcePotImages, setFilter, setWrap, unsafeSetFilter, unsafeSetFilter, unsafeSetWrap, unsafeSetWrap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Texture

public Texture(String internalPath)

Texture

public Texture(FileHandle file)

Texture

public Texture(FileHandle file,
               boolean useMipMaps)

Texture

public Texture(FileHandle file,
               Pixmap.Format format,
               boolean useMipMaps)

Texture

public Texture(Pixmap pixmap)

Texture

public Texture(Pixmap pixmap,
               boolean useMipMaps)

Texture

public Texture(Pixmap pixmap,
               Pixmap.Format format,
               boolean useMipMaps)

Texture

public Texture(int width,
               int height,
               Pixmap.Format format)

Texture

public Texture(TextureData data)
Method Detail

load

public void load(TextureData data)

draw

public void draw(Pixmap pixmap,
                 int x,
                 int y)
Draws the given 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!

Parameters:
pixmap - The Pixmap
x - The x coordinate in pixels
y - The y coordinate in pixels

getWidth

public int getWidth()
Specified by:
getWidth in class GLTexture
Returns:
the width of the texture in pixels

getHeight

public int getHeight()
Specified by:
getHeight in class GLTexture
Returns:
the height of the texture in pixels

getDepth

public int getDepth()
Specified by:
getDepth in class GLTexture
Returns:
the depth of the texture in pixels

getTextureData

public TextureData getTextureData()

isManaged

public boolean isManaged()
Specified by:
isManaged in class GLTexture
Returns:
whether this texture is managed or not.

dispose

public void dispose()
Disposes all resources associated with the texture

Specified by:
dispose in interface Disposable
Overrides:
dispose in class GLTexture

clearAllTextures

public static void clearAllTextures(Application app)
Clears all managed textures. This is an internal method. Do not use it!


invalidateAllTextures

public static void invalidateAllTextures(Application app)
Invalidate all managed textures. This is an internal method. Do not use it!


setAssetManager

public static void setAssetManager(AssetManager manager)
Sets the 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.

Parameters:
manager - the asset manager.

getManagedStatus

public static String getManagedStatus()

getNumManagedTextures

public static int getNumManagedTextures()
Returns:
the number of managed textures currently loaded


Copyright © 2013. All Rights Reserved.