StandardGame frame rate broken?

Whenever I run TestJMEDesktopState or run my own game that uses StandardGame, the FPS is constantly 50…

Although when I run TestGameStateSystem, the FPS is over 400

thats because StandardGame has 'vsync' turned on by default, which lets it render just as much frames as your monitor can show. turn vsync off in the settings of StandardGame (i gess its called PreferenceSettings?)



EDIT: You might also want to make sure to the framerate setting is set to -1.



so long

My monitor is 60Hz…



EDIT: Even when I add this to it… the FPS is still 50


      StandardGame game = new StandardGame("Testing JMEDesktopState");
      game.getSettings().setFramerate(-1);
      game.start();



EDIT: When I try to turn vsync off, it renders at 57 FPS

do this:

game.getSettings().setVerticalSync(false);
game.getSettings().setFrequency(60);



or leave the frequency statement out at first

It works! … but why would that fix it?

When I change it to


      System.out.println("a: " + game.getSettings().isVerticalSync()
            + " b: " + game.getSettings().getFrequency());
      game.getSettings().setVerticalSync(false);
      game.getSettings().setFrequency(60);
      game.start();



It prints "a: false b: 60"

EDIT: When I change it to only


      System.out.println("a: " + game.getSettings().isVerticalSync()
            + " b: " + game.getSettings().getFrequency());



It works still...

the parameter 'framerate' is standard at -1 which says pretty much: "render as many frames as you can". vsync to off lets the StandardGame not wait for monitor synchronization -> more frames. and the frequency is just a parameter that lets you set the Hz of the application (optimally the maximally available of your monitor).



vsync is the crucial part here. vsync = true means that the application waits for the monitor to be able to show the next frame. when its false, it just renders like hell and doesn't give a damn about your monitor (can result in 'tearing', google it  ;))



when you 'ship' your game, you might want to turn vsync back on as a standard, because when you render 400 frames and only 60 of them are actually shown on the monitor, the computer renders 340 frames for nothing  :wink:

But why does it still work when I remove the set statements out and only have this?  :?



System.out.println("a: " + game.getSettings().isVerticalSync()
            + " b: " + game.getSettings().getFrequency());

thats strange. if you use eclipse, try to 'clean' your project and recompile.

The StandardGame settings are stored in your registry, not in a properties file like SimpleGame.

Thats why it still works after you uncomment the settings.



If you play with settings in StandardGame you have to explicitly set them true or false or whatever value.

Or remove any settings before starting the Game.

Ah I see, thanks. I used game.getSettings().clear();