java 2D : how to make faster

Hey
I’m making an ALife game and for the moment I have a terrible FPS
the methode to draw just a 50 circles on the buffer and flip the buffer takes 110 millis ! (with antialliasing)

  1. Is this normal ?
  2. to draw cicles is the ellips geom the one I have to use ?
  3. any suggestions where I can make improvements
    (writing own circle draw methodes for ex.)

Stop drawing ;D

No really - stop drawing circles and just blit a circle image.

However that said - 50 circles should render better than what you’re saying - that is if the AA isn’t taking its toll. Try disabling anti aliasing.

Or use OpenGL and forget Java2D. It’s a waste of space..

Cas :slight_smile:

Java2D isn’t bad, but I lost faith when I saw that my code was running really fast on Windows but getting too slow on Linux (on comparable HW).

But then again I haven’t tested OpenGL on any integrated-chipset-graphics (which is important, as they sell more than dedicated chips from nvidia or ati, especially the intel ones)

To the original question: AA is not hardware accelerated, drawing circles possibly not, too. (Simple) Line drawing seems to be accelerated on Windows.

I can’t use images for my circles because the color and the radius is in function of the amount of food in an organisme

but all my circles are small. Maybe I have to draw polygones instead.

If memory isnt too much of a concern, you could pre-create your organisms into a load of images, then select one suitable for the properties when drawing or if one isnt avalible, then create one as needed and store for further re-use. Theres also tricks with palletes you could try to get the variety of colours with a reduced set of images.

[quote]But then again I haven’t tested OpenGL on any integrated-chipset-graphics
[/quote]
Continuing to be off-topic: :wink:

At work I have a desktop with intel integrated chipset which performs I suspect well enough for 2d games (my 3d game still is playable on it). Especially when you want to do fancy stuff like rotation and blending you will have better performance using ogl on those chipsets.
And on wintel java2d might perform not too bad for simple stuff, it’s still buggy and not reliable on that platform.

And remember that the playspeed will be a problem sooner or later when you want to make a game without some native help.

I said it before and I say it again:
Java2d for games: never again for me.

How fast is it without antialiasing?

Actually, using volatileimage on 1.4 and straightforward unscaled blits, it’s about on a par with OpenGL. Nearly everything else it does it does very slowly though*

CpEx - what you should do is render your circles into a cache of images only when they change and draw them to your actual game display by using a blit. The circle-drawing bit with antialiasing on is slower by comparison than a blit. Not much slower mind - if you’re doing antialiased blits it’s still pretty dire in Java2D.

Cas :slight_smile:

  • It does have crackingly good quality output mind you. The font rendering is superb. (Shame they haven’t got antialiased fonts in Swing by default isn’t it?)