The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Triple buffering

From Allegro Wiki
Jump to: navigation, search
This article is incomplete and needs some revision or has some pending TODOs. Please help Allegro by editing and finishing it. When the article becomes complete, you may remove this tag.


Why triple buffering?

Triple buffering is the fastest method of controlling screen drawing known to Allegro. Normally screen updating methods must wait for the screen to cycle before drawing or risk tearing but the triple buffer technique does not.

How does it work?

Triple buffering is much like page flipping. So much so that understanding page flipping will make understanding this technique much easier.

Page flipping involves creating a second 'fake' screen. The graphics are then drawn onto the second screen. Once we're done drawing we have to wait for the monitor to finish drawing the first screen and then draw the second screen.

When using triple buffering you instead set this second, recently drawn, screen in a waiting line. As soon as the graphics hardware detect that the first screen is finished drawing, it starts to draw the second screen. Meanwhile you can draw on the third screen. Triple buffering eliminates the wait for the vertical sync (vsync()).

See Also

<tasks> [ ]Get a nice graphical illustration of this. [ ]This article should be about triple buffering, not page flipping. </tasks>