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?
Asked
Active
Viewed 545 times
0

Hải Phong
- 5,094
- 6
- 31
- 49
-
Try both and time them. Make sure to time *only* the rendering (and not, for example, constructing the sprites). Run multiple times, to prevent warming up/caching issues. – Jongware May 11 '14 at 12:43
-
This depends on number of circles and how big they are on screen. But if they are very big at all, you will probably have a fill rate problem using sprites. In that case, first make sure you have depth testing turned on. If that isn't it, maybe your current slow down is too many draw calls and you need to find a way to batch them into a single call. – Tenfour04 May 11 '14 at 12:57
1 Answers
0
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.

P.T.
- 24,557
- 7
- 64
- 95