Primitives VS Images VS Text

I need your experience on this one. :slight_smile:

What would be faster, drawing Java primitives or drawing Images? For example, in a PacMan game would it be faster to use oval or rectangle primitives (for the dots) or draw the equivalent Images? Or a ship’s protective shield, would it draw faster with a primitive oval or with a circular image around the ship? Also the stafield…

Again is it faster to draw Java text or use a bitmap character set? For example, messages like Score or High Score and the actual scores. (BTW is there any optimized algorithm for an int2digits translation? I realize that division by 10 cannot be optimized but you never know…)

Thank you.

To the font question I would say that it is definately faster to draw with bitmaps, because to achieve the quality of bitmap, you have to turn the java2d antialiasing hints on and do other tricks, which absolutely kills the performance.

However, I’m not sure about rectangles so I’ll let someone else answer that one.

Typically the only drawing primatives that are hardware-accelerated are certain cases of bitmap drawing, line drawing (although using large line widths can kill this) and filled rectangles (single colour, no fancy rounded corners etc.) Using antialiasing usually boots you back to software as well.

So for most cases, images are probably better, unless you can get away with the methods above. Assuming you’ve got nicely formated images that is (power-of-two size, larger than 4x4 and no bigger than 256x256, correct colour format).