Package playn.core
Class Texture
java.lang.Object
playn.core.TileSource
playn.core.Tile
playn.core.Texture
- All Implemented Interfaces:
AutoCloseable,Closeable
A handle to an OpenGL texture. A texture is also a
Tile which contains the entire
texture, which allows rendering methods to operate uniformly on tiles.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classUsed to configure texture at creation time.Nested classes/interfaces inherited from interface react.Closeable
Closeable.Set, Closeable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Texture.ConfigThis texture's configuration.final floatThe height of this texture in display units.final floatThe width of this texture in display units.final intThe GL texture handle.final intThe height of this texture in pixels.final intThe width of this texture in pixels.final ScaleThe scale factor used by this texture. -
Constructor Summary
ConstructorsConstructorDescriptionTexture(Graphics gfx, int id, Texture.Config config, int pixWidth, int pixHeight, Scale scale, float dispWidth, float dispHeight) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToBatch(QuadBatch batch, int tint, AffineTransform tx, float x, float y, float width, float height) Adds this tile to the supplied quad batch.voidaddToBatch(QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) Adds this tile to the supplied quad batch.voidclose()Deletes this texture's GPU resources and renders it unusable.booleandisposed()Returns whether this texture is been disposed.Returns aSlotthat will dispose this texture when triggered.floatheight()The height of this tile (in display units).static intnextPOT(int value) Returns next largest power of two, orvalueifvalueis already a POT.voidIncrements this texture's reference count.voidrelease()Decrements this texture's reference count.floatsx()Returns thestexture coordinate for the x-axis.floatsy()Returns thestexture coordinate for the y-axis.texture()The texture which contains this tile.tile(float x, float y, float width, float height) Returns an instance that can be used to render a sub-region of this texture.tile(IRectangle region) Returns an instance that can be used to render a sub-region of this texture.toString()floattx()Returns thettexture coordinate for the x-axis.floatty()Returns thettexture coordinate for the y-axis.voidUploadsimageto this texture's GPU memory.floatwidth()The width of this tile (in display units).
-
Field Details
-
id
public final int idThe GL texture handle. -
config
This texture's configuration. -
pixelWidth
public final int pixelWidthThe width of this texture in pixels. -
pixelHeight
public final int pixelHeightThe height of this texture in pixels. -
scale
The scale factor used by this texture. -
displayWidth
public final float displayWidthThe width of this texture in display units. -
displayHeight
public final float displayHeightThe height of this texture in display units.
-
-
Constructor Details
-
Texture
public Texture(Graphics gfx, int id, Texture.Config config, int pixWidth, int pixHeight, Scale scale, float dispWidth, float dispHeight)
-
-
Method Details
-
nextPOT
public static int nextPOT(int value) Returns next largest power of two, orvalueifvalueis already a POT. Note: this is limited to values less than0x10000. -
reference
public void reference()Increments this texture's reference count. NOOP unlessTexture.Config.managed. -
release
public void release()Decrements this texture's reference count. If the reference count of a managed texture goes to zero, the texture is disposed (and is no longer usable). -
update
Uploadsimageto this texture's GPU memory.imagemust have the exact same size as this texture and must be fully loaded. This is generally useful for updating a texture which was created from a canvas when the canvas has been changed. -
tile
Returns an instance that can be used to render a sub-region of this texture. -
tile
Returns an instance that can be used to render a sub-region of this texture. -
disposed
public boolean disposed()Returns whether this texture is been disposed. -
disposeSlot
Returns aSlotthat will dispose this texture when triggered.This is useful when you want to manually bind the lifecycle of an unmanaged texture to the lifecycle of a layer. Simply `layer.onDisposed(texture.disposeSlot())`.
-
texture
Description copied from class:TileThe texture which contains this tile. -
width
public float width()Description copied from class:TileThe width of this tile (in display units). -
height
public float height()Description copied from class:TileThe height of this tile (in display units). -
sx
public float sx()Description copied from class:TileReturns thestexture coordinate for the x-axis. -
sy
public float sy()Description copied from class:TileReturns thestexture coordinate for the y-axis. -
tx
public float tx()Description copied from class:TileReturns thettexture coordinate for the x-axis. -
ty
public float ty()Description copied from class:TileReturns thettexture coordinate for the y-axis. -
addToBatch
public void addToBatch(QuadBatch batch, int tint, AffineTransform tx, float x, float y, float width, float height) Description copied from class:TileAdds this tile to the supplied quad batch.- Specified by:
addToBatchin classTile
-
addToBatch
public void addToBatch(QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) Description copied from class:TileAdds this tile to the supplied quad batch.- Specified by:
addToBatchin classTile
-
close
public void close()Deletes this texture's GPU resources and renders it unusable.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
toString
-