SDL_SetRenderVSync(3)
π SDL_SetRenderVSync(3) π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_SetRenderVSync β she's here to fix your screen tearing era. π¦
β¨ NAME β¨
SDL_SetRenderVSync β toggle VSync of the given renderer. no cap, that's the whole job. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_render.h>
bool SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
#define SDL_RENDERER_VSYNC_DISABLED 0
#define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
like. look at her. so clean. so demure. π
β¨ DESCRIPTION β¨
so when a renderer gets created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED. that's the factory setting, that's the vibe it was born with, periodt.
now the vsync parameter is lowkey a choose-your-own-adventure:
1β synchronize present with every vertical refresh2β synchronize present with every second vertical refresh- etc. (you get the pattern, you're smart, i believe in you π«Ά)
SDL_RENDERER_VSYNC_ADAPTIVEβ for late swap tearing (adaptive vsync)SDL_RENDERER_VSYNC_DISABLEDβ just disable it, she's free
β οΈ okay important bestie: not every value is supported by every driver. so please, please check the return value to see whether the requested setting is actually supported. don't just assume and then act surprised. π
β¨ FUNCTION PARAMETERS β¨
rendererβ the renderer to toggle. she's the one getting the glow-up. π«vsyncβ the vertical refresh sync interval. yes that's the fancy way of saying "how often do we sync".
β¨ RETURN VALUE β¨
returns true on success or false on failure. and if it's giving failure, call SDL_GetError() for more info β she will tell you what went wrong, she's not mysterious, she's just dramatic. π
β¨ THREAD SAFETY β¨
this function should only be called on the main thread. do not try to be sneaky from a side thread, it's not that girl. π«π§΅
β¨ AVAILABILITY β¨
this function is available since SDL 3.2.0. so if you're on something older... yeah. upgrade era. β
β¨ SEE ALSO β¨
SDL_GetRenderVSync(3)β the read-only bestie, the one who checks in on what you set. π
and that's the whole page, you ate that fr fr πβ¨
this has been a Simple Directmedia Layer moment, brought to you by SDL 3.4.18 β go forth and sync those refreshes, queen ππ¦π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms