Java 2D very slow with Windows XP

Hi all!

I'm writing an isometric game engine using Java 2D API, in full-screen exclusive mode and using all the advantages of the new VolatileImage class. The engine is almost finished, I'm testing it putting some animated players on screen and showing the frame rate of the engine. Everything went right, frame rate was very high in Linux and Windows 98/Me. But when I try to run the engine on Windows XP I can only get 5 or 6 fps!!!! And I don't know why!! It seems that XP makes Java run very slow... at least when using Java2D...

Please, anyone knows why the performance is reduced? Is there a new JRE release for Windows XP? I'm using JDK 1.4.1.

Thanks for your help.

[709 byte] By [acaleroa] at [2007-9-28 11:30:32]
# 1

Same problem here, and not only with my own code. All the games at Popcap run really slow too, and they don't even use the fullscreen API. The only thing the two have in common is they both use DirectDraw for rendering, and I'd imagine turning that off wouldn't help performance much either.

trejkaza at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...
# 2

If you're using the Fullscreen API, then you're using BufferStrategy, thus you shouldn't use VolatileImages, it does this for you in the background. You shouldn't create any buffers, simply use the one provided. I'm assuming your problem probably lies in transparency. I've made an isometric engine using the fullscreen API that has run with complete 60fps page flipping. I would assume your bottle-neck lies in:

Transparencys (These are very slow, there is a way to make a bitmask, much like you'd do in DirectX)

Dynamic Memory allocation/Alpha rendering in your animation loop. (You need to allocate ALL of the colors you're going to use, and avoid using an alpha component if you want to avoid the VM getting bogged down by the garbage collector because you're allocating 30 Color objects a second).

I made a Color object that was some what hacked together that has methods to allow you to access it's values for doing this kind of thing, allocating your scheme before hand is an easier approach.

The method that performs the page flipping is a BLOCKING method, so you should orient your drawing before it, and not assume it's simply placing a request, like repaint does.

-Jason Thomas.

thedraclea at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...
# 3

Ok, thanks. I will modify my code to see if the performance increases without VolatileImages...

But I think the problem is not there... I mean, it's true that I use a lot of transparencys, a lot of images with alpha component and all that kind of things, but the fact is that the engine goes with a perfect framerate in Windows 98 (so, the bottle-neck is not there I think)... The problem appears when running in Windows XP! It is very strange! :-(

acaleroa at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...
# 4
Java2D runs faster on my XP machine than it does on my 98 machine, and I'm using a little over 50 transparencies for sprites and such.. are you running some memory-hog program in the background?
Woogleya at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...
# 5
> are you running some memory-hog program in the background?Yes, he's running windows XP >:-P
shishthemoomina at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...
# 6

Well, I have change my offscreen buffer from a VolatileImage to an Image and now the frame rate in XP has increased a lot!!!(about 100 FPS). I have run the engine in windowed mode and in full screen mode.

How is it possible? I mean, it is supposed that VolatileImage is using hardware accelerated memory, how is it possible that it is faster using Image class in XP?

The performance of the engine in Linux using Image is the same as using VolatileImage... Now I'm going to see what happens with Windows 98...

I'm very surprised with these results. VolatileImage was supposed to be faster than Image...

acaleroa at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...
# 7
It probably means that the video driver sucks and is giving you poor performance for images cached in VRAM.
jbanesa at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...
# 8
LOL. "The video driver sucks" sounds like Sun talk to me. :-)
trejkaza at 2007-7-12 2:08:09 > top of Java-index,Other Topics,Java Game Development...