package com.blarg.gdx.graphics;

/***
 * <p>
 * Wrapper over libgdx's included {@link DecalBatch} with automatic easy management of
 * {@link Decal} objects. This is intended to make "on the fly" rendering of decals/billboards
 * as easy as rendering 2D sprites is with SpriteBatch / DelayedSpriteBatch.
 * </p>
 */
public class BillboardSpriteBatch {

}

@@ -26,16 +26,213 @@
 phics;%0A%0A
+import com.badlogic.gdx.graphics.g2d.TextureRegion;%0Aimport com.badlogic.gdx.graphics.g3d.decals.Decal;%0Aimport com.badlogic.gdx.graphics.g3d.decals.DecalBatch;%0Aimport com.badlogic.gdx.utils.Array;%0A%0A
 /***%0A * 
@@ -542,11 +542,1577 @@
 Batch %7B%0A
+%09static final int CAPACITY_INCREMENT = 128;%0A%0A%09Array%3CDecal%3E sprites;%0A%09int pointer;%0A%09boolean hasBegun;%0A%09DecalBatch decalBatch;%0A%0A%09public BillboardSpriteBatch() %7B%0A%09%09sprites = new Array%3CDecal%3E(true, CAPACITY_INCREMENT, Decal.class);%0A%09%09pointer = 0;%0A%09%09addNewSprites(CAPACITY_INCREMENT);%0A%0A%09%09hasBegun = false;%0A%09%09decalBatch = null;%0A%09%7D%0A%0A%09public void begin(DecalBatch decalBatch) %7B%0A%09%09if (hasBegun)%0A%09%09%09throw new IllegalStateException(%22Cannot be called within an existing begin/end block.%22);%0A%09%09if (decalBatch == null)%0A%09%09%09throw new IllegalArgumentException();%0A%0A%09%09this.decalBatch = decalBatch;%0A%09%09hasBegun = true;%0A%09%09pointer = 0;%0A%09%7D%0A%0A%09public void flush() %7B%0A%09%09if (!hasBegun)%0A%09%09%09throw new IllegalStateException(%22Cannot call outside of a begin/end block.%22);%0A%0A%09%09// TODO: render decals with DecalBatch%0A%0A%09%09pointer = 0;%0A%09%7D%0A%0A%09public void end() %7B%0A%09%09if (!hasBegun)%0A%09%09%09throw new IllegalStateException(%22Must call begin() first.%22);%0A%0A%09%09flush();%0A%0A%09%09hasBegun = false;%0A%09%09decalBatch = null;    // don't need to hold on to this particular reference anymore%0A%09%7D%0A%0A%0A%09private void increaseCapacity() %7B%0A%09%09int newCapacity = sprites.items.length + CAPACITY_INCREMENT;%0A%09%09sprites.ensureCapacity(newCapacity);%0A%09%09addNewSprites(CAPACITY_INCREMENT);%0A%09%7D%0A%0A%09private void addNewSprites(int count) %7B%0A%09%09for (int i = 0; i %3C count; ++i)%0A%09%09%09sprites.add(Decal.newDecal(new TextureRegion()));%0A%09%7D%0A%0A%09private int getRemainingSpace() %7B%0A%09%09return sprites.size - pointer;%0A%09%7D%0A%0A%09private Decal nextUsable() %7B%0A%09%09if (getRemainingSpace() == 0)%0A%09%09%09increaseCapacity();%0A%0A%09%09Decal usable = sprites.items%5Bpointer%5D;%0A%09%09pointer++;%0A%09%09return usable;%0A%09%7D
 %0A%7D%0A

add initial methods