简体   繁体   中英

Java / Libgdx LwjglApplicationConfiguration backgroundFPS doesn't work

I'm working on a multiplayer game, because of that it should also be rendered and calculated when the window is not in focus. I searched a little bit and found a way for libgdx to render in background, normally it should work by setting backgroundFPS = 0; like here :

LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "32 Bit Game v : 0.4.75";

cfg.vSyncEnabled = false;
cfg.forceExit = true;

cfg.backgroundFPS = 0;
cfg.foregroundFPS = 0;

cfg.width = 1920;
cfg.height = 1080;

cfg.fullscreen = false;

cfg.addIcon("Icon/Logo.png", FileType.Internal);

//System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");

new LwjglApplication(new MenuCreate(), cfg);

Like I did in my code, but it doesn't work, every time my game loses focus it still doesn't render. Can anyone help me ?

Due to documentation you should rather use the -1 value

Target framerate when the window is not in the foreground. The CPU sleeps as needed. Use 0 to never sleep, -1 to not render.

So it should be:

    cfg.backgroundFPS = -1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM