GLXSWAPBUFFERS(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

🌸 NAME 🌸

glXSwapBuffers β€” ok so this is the one that exchanges front and back buffers, bestie ✨ it lives in section 3G of the GLX manual, and honestly? it's giving main character energy πŸ’…


πŸŽ€ C SPECIFICATION πŸŽ€

void glXSwapBuffers( Display *dpy,
                     GLXDrawable drawable )

delim $$

(yeah that delim $$ line is just vibing there at the end, we don't question it, we respect it πŸ™ˆ)


πŸ“ PARAMETERS πŸ“

  • dpy β€” the connection to the X server. that's your link to the whole X situation, no cap.
  • drawable β€” the drawable whose buffers are the ones getting swapped. yes, that one. πŸ‘‘

✨ DESCRIPTION ✨

okay so here's the tea πŸ«– glXSwapBuffers promotes the contents of the back buffer of drawable to become the contents of the front buffer of drawable. like, back buffer β†’ front buffer, glow up complete, slay. πŸ’–

and then?? the contents of the back buffer become undefined. gone. mystery. we do not know her anymore. 😭

the update typically takes place during the vertical retrace of the monitor, rather than immediately after glXSwapBuffers is called. so it's not instant-instant, it's scheduled-instant, iykyk. 🌈

also important: glXSwapBuffers performs an implicit glFlush before it returns. so subsequent OpenGL commands may be issued immediately after calling glXSwapBuffers, but β€” and this is the key part β€” they are not executed until the buffer exchange is completed. they're queued, they're waiting their turn, they're in the group chat but nobody's read the message yet. πŸ’€

and if drawable was not created with respect to a double-buffered visual, glXSwapBuffers has no effect, and no error is generated. literally nothing happens. iconic of it. πŸ™ˆ


πŸ“ NOTES πŸ“

the contents of the back buffer become undefined after a swap. and note (fr fr note this): this applies to pbuffers as well as windows. not just windows. pbuffers too. don't forget the pbuffers bestie. πŸ’…

all GLX rendering contexts share the same notion of which are front buffers and which are back buffers. one consequence of that is β€” and this is the big one β€” when multiple clients are rendering to the same double-buffered window, all of them should finish rendering before one of them issues the command to swap buffers. πŸ‘€

the clients are responsible for implementing this synchronization. the API is not gonna do it for you, she's not your mom. 😀 typically this is accomplished by executing glFinish and then using a semaphore in shared memory to rendezvous before swapping. that's the move. that's the whole plan. 🫢


πŸ’€ ERRORS πŸ’€

  • GLXBadDrawable is generated if drawable is not a valid GLX drawable. invalid drawable = instant error, no thoughts. πŸ’€
  • GLXBadCurrentWindow is generated if dpy and drawable are respectively the display and drawable associated with the current context of the calling thread, and drawable identifies a window that is no longer valid. that window has left the chat. πŸšͺ

πŸ‘€ SEE ALSO πŸ‘€

  • glFlush
  • glXBindSwapBarrierSGIX
  • glXJoinSwapGroupSGIX
  • glXSwapIntervalSGI

go read those too, bestie, they're all part of the same little friend group πŸ¦‹


and that's the whole page!! footer says GLXSWAPBUFFERS() and it's the GLX manual, section 3G β€” so yeah, GLXSWAPBUFFERS(3G), exactly as the page signs off at the bottom. periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from