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 class
Used to configure texture at creation time.Nested classes/interfaces inherited from interface react.Closeable
Closeable.Set, Closeable.Util
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Texture.Config
This texture's configuration.final float
The height of this texture in display units.final float
The width of this texture in display units.final int
The GL texture handle.final int
The height of this texture in pixels.final int
The width of this texture in pixels.final Scale
The 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 TypeMethodDescriptionvoid
addToBatch
(QuadBatch batch, int tint, AffineTransform tx, float x, float y, float width, float height) Adds this tile to the supplied quad batch.void
addToBatch
(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.void
close()
Deletes this texture's GPU resources and renders it unusable.boolean
disposed()
Returns whether this texture is been disposed.Returns aSlot
that will dispose this texture when triggered.float
height()
The height of this tile (in display units).static int
nextPOT
(int value) Returns next largest power of two, orvalue
ifvalue
is already a POT.void
Increments this texture's reference count.void
release()
Decrements this texture's reference count.float
sx()
Returns thes
texture coordinate for the x-axis.float
sy()
Returns thes
texture 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()
float
tx()
Returns thet
texture coordinate for the x-axis.float
ty()
Returns thet
texture coordinate for the y-axis.void
Uploadsimage
to this texture's GPU memory.float
width()
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, orvalue
ifvalue
is 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
Uploadsimage
to this texture's GPU memory.image
must 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 aSlot
that 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:Tile
The texture which contains this tile. -
width
public float width()Description copied from class:Tile
The width of this tile (in display units). -
height
public float height()Description copied from class:Tile
The height of this tile (in display units). -
sx
public float sx()Description copied from class:Tile
Returns thes
texture coordinate for the x-axis. -
sy
public float sy()Description copied from class:Tile
Returns thes
texture coordinate for the y-axis. -
tx
public float tx()Description copied from class:Tile
Returns thet
texture coordinate for the x-axis. -
ty
public float ty()Description copied from class:Tile
Returns thet
texture 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:Tile
Adds this tile to the supplied quad batch.- Specified by:
addToBatch
in 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:Tile
Adds this tile to the supplied quad batch.- Specified by:
addToBatch
in classTile
-
close
public void close()Deletes this texture's GPU resources and renders it unusable.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
toString
-