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

void render()



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?


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.

| improve this answer | |
  • \$\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 '14 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 '14 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.