Search code examples
javaandroidlibgdx

LibGdx:Alternatives to ShapeRenderer


Note: I am new to LibGdx with android.

I am Creating a clone of the famous game Color Switch for practice purposes.

I have used ShapeRenderer for creating the ball and moving circles. After reading more about ShapeRenderer, I realized it is mostly used for debugging purposes, so I searched for other alternatives to it and I got to know about Pixmaps but I am stuck on how to use it and cannot find any source.

So I want to know if there any other alternatives to ShapeRenderer or any sources for Pixmaps to get started?


Solution

  • ShapeRenderer is perfectly fine for your use-case. So, unless you have an actual problem with it, there is no need to switch to something else.

    The reason that ShapeRenderer is primarily used for debugging is because it's limited to basic shapes and colors. In many use-cases this is insufficient and e.g. images (like .png files) are used instead. In those cases SpriteBatch is typically used to draw the images, which is optimized for (rectangular) images instead of shapes.

    A Pixmap is the raw image data in CPU memory (RAM), which is practically an interim step between the image on disk (e.g. the .png file) and the image (Texture) in GPU memory (VRAM). LibGDX handles this interim step for you, so you should never have to deal with Pixmap in most use-cases yourself. Manually manipulating a Pixmap is very costly operation and worse than using ShapeRenderer for your use-case.