This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Performance and the fly likes Slow g.paint() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Performance
Reply 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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Slow g.paint() ?
 
Similar Threads
Most efficient way to use a spritesheet?
Help! Why isn't my Window paint method called?
Isometric assistance needed
Moving within a 2 dimensional array
Problem with my Breakout clone