X11 How to get window data pointer?

On the Wikipedia page for multiple buffering, under page flipping it says:

In the page-flip method, instead of copying the data, both buffers are capable of being displayed (both are in VRAM). At any one time, one buffer is actively being displayed by the monitor, while the other, background buffer is being drawn. When the background buffer is complete, the roles of the two are switched. The page-flip is typically accomplished by modifying the value of a pointer to the beginning of the display data in the video memory.

The page-flip is much faster than copying the data and can guarantee that tearing will not be seen as long as the pages are switched over during the monitor's vertical blanking interval—the blank period when no video data is being drawn. The currently active and visible buffer is called the front buffer, while the background page is called the "back buffer".

So how would you do something like
1
2
3
4
5
6
7
8
9
int &current = XGetPixelPointer(window);
int &a = current;
int &b = current + (width * height * 3);
while (running) {
    current = a;
    draw(b);
    current = b;
    draw(a);
}
?
Last edited on
You need to get the current framebuffer pointer every time you're about to render.
Can I not set the frame buffer pointer to use double-buffering?
A pointer is nothing but an integer that refers to a memory location. All you can do is make it point somewhere and read where it's pointing to. That's it.
I'm asking if can you tell the X API to change its rendering pointer to a different address. To quote Wikipedia, "The page-flip is typically accomplished by modifying the value of a pointer to the beginning of the display data in the video memory." How do you accomplish this with X?
If you've configured X to use double buffering, there should be a function that performs a buffer swap and changes what pointer is returned by XGetPixelPointer(), I'd imagine. Doing a simple search for "x11 buffer swap" gives this result: https://www.x.org/releases/X11R7.7/doc/libXext/dbelib.html
XdbeSwapBuffers() looks promising.
Topic archived. No new replies allowed.