Is it possible to disable frame-limiting in libGDX?

前端 未结 3 1284
迷失自我
迷失自我 2021-02-07 10:15

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

相关标签:
3条回答
  • 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.

    0 讨论(0)
  • 2021-02-07 10:45

    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.

    0 讨论(0)
  • 2021-02-07 10:52

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

    0 讨论(0)
提交回复
热议问题