Class DecalBatch
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.decals.DecalBatch
-
- All Implemented Interfaces:
Disposable
public class DecalBatch extends java.lang.Object implements Disposable
Renderer for
Decal
objects.New objects are added using
add(Decal)
, there is no limit on how many decals can be added.
Once all the decals have been submitted a call toflush()
will batch them together and send big chunks of geometry to the GL.The size of the batch specifies the maximum number of decals that can be batched together before they have to be submitted to the graphics pipeline. The default size is
DEFAULT_SIZE
. If it is known before hand that not as many will be needed on average the batch can be downsized to save memory. If the game is basically 3d based and decals will only be needed for an orthogonal HUD it makes sense to tune the size down.The way the batch handles things depends on the
GroupStrategy
. Different strategies can be used to customize shaders, states, culling etc. for more details see theGroupStrategy
java doc.
While it shouldn't be necessary to change strategies, if you have to do so, do it before callingadd(Decal)
, and if you already did, callflush()
first.
-
-
Constructor Summary
Constructors Constructor Description DecalBatch(int size, GroupStrategy groupStrategy)
DecalBatch(GroupStrategy groupStrategy)
Creates a new DecalBatch using the givenGroupStrategy
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Decal decal)
Add a decal to the batch, marking it for later renderingprotected void
clear()
Remove all decals from batchvoid
dispose()
Frees up memory by dropping the buffer and underlying resources.void
flush()
Flush this batch sending all contained decals to GL.protected void
flush(ShaderProgram shader, int verticesPosition)
Flushes vertices[0,verticesPosition[ to GL verticesPosition % Decal.SIZE must equal 0int
getSize()
void
initialize(int size)
Initializes the batch with the given amount of decal objects the buffer is able to hold when full.protected void
render()
Renders all decals to the buffer and flushes the buffer to the GL when full/donevoid
setGroupStrategy(GroupStrategy groupStrategy)
Sets theGroupStrategy
used
-
-
-
Constructor Detail
-
DecalBatch
public DecalBatch(GroupStrategy groupStrategy)
Creates a new DecalBatch using the givenGroupStrategy
. The most commong strategy to use is aCameraGroupStrategy
- Parameters:
groupStrategy
-
-
DecalBatch
public DecalBatch(int size, GroupStrategy groupStrategy)
-
-
Method Detail
-
setGroupStrategy
public void setGroupStrategy(GroupStrategy groupStrategy)
Sets theGroupStrategy
used- Parameters:
groupStrategy
- Group strategy to use
-
initialize
public void initialize(int size)
Initializes the batch with the given amount of decal objects the buffer is able to hold when full.- Parameters:
size
- Maximum size of decal objects to hold in memory
-
getSize
public int getSize()
- Returns:
- maximum amount of decal objects this buffer can hold in memory
-
add
public void add(Decal decal)
Add a decal to the batch, marking it for later rendering- Parameters:
decal
- Decal to add for rendering
-
flush
public void flush()
Flush this batch sending all contained decals to GL. After flushing the batch is empty once again.
-
render
protected void render()
Renders all decals to the buffer and flushes the buffer to the GL when full/done
-
flush
protected void flush(ShaderProgram shader, int verticesPosition)
Flushes vertices[0,verticesPosition[ to GL verticesPosition % Decal.SIZE must equal 0- Parameters:
verticesPosition
- Amount of elements from the vertices array to flush
-
clear
protected void clear()
Remove all decals from batch
-
dispose
public void dispose()
Frees up memory by dropping the buffer and underlying resources. If the batch is needed again after disposing it can beinitialized
again.- Specified by:
dispose
in interfaceDisposable
-
-