int spritesInBatch = idx / 20;
if (spritesInBatch > maxSpritesInBatch) maxSpritesInBatch = spritesInBatch;
int count = spritesInBatch * 6;
lastTexture.bind();
Mesh mesh = this.mesh;
mesh.setVertices(vertices, 0, idx);
mesh.getIndicesBuffer().position(0);
mesh.getIndicesBuffer().limit(count);
if (blendingDisabled) {
Gdx.gl.glDisable(GL20.GL_BLEND);
} else {
Gdx.gl.glEnable(GL20.GL_BLEND);
if (blendSrcFunc != -1) Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
}
if (Gdx.graphics.isGL20Available())
mesh.render(customShader != null ? customShader : shader, GL10.GL_TRIANGLES, 0, count);
else
mesh.render(GL10.GL_TRIANGLES, 0, count);
idx = 0;
currBufferIdx++;
if (currBufferIdx == buffers.length) currBufferIdx = 0;
this.mesh = buffers[currBufferIdx];