Save battery by not drawing every render call

I think that for this there should be an easy solution that I am missing. I think one option would be FrameBuffer , but not sure which is the best.

I am working on a puzzle that requires intensive computation when drawing. I did my best to do as little calculation as possible when updating the screen, but some of them I can’t, or it would be cumbersome to get rid of. On the other hand, most of the time the user will look at the screen, trying to understand the next move, and a still image will be displayed on the screen. So running the visualization code 60 times per second is just a waste battery.

What would be the easiest way to prevent drawing while there are no changes to the model? Is there a way to tell libGDX to temporarily stop the rendering call when the last rendered image is displayed, or to have some kind of virtual screen that I can draw on and then draw it on the screen?

As I said, I know FrameBuffer, but it looks like this object is intended to be used by more complex things than what I'm trying to achieve.

+4
source share
1 answer

Use continuous rendering only for on-demand rendering. Detailed instructions are provided in the documentation.

The most basic thing to do is put this in onCreate()

Gdx.graphics.setContinuousRendering(false);
Gdx.graphics.requestRendering();

requestRendering() , (, , ).

, , Gdx.graphics.requestRendering() , , . - , .

+3

All Articles