0

I’m developing a 2D game in java. Our group is normally developing on a Windows and Mac platform. No problems appear during the game and we have a constant frame rate of 60 fps.

Yesterday we ran our game on a Linux computer and the frame rate was only about 10 frames per second!

Does anybody have heard something like this? Having problems on running Java games on Linux? Holding up a good frame rate on Linux?

I don´t know which code lines(at the moment more then 12000) I should show you, so you could understand my problem. But I’ll try to explain a little of our concept so maybe you know a solution or you can give us a hint :)

We build a Content Manager Service, which loads and holds our images which should be drawn on the JFrame. Typically we are using images in a png format.

A very short extract:

//Load our images which are later drawn on the Frame
URL url = this.getClass().getClassLoader().getResource( the right image Path);
this.image = ImageIO.read(url);

//extract of draw
this.graphicsDevice.getGraphics().drawImage(ourImage, x , y , null);

We have about 25 different images at the same time, which are directly drawn on the graphic device of the JFrame.

I don´t have any experience with Linux, that’s why I can´t understand the source of the terrible frame rate. (Remember, on windows and mac pcs it´s constant 62 fps, with the same code :( )

If anybody needs some more information to help, I would try to add some.

Thanks for reading!

Best regards FireDragon

  • 1
    Do you have an actual JVM on the system? Are you sure that this JVM is used and not some old implementation? – Arne Deutsch Jun 08 '11 at 12:11
  • 2
    How well is the graphics card for your test machine supported on Linux ? You might be comparing framerate with Windows or Mac that can use hardware acceleration / proper OpenGL drivers ... – phtrivier Jun 08 '11 at 12:12

3 Answers3

1

I suspect, that you didn't include the Linux-Buffering during the painting-process. Try to add Toolkit.getDefaultToolkit().sync(); in your paint-Method. Good luck.

WeGi
  • 1,908
  • 1
  • 21
  • 33
  • Thanks for your answer, yesterday night we found the source of the problem. We are using transparent images, which causes the troubles. A friend of mine made a new topic with our new problem: http://stackoverflow.com/questions/6290576/java2d-bufferedimage-not-accelerated-on-ubuntu – FireDragon Jun 09 '11 at 09:21
1

Profile your code on both so that you can see if one specific area is causing the problem.

Also, compare the specs of the two machines, if the Linux machine is running on much slower hardware that could be your issue.

jzd
  • 23,473
  • 9
  • 54
  • 76
  • Thanks for your answer, yesterday night we found the source of the problem. We are using transparent images, which causes the troubles. A friend of mine made a new topic with our new problem: http://stackoverflow.com/questions/6290576/java2d-bufferedimage-not-accelerated-on-ubuntu – FireDragon Jun 09 '11 at 09:22
1

I would ask the user experiencing such problems which version of X, video card drivers and jre he is running and if compositing is on.

I experienced dramatic increase of RAM/CPU usage with the same application after updating to newer version of openjre.

There's no such thing as Linux machine, there are machines with (AMD|nVidia|Intel) video cards running (latest|outdated) (proprietary|free) drivers and (KDE|Gnome|whatever) and (openjre|sunjre), and each combination of software/hardware would show different results.

I would try to test an application on AMD and nVidia machines, with proprietary and free drivers and with openjre and sunjre to have an idea what causes low fps.

Roman Grazhdan
  • 467
  • 4
  • 15
  • Thanks for your answer, yesterday night we found the source of the problem. We are using transparent images, which causes the troubles. A friend of mine made a new topic with our new problem: http://stackoverflow.com/questions/6290576/java2d-bufferedimage-not-accelerated-on-ubuntu – FireDragon Jun 09 '11 at 09:21
  • I believe WeGi's answer is of more use for you, because it's more language specific, while my answer is just a trivial information about testing/troubleshooting apps in Linux. – Roman Grazhdan Jun 09 '11 at 12:46