开发者

JAVA 2D Game Linux terrible FameRate

开发者 https://www.devze.com 2023-03-11 16:42 出处:网络
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.

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 compu开发者_StackOverflow社区ter 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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消