In my game I have some graphics that I want to draw once and only redraw whenever something is changed by the player. Now, I'm wondering, whether I should use the FrameBuffer or the SpriteCache class. I know that a framebuffer is much more general concept and also works for 3D, while a SpriteCache is only for 2D. However it seems to me that they would both make sense in my use case, so I'm wondering..

What are the differences, drawbacks and advantages of using one over the other?


1 Answer 1


So, I asked this on the #libgdx IRC channel and got the following response:

Whereas you may be able to achieve a similar effect with both, they are very different things. SpriteCache is for cacheing sprite geometry on the gpu, allowing you to draw the cache, or elements of the cache without the costly upload to the gpu. All the geometry is still intact. FrameBuffers are render targets, you render to them. You are limited by texture max sizes, and it only contains the texture information, it has no concept of what was rendered to it.

SpriteCache is great for when you have alots of static sprites that dont move, for example a tiled map layer.

FrameBuffers are good for rendering to texture at runtime, for example if you have a widget that is costly to create, but it doesn't change every frame, you can render it to a texture (framebuffer), and simply render that generated asset as a simple quad. Its also good for post processing, or deferred rendering paths.

[With a FrameBuffer] you lose the information about the sprites also, so if you had a special shader that did some fancy things with the geometry, you would lose your tile vertices


You must log in to answer this question.

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