---
name: "SDL_SetWindowSurfaceVSync"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_SetWindowSurfaceVSync"
---

# SDL\_SetWindowSurfaceVSync(3)

Toggle VSync for the window surface.

## NAME

SDL\_SetWindowSurfaceVSync - Toggle VSync for the window surface.

## HEADER FILE

Defined in SDL3/SDL\_video.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_SetWindowSurfaceVSync(SDL\_Window \*window, int vsync);** **#define SDL\_WINDOW\_SURFACE\_VSYNC\_DISABLED 0** **#define SDL\_WINDOW\_SURFACE\_VSYNC\_ADAPTIVE (-1)**

## DESCRIPTION

When a window surface is created, vsync defaults to

**SDL\_WINDOW\_SURFACE\_VSYNC\_DISABLED** .

The **vsync** parameter can be 1 to synchronize present with every vertical refresh, 2 to synchronize present with every second vertical refresh, etc.,

**SDL\_WINDOW\_SURFACE\_VSYNC\_ADAPTIVE**\
  for late swap tearing (adaptive vsync), or

**SDL\_WINDOW\_SURFACE\_VSYNC\_DISABLED**\
  to disable. Not every value is supported by every driver, so you should check the return value to see whether the requested setting is supported.

## FUNCTION PARAMETERS

- *window*

  the window.

- *vsync*

  the vertical refresh sync interval.

## RETURN VALUE

Returns true on success or false on failure; call

**SDL\_GetError** () for more information.

## THREAD SAFETY

This function should only be called on the main thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_GetWindowSurfaceVSync**(3)](/SDL_GetWindowSurfaceVSync/3.md)
