This commit is contained in:
Miloslav Ciz 2023-04-06 22:43:02 +02:00
parent fa845d3bee
commit 40826e0336
7 changed files with 50 additions and 23 deletions

View file

@ -2,6 +2,18 @@
In [computer graphics](graphics.md) double buffering is a technique of rendering in which we do not draw directly to [video RAM](vram.md), but instead to a second "back buffer", and only copy the rendered frame from back buffer to the video RAM ("front buffer") once the rendering has been completed; this prevents flickering and displaying of incompletely rendered frames on the display. Double buffering requires a significant amount of extra memory for the back buffer, however it is also necessary for how graphics is rendered today.
```
here we are this is seen
drawing on display
| |
V V
.--------. when drawing is done .--------.
| | we copy this | |
| back | -----------------------> | front |
| buffer | | buffer |
|________| |________|
```
In most libraries and frameworks today you don't have to care about double buffering, it's done automatically. For this reason in many frameworks you often need to indicate the end of rendering with some special command such as `flip`, `endFrame` etc. If you're going lower level, you may need to implement double buffering yourself.
Though we encounter the term mostly in computer graphics, the principle of using a second buffer in order to ensure the result is presented only when it's ready can be applied also elsewhere.