Painting with libgdx makes blinking objects

I am trying to make something like a very simple drawing application using Libgdx. I have been looking for intertubes for several days trying to solve this problem, which is probably due to my openGL noobness.

When I draw an object on the screen while the render () method is working, the material that I draw flashes very quickly (I accept it every time the render () method is called). If I turn off continuous rendering, the blinking will stop until I draw something else (again, render () is not called).

Suppose I load a new texture into Sprite appropriately - it draws, scams everything - and everything I do in my render () method is this:

batch.begin();
myShape.setPosition(Gdx.input.getX(), Gdx.input.getY());
batch.setColor(Color.BLUE);
myShape.draw(batch);
batch.end();

I don’t call glClear because I don’t think (I think) I want to clear the screen from every rendering. I blindly experimented with various glEnable and glDisable for culling, blending, dithernig, etc., but nothing helped solve the problem.

What am I doing wrong in the world or just do not understand here? Am I misunderstood something?

+5
source share
1 answer

This is due to double buffering .

If double buffering is enabled, you do not draw the previous frame, but before the previous one. This means that even and odd frames access two different buffers. Changing these buffers creates a flicker.

I see three solutions:

  • You can disable double buffering. I am not sure if this is possible in libgdx.

  • . , .

  • . , . " ".

+2

All Articles