Class KTXTextureData
- java.lang.Object
-
- com.badlogic.gdx.graphics.glutils.KTXTextureData
-
- All Implemented Interfaces:
CubemapData
,TextureData
public class KTXTextureData extends java.lang.Object implements TextureData, CubemapData
A KTXTextureData holds the data from a KTX (or zipped KTX file, aka ZKTX). That is to say an OpenGL ready texture data. The KTX file format is just a thin wrapper around OpenGL textures and therefore is compatible with most OpenGL texture capabilities like texture compression, cubemapping, mipmapping, etc. For example, KTXTextureData can be used forTexture
orCubemap
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.badlogic.gdx.graphics.TextureData
TextureData.Factory, TextureData.TextureDataType
-
-
Constructor Summary
Constructors Constructor Description KTXTextureData(FileHandle file, boolean genMipMaps)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
consumeCubemapData()
Uploads the pixel data for the 6 faces of the cube to the OpenGL ES texture.void
consumeCustomData(int target)
Uploads the pixel data to the OpenGL ES texture.Pixmap
consumePixmap()
Returns thePixmap
for upload by Texture.boolean
disposePixmap()
void
disposePreparedData()
java.nio.ByteBuffer
getData(int requestedLevel, int requestedFace)
Pixmap.Format
getFormat()
int
getGlInternalFormat()
int
getHeight()
int
getNumberOfFaces()
int
getNumberOfMipMapLevels()
TextureData.TextureDataType
getType()
int
getWidth()
boolean
isManaged()
boolean
isPrepared()
void
prepare()
Prepares the TextureData for a call toTextureData.consumePixmap()
orTextureData.consumeCustomData(int)
.boolean
useMipMaps()
-
-
-
Constructor Detail
-
KTXTextureData
public KTXTextureData(FileHandle file, boolean genMipMaps)
-
-
Method Detail
-
getType
public TextureData.TextureDataType getType()
- Specified by:
getType
in interfaceTextureData
- Returns:
- the
TextureData.TextureDataType
-
isPrepared
public boolean isPrepared()
- Specified by:
isPrepared
in interfaceCubemapData
- Specified by:
isPrepared
in interfaceTextureData
- Returns:
- whether the TextureData is prepared or not.
-
prepare
public void prepare()
Description copied from interface:TextureData
Prepares the TextureData for a call toTextureData.consumePixmap()
orTextureData.consumeCustomData(int)
. This method can be called from a non OpenGL thread and should thus not interact with OpenGL.- Specified by:
prepare
in interfaceCubemapData
- Specified by:
prepare
in interfaceTextureData
-
consumeCubemapData
public void consumeCubemapData()
Description copied from interface:CubemapData
Uploads the pixel data for the 6 faces of the cube to the OpenGL ES texture. The caller must bind an OpenGL ES texture. A call toCubemapData.prepare()
must preceed a call to this method. Any internal data structures created inCubemapData.prepare()
should be disposed of here.- Specified by:
consumeCubemapData
in interfaceCubemapData
-
consumeCustomData
public void consumeCustomData(int target)
Description copied from interface:TextureData
Uploads the pixel data to the OpenGL ES texture. The caller must bind an OpenGL ES texture. A call toTextureData.prepare()
must preceed a call to this method. Any internal data structures created inTextureData.prepare()
should be disposed of here.- Specified by:
consumeCustomData
in interfaceTextureData
-
disposePreparedData
public void disposePreparedData()
-
consumePixmap
public Pixmap consumePixmap()
Description copied from interface:TextureData
Returns thePixmap
for upload by Texture. A call toTextureData.prepare()
must precede a call to this method. Any internal data structures created inTextureData.prepare()
should be disposed of here.- Specified by:
consumePixmap
in interfaceTextureData
- Returns:
- the pixmap.
-
disposePixmap
public boolean disposePixmap()
- Specified by:
disposePixmap
in interfaceTextureData
- Returns:
- whether the caller of
TextureData.consumePixmap()
should dispose the Pixmap returned byTextureData.consumePixmap()
-
getWidth
public int getWidth()
- Specified by:
getWidth
in interfaceCubemapData
- Specified by:
getWidth
in interfaceTextureData
- Returns:
- the width of the pixel data
-
getHeight
public int getHeight()
- Specified by:
getHeight
in interfaceCubemapData
- Specified by:
getHeight
in interfaceTextureData
- Returns:
- the height of the pixel data
-
getNumberOfMipMapLevels
public int getNumberOfMipMapLevels()
-
getNumberOfFaces
public int getNumberOfFaces()
-
getGlInternalFormat
public int getGlInternalFormat()
-
getData
public java.nio.ByteBuffer getData(int requestedLevel, int requestedFace)
-
getFormat
public Pixmap.Format getFormat()
- Specified by:
getFormat
in interfaceTextureData
- Returns:
- the
Pixmap.Format
of the pixel data
-
useMipMaps
public boolean useMipMaps()
- Specified by:
useMipMaps
in interfaceTextureData
- Returns:
- whether to generate mipmaps or not.
-
isManaged
public boolean isManaged()
- Specified by:
isManaged
in interfaceCubemapData
- Specified by:
isManaged
in interfaceTextureData
- Returns:
- whether this implementation can cope with a EGL context loss.
-
-