Draw color whit alpha is very SLOW!!!

Hi all, i have a problem whit my first java 2d game.

I need to draw material like water, now i use this code:

publicclass Water{

GeneralPath water=new generalPath();

public Water(bla bla bla){

water.moveTo(etc etc...);

water.quadTo(etc etc...);

}

publicvoid drawWater(Graphics2D g2){

g2.setColor(new Color(80,155,235,150));

g2.fill(water);

}

}

I call the drawWater method in a paintComponent method of JPanel.

The problem is that drawing is very slow, if i use a color whitout alpha drawing is very fast.

How i can resolve?

I have tried to set System.setProperty("sun.java2d.translaccel", "true"); but now is more slow...

What can i do?

ps.i use java 1.5

[1161 byte] By [blowa] at [2007-10-2 23:29:10]
# 1

I tried to load a PNG 100% translucent image and i have create a compatibleImage of this, but not works, i think the translucent parts of image dont become accelerated.

I have tried whit a PNG pictures 50% opaque and 50% translucent, when a create a compatibleImage of this the drawImage are more fast, so i think the part opaque are accelerated and the part translucent arent accelerated...

What can i do?

ps. translucent=not totaly transparent

Message was edited by:

blow

blowa at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 2
So, there are no way?
blowa at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 3
any real code? (im too lazy to actually try that...)
skyuzoa at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 4
Just a minor thing: don't create a Color instance each time you draw your stuff...
Franck_Lefevrea at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 5
> Just a minor thing: don't create a Color instance> each time you draw your stuff...Color instance? this g2.setColor(new Color(80,155,235,150)); ?
blowa at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 6

> > Just a minor thing: don't create a Color instance

> > each time you draw your stuff...

>

> Color instance? this g2.setColor(new Color(80,155,235,150)); ?

yes.

As the color values are never changing, better use a constant than re-creating

the same Color object each time you draw your stuff.

Franck_Lefevrea at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 7

Now i have to resolve this problem...

There are any way to resolve it?

When a draw a GeneralPath shape whit translucent GradientPaint frame per second decrese terribly...

When i draw a bufferedImage of translucent image frame per second decrese terribly too.

Why why why?

What can i do?

How can i know if now im using double buffering?

Im painting my image on a JPanel doublebuffered and the bufferedImage that im paint are compatibleImage, the doublebuffering is ON?

blowa at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 8
I have also mesured the time to excute paintComponent() metodo of my JPanel.I noticed that the time is the same when i draw whit alpha color and when i draw whit normal color.I think the problem is when the image is paint in video...
blowa at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...
# 9
Then maybe you should post your actual code, here so we can try to guess what's going wrong.
Franck_Lefevrea at 2007-7-14 16:09:14 > top of Java-index,Other Topics,Java Game Development...