SDL_HINT_VIDEO_DOUBLE_BUFFER(3)

πŸ’– SDL_HINT_VIDEO_DOUBLE_BUFFER πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is a lil hint called SDL_HINT_VIDEO_DOUBLE_BUFFER. she's small, she's powerful, she controls your frames. let's get into it πŸŽ€


✨ NAME ✨

SDL_HINT_VIDEO_DOUBLE_BUFFER β€” tell the video driver that we only want a double buffer. no more, no less, she said what she said πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_hints.h>

#define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER"

🌸 DESCRIPTION 🌸

so here's the tea, fr fr. by default, most lowlevel 2D APIs will use a triple buffer scheme. what does that mean? it means they waste no CPU time on waiting for vsync after issuing a flip. iconic, efficient, no waiting around like a loser. BUT 😭 β€” and this is the plot twist β€” it introduces a frame of latency.

on the other hand (and you knew there was another hand), using a double buffer scheme instead is recommended for cases where low latency is an important factor, because we save a whole frame of latency. yes bestie, a WHOLE frame. that's not a small deal, that's a big deal πŸ‘‘

and how do we do this magical thing? we do so by waiting for vsync immediately after issuing a flip, usually just after eglSwapBuffers call in the backend's *_SwapWindow function. the way that we just... wait. on purpose. for the vibes. and for the latency 🫢

this hint is currently supported on the following drivers:

  • Raspberry Pi (raspberrypi)
  • Wayland (wayland)
⚠️ this hint should be set before SDL is initialized. do not pass go, do not collect $200, set it early or it's giving nothing πŸ’€

⭐ AVAILABILITY ⭐

this hint is available since SDL 3.2.0. she's not ancient, she's not brand new, she's just right 🌈


and that's the whole page, bestie!! go forth and double buffer responsibly πŸ§šπŸ’œ

this has been your girl from Simple Directmedia Layer, reporting live from SDL 3.4.18, signing off on SDL_HINT_VIDEO_DOUBLE_BUFFER(3) β€” mwah, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from