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]

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 >

> > 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.
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 >
