views:

91

answers:

1

Hey, I've been having this problem for a while now and I was hoping someone could help.

I make small games using Java on Mac OSX 1.6.3 and if I use PNG's as the image format my CPU usage by Java skyrockets to say 50% (on a very small 2D game). However if I use GIF as the format my CPU usage by Java stays constant at 10% which is reasonable.

What is causing this problem?? It occurs on every game I develop using PNG's so I always just switch to GIF's.

The problem is now that i need to use a PNG for its variable alpha properties rather than just plain transparency. This is not available using GIF's.

The problem is present on Java SE 6 and previous versions. I am using an early 2009 Mac Book Pro 15".

The problem does not occur on a Windows PC running the same game. The CPU usage due to Java using PNG's on a Windows PC (I have tried XP, Vista and 7) is always constantly low at ~10%.

Any help would be greatly appreciated. Thanks :)

+1  A: 

Transparency is probably at the root of the issue, since it's a rather expensive feature. My guess is that Java2D on Mac doesn't use hardware acceleration, while on Windows it does.

Are you running the JRE that comes with MacOS?

Michael Borgwardt
Yeah, Mac release their own versions of the JRE and i'm running the most up to date version. I could try the -Dsun.java2d.opengl=true to enable Suns implementation of opengl but i'm not sure how effective that is.Thanks
alexganose
@alexganose - *"... but i'm not sure how effective that is"*. Try it and see.
Stephen C
No noticeable difference.Really stuck on what to do here. I can't find anyone more information about it, although others I have spoken to are experiencing the same problem.
alexganose
@alexganose: you could try profiling the app on both platforms to see where it's spending the time.
Michael Borgwardt