Salihcan
Salihcan

Reputation: 121

Low fps on LibGDX

Without this code fps is 60-65. But when i use this code, fps down to 50.

Another problem is that the FPS is too low on some devices. However, the game is quite simple. I'm using ShapeRenderer for all shapes. Game is here: link

    try {
            Thread.sleep((long)(1000/60-Gdx.graphics.getDeltaTime()));
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Edit: I solved this problem using this code --> link.

Upvotes: 0

Views: 1073

Answers (1)

dfour
dfour

Reputation: 1376

You can limit the FPS to any value you want in a libgdx application by defining the foregroundFPS in the config of your app loader.

LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.width = 640;
    config.height = 480;
    config.foregroundFPS = 60; // <- limit when focused
    config.backgroundFPS = 60; // <- limit when minimized
    config.samples =2; // AA for shape renderer.. not textures!
    new LwjglApplication(new libgdxapp(), config);

android config

Continuous rendering

Upvotes: 4

Related Questions