Package arc.graphics

Interface TextureData

All Known Implementing Classes:
FileTextureData, FloatTextureData, GLOnlyTextureData, MipMapTextureData, PixmapTextureData

public interface TextureData
Used by a Texture to load the pixel data. A TextureData can either return a Pixmap or upload the pixel data itself. It signals it's type via isCustom() to the Texture that's using it. The Texture will then either invoke consumePixmap() or consumeCustomData(int). These are the first methods to be called by Texture. After that the Texture will invoke the other methods to find out about the size of the image data, the format, whether mipmaps should be generated and whether the TextureData is able to manage the pixel data if the OpenGL ES context is lost.

In case the TextureData implementation is custom, the implementation has to generate the mipmaps itself if necessary. See MipMapGenerator.

Before a call to either consumePixmap() or consumeCustomData(int), Texture will bind the OpenGL ES texture.

Look at FileTextureData for example implementations of this interface.

  • Method Details

    • isCustom

      boolean isCustom()
      Returns:
      whether to use #consumeCustomData
    • isPrepared

      boolean isPrepared()
      Returns:
      whether the TextureData is prepared or not.
    • prepare

      void prepare()
      Prepares the TextureData for a call to consumePixmap() or consumeCustomData(int). This method can be called from a non OpenGL thread and should thus not interact with OpenGL.
    • consumePixmap

      Pixmap consumePixmap()
      Returns the Pixmap for upload by Texture. A call to prepare() must precede a call to this method. Any internal data structures created in prepare() should be disposed of here.
      Returns:
      the pixmap.
    • getPixmap

      default Pixmap getPixmap()
    • disposePixmap

      boolean disposePixmap()
      Returns:
      whether the caller of consumePixmap() should dispose the Pixmap returned by consumePixmap()
    • consumeCustomData

      void consumeCustomData(int target)
      Uploads the pixel data to the OpenGL ES texture. The caller must bind an OpenGL ES texture. A call to prepare() must precede a call to this method. Any internal data structures created in prepare() should be disposed of here.
    • getWidth

      int getWidth()
      Returns:
      the width of the pixel data
    • getHeight

      int getHeight()
      Returns:
      the height of the pixel data
    • getFormat

      Pixmap.Format getFormat()
      Returns:
      the Pixmap.Format of the pixel data
    • useMipMaps

      boolean useMipMaps()
      Returns:
      whether to generate mipmaps or not.
    • load

      static TextureData load(Fi file, boolean useMipMaps)