Package arc.graphics

Class 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 GL20.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

  • Constructor Details

    • Texture

      public Texture(String internalPath)
    • Texture

      public Texture(Fi file)
    • Texture

      public Texture(Fi file, boolean useMipMaps)
    • Texture

      public Texture(Pixmap pixmap)
    • Texture

      public Texture(Pixmap pixmap, boolean useMipMaps)
    • Texture

      public Texture(int width, int height)
    • Texture

      public Texture(TextureData data)
    • Texture

      protected Texture()
      For use in mocking only!
    • Texture

      protected Texture(int glTarget, int glHandle, TextureData data)
  • Method Details

    • createEmpty

      public static Texture createEmpty(TextureData data)
    • load

      public void load(TextureData data)
    • draw

      public void draw(Pixmap pixmap)
    • 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
    • getDepth

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

      public TextureData getTextureData()
    • isDisposed

      public boolean isDisposed()
    • toString

      public String toString()
      Overrides:
      toString in class Object