SDL_SetWindowSurfaceVSync(3)
π SDL_SetWindowSurfaceVSync(3) β from the SDL3 FUNCTIONS girlies π
okay so bestie, welcome to the SDL3 video corner of the manual, where we're talking about SDL_SetWindowSurfaceVSync β aka the "toggle VSync for the window surface" function. yes that's literally the whole NAME section, she's short and she knows it. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_video.h>
bool SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync);
#define SDL_WINDOW_SURFACE_VSYNC_DISABLED 0
#define SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE (-1)
like, two defines and a function, that's the whole vibe. π
πΈ DESCRIPTION πΈ
so when a window surface gets created, vsync defaults to SDL_WINDOW_SURFACE_VSYNC_DISABLED. that's the starting state, no cap. π
now the vsync parameter, listen closely because this is the main character:
1β synchronize present with every vertical refresh2β synchronize present with every second vertical refresh- and so on and so on, etc., you get the pattern
SDL_WINDOW_SURFACE_VSYNC_ADAPTIVEβ for late swap tearing (that's the adaptive vsync, iykyk)SDL_WINDOW_SURFACE_VSYNC_DISABLEDβ disables it entirely
β οΈ not every value is supported by every driver!! so you should check the return value to see whether the requested setting is actually supported. do not just assume, bestie, that's how you get humbled. π
π«Ά FUNCTION PARAMETERS π«Ά
windowβ the window. yes. that's it. she's the window.vsyncβ the vertical refresh sync interval.
π RETURN VALUE π
returns true on success or false on failure. and if it fails? call SDL_GetError() for more information, she'll tell you what went wrong. π₯
π THREAD SAFETY π
this function should only be called on the main thread. periodt. don't be out here calling her from a random thread, she will not answer. π
π AVAILABILITY π
this function is available since SDL 3.2.0. iconic, honestly. β
π¦ SEE ALSO π¦
SDL_GetWindowSurfaceVSync(3)β the sister function, the getter to this setter. go read her too. π
and that's the whole page!! simple directmedia layer energy, SDL 3.4.18, and no date on this footer so she's giving timeless π β stay synced bestie, mwah πβ¨
π¦ 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