public class DecalBatch extends 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 to flush()
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 the GroupStrategy
java doc.
While it shouldn't be necessary to change strategies, if you have to do so, do it before calling add(Decal)
, and if
you already did, call flush()
first.
Constructor and Description |
---|
DecalBatch()
Creates a new batch using the
DefaultGroupStrategy |
DecalBatch(GroupStrategy groupStrategy) |
DecalBatch(int size,
GroupStrategy groupStrategy) |
Modifier and Type | Method and Description |
---|---|
void |
add(Decal decal)
Add a decal to the batch, marking it for later rendering
|
void |
dispose()
Frees up memory by dropping the buffer and underlying resources.
|
void |
flush()
Flush this batch sending all contained decals to GL.
|
int |
getSize() |
void |
initialize(int size)
Initializes the batch with the given amount of decal objects the buffer is able to hold when full.
|
void |
setGroupStrategy(GroupStrategy groupStrategy)
Sets the
GroupStrategy used |
public DecalBatch()
DefaultGroupStrategy
public DecalBatch(GroupStrategy groupStrategy)
public DecalBatch(int size, GroupStrategy groupStrategy)
public void setGroupStrategy(GroupStrategy groupStrategy)
GroupStrategy
usedgroupStrategy
- Group strategy to usepublic void initialize(int size)
size
- Maximum size of decal objects to hold in memorypublic int getSize()
public void add(Decal decal)
decal
- Decal to add for renderingpublic void flush()
public void dispose()
initialized
again.dispose
in interface Disposable
Copyright © 2014. All Rights Reserved.