Trouble getting Active Rendering to perform quickly

I’ve hit a snag getting my active rendering to display smoothly. I draw a background image using a bufferedImage, and them put several different items over it for the user to interact with. I noticed while building the program that it ran much slower when the background image was being rendered than if it wasn’t For instance, I have made my own versions of text field, and there is a noticable delay when the user types when I’m rendering a background image. Also, removing the image to increase speed revealed that the items from a previous state of the game were still there, apparently being rendered on screen. Currently, I’m using double buffering, no Swing components or any of that mess, and no hardware acceleration, and I’m disposing the graphics object at theend of every rendering pass. I’m also fairly new to all of this, so I havent learned any tricks to tweaking performance. From the look of it, it feels lke for some reason, instead of old items going away, I’m just covering them over with the background. Unfortuantely, I cannot post any code, becuase other classmates at my school are working on the same project, and it’s in violation of our honor code, but I’ll give as many details as I can if you need any. Any help would be greatly appreciated.

prozaconstilts

If your BufferedImage is in a different format than your display, then your rendering will slow down considerably. To avoid this, just use createCompatibleImage(…) from GraphicsConfiguration. Then draw your loaded image to this new image. Discard the loaded image and use the new image for all your rendering. This way the conversion is done on the first draw and the new image is in the correct format.

Some basic tipps:

  • Use Java-5.0 for getting better accerlation (basically BufferedImages only get accerlated when running it on 1.5+)

  • Render From BufferedImages and To VolatileImages, only rendering To VolatileImages (e.g using a Graphics object created from a VolatileImage will use HW-accerlation). Don’t use the Graphics-object of a BufferedImage frequently.

  • Run you program with -Dsun.java2d.trace=log to see which operations happen under the hood.
    Everything with “java2d.loops” in it is basically bad, so if a lot of stuff happens there (not only “some” calls like 20) you should tune your app.

lg Clemens

If the background image has no transparent parts to it, than you might consider using just a VolatileImage rather than a BufferedImage…