java 是否可以在 libGDX 中禁用帧限制?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15097834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to disable frame-limiting in libGDX?
提问by Mistodon
More specifically, a desktop libGDX-LWJGL application. There are configurations options to disable CPU syncing as well as vsynching, but regardless the application runs at 60fps.
更具体地说,一个桌面 libGDX-LWJGL 应用程序。有一些配置选项可以禁用 CPU 同步和 vsyncing,但不管应用程序以 60fps 运行。
This is fine for all practical uses - but out of curiousity if nothing else, I'd like to see how high the framerate could go.
这适用于所有实际用途 - 但出于好奇,如果不出意外,我想看看帧率可以达到多高。
回答by
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.
此外,如@RodHyde 所述,如果可能,请确保您的 GPU 上的所有硬件 vsync 已关闭。
回答by Rod Hyde
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.
答案在很大程度上取决于您的 CPU 和显卡的速度,但是如果您在创建应用程序时尝试如下配置,并在您的显卡上禁用 vsync,那么这应该会非常困难。
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.
禁用 vsync 将在显卡设置中的某处。在我的 nVidia 卡上,它在选项中显示为“垂直同步”。它被设置为“自适应”,帧速率上限为 60fps,但在将其设置为“关闭”后,我看到 > 4000fps 由fraps测量。
回答by Oliver
cfg.useCPUSynch
has been taken out it seems. Setting cfg.foregroundFPS
to some large number instead did the trick for me.
cfg.useCPUSynch
好像已经取出来了。设置cfg.foregroundFPS
为一些大数字反而对我有用。