Home arrow static arrow Java Programming [Archive] - Optimizing tips for Graphical engine please.
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Optimizing tips for Graphical engine please.
This topic has 4 replies on 1 page.

Posts:27
Registered: 4/26/04
Optimizing tips for Graphical engine please.  
Jun 25, 2004 2:47 PM



 
Hello.

I am trying to write a 2D graphical engine. It runs fullscreen using GraphicsDevice and BufferStrategy (to achieve double-buffering / page-flipping). Everything runs fine , but it is just too slow. When I paint a background, some animation, and some overlying sprites, my paint circle ends up at ~60 ms. It's livable, but I'd want to be able to have more objects onscreen simultaneously, so I am thinking it will be too slow.

Now, I have a paintManager that objects that want to be painted register themselves to. This registration is done using Vector's, and I know they are slow. I just wonder, how slow? Is there any significant speed to gain from switching to arrays? And, are there other common pitfalls and pratfalls in this line of business that I should be aware of?

When painting the background, is it always faster to just paint the parts of it that needs painting, or is it sometimes (many objects ontop of it), faster to just paint the complete background every cycle? (I guess it takes a few ms to figure out the coordinates to which the background wiki/./needs repainting as well).

Any tips here are appreciated.

Thanks,
-Terje
 

Posts:1,183
Registered: 1/23/02
Re: Optimizing tips for Graphical engine please.  
Jun 25, 2004 2:55 PM (reply 1 of 4)



 
Don't try to guess what the bollteneck it. Use a profiler (there's a simple built-in one in Sun's JVMs, see http://java.sun.com/developer/technicalArticles/Programming/perfanal/).

Whether it's faster to draw all objects or draw only visible varies from case to case. Run the profiler. See what's taking the time. Speed it up. If you see that there's too much drawing, no matter how fast you make it - add visibility computation. And vice versa, if you see all time being spent on visibility computation - try skipping it altogether.
 

Posts:27
Registered: 4/26/04
Re: Optimizing tips for Graphical engine please.  
Jun 25, 2004 2:57 PM (reply 2 of 4)



 
That link was broken..

I tried using profilers, but I must just be stupid, because I cant get any of those I tried to work ;)
 

Posts:27
Registered: 4/26/04
Re: Optimizing tips for Graphical engine please.  
Jun 25, 2004 2:58 PM (reply 3 of 4)



 
Argh, nevermind my rambling, I forgot to remove the ) from the paste. My bad.
 

Posts:27
Registered: 4/26/04
Re: Optimizing tips for Graphical engine please.  
Jun 25, 2004 3:22 PM (reply 4 of 4)



 
I dont get it.. The profiler says the AWT eventloop is what uses most time. WToolkit.run

But I was under the impression that I was sparing the AWT eventloop by using active rendering, since I would like to spend my share of the AWT loop to do input. hrmph.
 
This topic has 4 replies on 1 page.