Quantcast
Channel: Question and Answer » game-loop
Viewing all articles
Browse latest Browse all 30

Laggy empty project at 60FPS

$
0
0
@Override
public void create() {
    batch = new SpriteBatch();
    img = new Texture("badlogic.jpg");
}

@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    if (x < 0 || x > 400) {
        speed = -speed;
    }
    x += speed * Gdx.graphics.getDeltaTime() * 60;
    Gdx.app.log("delta",Gdx.graphics.getDeltaTime()+"");

    batch.begin();
    batch.draw(img, x, 0);
    batch.end();

}

I had a problem and i created a new project. The problem libgdx tries to keep 60FPS and avarage deltatime is ~16ms.Some renders take +20ms then next render takes 12ms(render1 + render2 = 32ms) to achieves 60FPS. That makes game laggy. As you can see i don’t have anything in the project and it is the same in desktoplaunch. How did you solve this ?

Note: I also tried reqeustRendering. But it is the same thing if the render takes more time than the avarage. I also tried to wait some times for the render if that is smaller than 16ms. It didn’t help either. It doesn’t have any GC problem. I use Libgdx 1.6.4.


Viewing all articles
Browse latest Browse all 30

Trending Articles