Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to draw a rectangle box to use as a text background for a visual novel library I'm writing, I wanted some flexibility of color and transparency and the ShapeRenderer class seems to fit the need but the doc brings this disclaimer:

This class is not meant to be used for performance sensitive applications but more oriented towards debugging.

If I use it as background the most action on screen would probably be the text scrolling over it. Can someone more experient on the engine tell me if it is viable to use it under those premises, or it is really for debug only?

share|improve this question
up vote 5 down vote accepted

It is probably fine for a desktop-only game if you don't draw too many shapes, but it can produce FPS stutter on some mobile GPUs and, iirc, doesn't cache any of the shapes between frames.

A better approach might be to allocate a Sprite with a small white texture that you upscale to the appropriate size. Set tint and alpha with Sprite#setColor


It is possible to manually create a texture by using a pixmap. It is probably easier grabbing the background texture from a texture atlas, if you're using it - allowing libgdx to automatically manage the texture for you. Otherwise:

public static Texture createBgTexture()
        Pixmap pixmap = new Pixmap(1, 1, Format.RGBA4444); // or RGBA8888
        Texture texture = new Texture(pixmap); // must be manually disposed

        return texture;
share|improve this answer
Is it possible to load or create that one pixel texture without reading it from a file? – petervaz Feb 22 '13 at 17:09
Sure, see updated answer. – junkdog Feb 23 '13 at 12:26
geez, I did exatcly that, except the fill(), and was wondering why didn't work. thanks. – petervaz Feb 23 '13 at 20:39
Could you specify how to scale the texture? – Wolfrevo Kcats Aug 20 '13 at 18:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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