What does it mean by Page-Flipping?
Why do we need it in graphics programming?
What does it mean by Page-Flipping?
Why do we need it in graphics programming?
Page flipping is a simple hardware-assisted technique for flicker-free graphics which has been with us for decades.
It requires support from the hardware:
The video subsystem must have at least two areas of memory (pages) that can potentially be visible, of which only one is visible at any given moment.
The video subsystem supports some means whereby the software can select which of the two pages is visible. This is usually just a single instruction to the hardware, and the switch is instantaneous, because the hardware simply stops scanning one page and starts scanning the other page.
So, the idea is that at any given moment we keep one page visible, while on the other page we are doing the rendering of our next frame. Once we are done rendering the frame, we send the hardware instruction that instantaneously "flips" the visible page, which means that the page where we did our rendering now becomes visible, while the page that used to be visible becomes invisible and available for us to render the next frame in it. We repeat the process for each frame, always rendering on the invisible page while the user is seeing the visible page.
More elaborately, it works as follows:
We have two pages, A and B. In the beginning both pages are blank, page A is visible, page B is invisible.
We render our graphics frame on page B, which is invisible, so initially the user does not see it.
Once we are done rendering our frame in page B, we send the hardware instruction to flip the pages, so the user now starts seeing our rendering on page B.
We render our next frame on invisible page A, so the user does not see the rendering taking place. (That would be perceived as flicker.)
Once we are done rendering on page A, we flip the pages again, so now the user can see our newly rendered page, while the previously visible page now becomes invisible and available for rendering the next frame in it.
We keep repeating this procedure for each frame.
often its too slow to draw directly on the screen, visually, you see the drawing. So you draw on one page while showing another. then when its ready to be shown you 'page flip' to the fully drawn page, then you can start drawing on another page.
Makes for smooth animation.