1
\$\begingroup\$

Using libGDX, sprites or simply texture regions must be inserted into the batch for drawing:

void render()
{
    batch.begin();

    batch.draw(...);

    batch.end();
}

Is the VBO being uploaded to the GPU in every frame? Is there a way to reuse the batch once any of the data changed?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

LibGDX already binds the textures for you under the hood: Texture.java

For 99% of cases you can just let the SpriteBatch draw everything for you; it does so with very good efficiency. I would suggest referring to the extensive documentation on the wiki.

Additionally, if you use the AssetManager, textures will be re-bound even after an OpenGL context loss.

Regarding "re-using" the batch, the same SpriteBatch can render every frame as long as you are calling begin() and end(). You shouldn't create more than one SpriteBatch.

\$\endgroup\$
2
  • \$\begingroup\$ My question was about not changing the vertex buffer in every frame, like a static batch which gets filled once and draws many frames. I agree that SpriteBatch class draws stuff efficiently, only changing states when needed and this way minimizing draw calls. Sorry if the question is not clear. \$\endgroup\$
    – felipe
    May 20, 2014 at 22:03
  • 1
    \$\begingroup\$ Look into the SpriteCache class rather than SpriteBatch. It allows you to collect texture data once and re-use it. \$\endgroup\$
    – Matt Sams
    May 23, 2014 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .