[java] Performance in Java applications with Java2D

Started by
7 comments, last by biovenger 19 years, 10 months ago
Hey, I just had a fast question. How good is the performance in Java when one is using the Java2D classes (Graphics2D, etc...) to render. I will not be using any fancy software blenders, but mainly will just display images (.PNG with 1 layer of transparency) and animations. How large can the performance be? Is it fast enough to do a nice little action game (was thinking isometric)? Or would I have to use the OpenGL extensions (I''d really rather NOT do this).
-----------------------------Final Frontier Trader
Advertisement
Faster than you think. I think you''ll find it works quite well. Make sure you use double buffering. I made a side scrolling shooter with Java2D in college and was suprised at the performance. I thought it would be slow.
It can be fast enough for simple stuff, provided you a) expect it to run at 30fps or less in general (although it is possible to target 60fps+ it''s generally not always going to work out) b) don''t deploy on the Mac which has some performance issues still c) know all the magic riddles and runes to get accelerated blitting working and d) you don''t do any alpha blending or rotation or scaling

Cas
Oh please teach me the arcane magicks of accelerated blitting! Or at least show me a tutorial!

Also: I am of course talking about a Java Application, not an applet.

[edited by - biovenger on June 1, 2004 7:28:39 AM]
-----------------------------Final Frontier Trader
Bottom link is a good place to start.
Java2D uses directx for hardware accelerated blitting on windows. So its comparable in speed to doing 2d in SDL or Allegro on windows. Its easy to get 100+ fps.
I was also wondering about basically the same thing. Thanks for the link.

How do using .gif''s compare to using .png? Any speed advantage,color advantage or something like that?
Anything other than 1-bit (on/off) transparency will pretty much suck in terms of performance, but how you create that image is up to you. Sticking with gifs is a good idea though, as if you use pngs you can accidentally get a proper transparent image and be left wondering where all your performance has gone. :S The 256 colour limit for gifs isn't usually a problem unless you want big background images or something.

[edited by - OrangyTang on June 1, 2004 2:23:15 PM]
Rule-of-Thumb when working with PNG files: Always save them in 8-bit mode (256 colors, that way you only get 1-bit transparecy channel)
-----------------------------Final Frontier Trader

This topic is closed to new replies.

Advertisement