GeeCON Prague 2014*
The moose likes Performance and the fly likes Slow g.paint() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Performance
Bookmark "Slow g.paint() ?" Watch "Slow g.paint() ?" New topic
Author

Slow g.paint() ?

Mike Cole
Ranch Hand

Joined: Sep 25, 2006
Posts: 38
Hi all,

i have a quick question. Ive made a prog. which displays some gfx. Iam using Graphics2D for that. First i had a class which was holding all BufferedImages in an array and i used a loop to paint(g.drawImage(...)) all these.
But then i decided to change that and instead of BufferedImages i made a sprite class which holds the buffered image. So now iam looping over an array of sprites and call each sprites own "paint"(g.drawImage(...)) function.
The problem is it is extremly slower than the first version. Frames dropped from over 200 to 32, just by this small change! Is that normal or is it possible that i made a mistake???

thank you
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
That drop in performance sounds at least suspicious. Hard to say more without seeing some of the code...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Mike Cole
Ranch Hand

Joined: Sep 25, 2006
Posts: 38
I will post the code here as soon as iam home.
Is there a special part of interesst or shall i just post the two classes?

thank you.
Mike Cole
Ranch Hand

Joined: Sep 25, 2006
Posts: 38
okay, i found it out. The problem was that the BufferedImages in the Sprite-Class were not accelerated. After i constructed the image with the gfxConfiguration everything went fine.

but.. Thanks anyway!
 
GeeCON Prague 2014
 
subject: Slow g.paint() ?