public abstract class Batchable
extends java.lang.Object
implements com.badlogic.gdx.utils.Pool.Poolable
| Modifier and Type | Class and Description |
|---|---|
static class |
Batchable.FixedSizeBatchable
Parent class for Batchables that all have the same number of vertices and triangles.
|
| Constructor and Description |
|---|
Batchable() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addVertexAttributes(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes)
A Batchable implementation calls this to populate a list of vertex attributes that will be used by the FlexBatch.
|
protected abstract int |
apply(float[] vertices,
int startingIndex,
AttributeOffsets offsets,
int vertexSize)
Called by FlexBatch.
|
protected abstract int |
apply(short[] triangles,
int startingIndex,
short firstVertex)
Called by FlexBatch.
|
protected abstract int |
getNumberOfTextures() |
protected abstract boolean |
prepareContext(RenderContextAccumulator renderContext,
int remainingVertices,
int remainingIndices)
Called before
apply(float[], int, AttributeOffsets, int) to set render context states and texture bindings, and to
determine if a flush is necessary before this Batchable can be drawn. |
protected void |
prepareSharedContext(RenderContextAccumulator renderContext)
Prepares the rendering context for this type of Batchable to be drawn.
|
abstract void |
refresh()
Resets the state and default parameters of the Batchable so it can be reused for an entirely new image.
|
protected void prepareSharedContext(RenderContextAccumulator renderContext)
begin(),
executeChanges(), or end() on
renderContext, as these are handled by the FlexBatch. It should not change anything in a way that is unique to any
particular instance of this Batchable type.renderContext - The FlexBatch's manager of GL state changes and texture bindings.protected abstract boolean prepareContext(RenderContextAccumulator renderContext, int remainingVertices, int remainingIndices)
apply(float[], int, AttributeOffsets, int) to set render context states and texture bindings, and to
determine if a flush is necessary before this Batchable can be drawn.
Overriding this method may produce a subclass that is incompatible with a FlexBatch that was instantiated for the superclass
type.renderContext - The FlexBatch's manager of GL state changes and texture bindings. Pending state changes and texture
bindings can be made on this context, and the context will return whether the context is now changed, which means
a flush is required and this method needs to return true.remainingVertices - The number of vertices that can be drawn before the next flush is required.remainingIndices - The number of triangle indices that can be drawn before the next flush is required. This value is
undefined for Batchable.FixedSizeBatchable and should not be used or checked against.protected abstract void addVertexAttributes(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes)
attributes - An array to which attributes can be added.protected abstract int getNumberOfTextures()
public abstract void refresh()
protected abstract int apply(float[] vertices,
int startingIndex,
AttributeOffsets offsets,
int vertexSize)
vertices - startingIndex - offsets - The offsets of the vertex attributes.vertexSize - The size of a vertex in floats.Batchable.FixedSizeBatchable, as it is
assumed to match Batchable.FixedSizeBatchable.getVerticesPerBatchable().protected abstract int apply(short[] triangles,
int startingIndex,
short firstVertex)
FixedSizeBatchables.
Overriding this method may produce a subclass that is incompatible with a FlexBatch that was instantiated for the superclass
type.triangles - startingIndex - firstVertex - The first vertex value that should be used.