libgdx API

com.badlogic.gdx.graphics.g3d.decals
Class DecalBatch

java.lang.Object
  extended by 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 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 Summary
DecalBatch()
          Creates a new batch using the DefaultGroupStrategy
DecalBatch(GroupStrategy groupStrategy)
           
DecalBatch(int size, GroupStrategy groupStrategy)
           
 
Method Summary
 void add(Decal decal)
          Add a decal to the batch, marking it for later rendering
protected  void clear()
          Remove all decals from batch
 void 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 0
 int 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/done
 void setGroupStrategy(GroupStrategy groupStrategy)
          Sets the GroupStrategy used
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecalBatch

public DecalBatch()
Creates a new batch using the DefaultGroupStrategy


DecalBatch

public DecalBatch(GroupStrategy groupStrategy)

DecalBatch

public DecalBatch(int size,
                  GroupStrategy groupStrategy)
Method Detail

setGroupStrategy

public void setGroupStrategy(GroupStrategy groupStrategy)
Sets the GroupStrategy 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 be initialized again.

Specified by:
dispose in interface Disposable

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)