Ok, now I've had it with the JavaSoft's Java implementation. It is unbelieveable how slow drawing a bitmap can be! When I was still programming with JDK 1.1 I noticed that Microsoft's runtimes were a bit faster in drawBitmap() operations. Now when I compare Java 2 and Microsoft Java SDK 4.x the speed difference is HUGE.
I'm just drawing 10 animated (of size 32*32) bitmaps on the screen, but still the JavaSoft runtime bogs down to snails pace. While MS Java speeds along and the bitmaps animate and bounce around the screen at lightning speed.
When I start to use copyArea() while the bitmaps bounce around, the speed difference gets even greater. I just copy the backbuffer one pixel downwards on each repaint creating a chaotic effect. JavaSoft's Java 2 runtime slows down to a point where you can actually see the screen scroll down pixel by pixel. While the MS Java doesn't really seem to slow down at all from the previous case.
I've tried setting the rendering hints to get every bit of performance out of the Java 2, but nothing really helps. I'm guessing that the fact that I'm drawing the bitmaps to the backbuffer (a 640*480 bitmap ) and then draw this backbuffer to the screen once in a loop cycle just is too much for the poor JavaSoft runtime. I just wonder how the MS runtime has been so well optimized and/or the JavaSoft one so poorly implemented.
Does anyone have a cure for this speed problem? Should I just stop using the backbuffer or is there some trick I've forgotten to put in use?
If you want to take a look at the code I'm using just download the GameFrame for Java 0.9.2 and look at the code in CGraphicsEngine class in gameframe.jdk12x package. The currently on line version doesn't have the areaCopy method or the setting of the rendering hints, but otherwise it is the same code.
Edited by - javanerd on 3/16/00 12:26:59 PM
I''ve heard and seen benchmarks that IBM''s jvm puts even ms'' vm to shame. Which Sun jvm are you using, the refrence implementation or the production one? Also, which compiler are you using, are you using the -O option with javac?
So, I don''t see your point, if you want to develop to standards and then run your program on any VM, what''s the big deal? Just tell your users what you have experienced under certain VMs and to be wary of poor performance. Personally, I can''t get my game to run under Microsoft''s VM, and I shouldn''t expect to either.
One thing to note: the MS JVMs use JIT compiling, so they''re going to run a lot faster. The JavaSoft Virtual Machine still does everything in software. It''s not that the JavaSoft is poorly optimized, it''s that MS, in a sense, takes the application out of the virtual machine.
Thank you for your replies, but it seems that I''ve again shooten myself on my foot. It wasn''t that many days ago I adviced against using clip rectangles extensively, but for some reason I just didn''t make the connection to this problem. The main problem was the usage of clip regions everywhere in my library code.
After removing all unnecessary usage of clip regions, the framerates went through the roof. Thankfully I''ve still get these "48 hours" weekends when I can really look into things. The library should be ready for a new release in no time after this