Question

In my game, I have about 50 filled-circles with different size and different color distributed full screen, and they continuously resize themselves, creating animation. I'm currently using Shaperenderer to render all of them. This way, all the circles look crisp but it seems like the performance is not very good. Should I make a circle sprite and then render all of them using SpriteBatch instead of Shaperenderer? Will the performance be improved by doing that?

Was it helpful?

Solution

Generally, yes, the SpriteBatch API is more optimized than the ShapeRenderer API in Libgdx. ShapeRenderer is designed for debug overlays and for being easy to use. But, it depends on the specifics of how you use the APIs, too.

The ShapeRenderer API assumes your viewport is mapped to pixel units. It determines the number of vertices to use in the circle based on a rough guess. You may be creating too many vertices for each circle (and you may be able to improve the performance without sacrificing fidelity by reducing the number of vertices computed).

For any specific case though, it makes sense to profile your code and see where the time is actually being spent before optimizing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top