Is it possible to disable frame-limiting in libGDX?

£可爱£侵袭症+ 提交于 2019-12-03 10:28:01
Aaron Mahan

Rode Hyde's answer is no longer correct due to changes in the library. Try this:

LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.vSyncEnabled = false; // Setting to false disables vertical sync
config.foregroundFPS = 0; // Setting to 0 disables foreground fps throttling
config.backgroundFPS = 0; // Setting to 0 disables background fps throttling

Also, make sure any hardware vsync is off on your GPU, if possible, as @RodHyde mentioned.

The answer depends very much on the speed of your CPU and graphics card, but if you try a configuration like the following when you create your application, and disable vsync on your graphics card, then that should push it pretty hard.

LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "Framerate test";
cfg.width = 1280;
cfg.height = 720;
cfg.fullscreen = false;  
cfg.useGL20 = false;
cfg.useCPUSynch = false;
cfg.forceExit = true;  
cfg.vSyncEnabled = false;

Disabling vsync will be somewhere in the settings for your graphics card. On my nVidia card, it is given as "Vertical sync" in the options. It was set to "Adaptive", capping the frame rate at 60fps, but after setting it to "Off", I saw > 4000fps as measured by fraps.

cfg.useCPUSynch has been taken out it seems. Setting cfg.foregroundFPS to some large number instead did the trick for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!