On-the-fly Blur

Hi,

I am currently working on a 2d space side-scrolling shooter where each ship consists of geometrical shapes like triangle or square. I am currently drawing them with fillRect and fillPoly and performance is excellent.

As the shapes look a bit raggish on the black background, I tried to apply a Blur Filter like this:

BufferedImageOp blur;
float ninth = 1.0f / 9.0f;
float[] blurKernel = {
ninth, ninth, ninth,
ninth, ninth, ninth,
ninth, ninth, ninth
};
blur = new ConvolveOp(new Kernel(3, 3, blurKernel));

this is instantiated one time, and in the render loop, I apply it like this:

foreground = blur.filter(foreground, null);

Performance dropped tremendously and I only have like 4-5 frames left. I am using Fedora Core 3 Linux with Sun JRE 1.5 and a Geforce 6800 so I don’t think it has sth to do with pc performance.

Can someone suggest a better method or am I doing something wrong ?

Thanks a lot.

Does anybody know how I could make the shapes look better, with things like anti-aliasing or something ?

You can set a rendering hint that will antialias your geometric shapes


g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                       RenderingHints.VALUE_ANTIALIAS_ON);

you will take a performance hit over the non-antialiased shapes, but I imagine it won’t be nearly as bad as your current method of blurring the objects.