How do different buffer strategy sizes affect performance?

In java, in the Canvas class, I heard someone once explain that a higher buffer strategy is more efficient when moving from 1 to 2 and from 2 to 3, but above 3 it does not matter. Why does bufferstrategy size above 3 significantly increase speed, and how does the increase from createBufferStrategy (2) to createBufferStrategy (3) work?

+4
source share
1 answer

There is a performance issue if and only if you do not want to break the animation: in this case you need to wait for the system to finish displaying the buffer before changing this buffer again.

So, with 1 buffer you have to wait without doing anything. With 2 buffers, you can write to another buffer while the first one is displayed, but if you are fast enough, you can end the wait before starting the next frame. With 3 buffers, you can do something again, rather than wait.

It is less likely that he completed drawing in the third buffer before the first is fully displayed, so the gain is very low than 3 buffers.

Note that the more the buffer is used, the more memory is required to accommodate this buffer. This is not a problem on a regular computer, but it can be for telephone applications.

+3
source

All Articles