---
name: "SDL_GL_SetSwapInterval"
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_GL_SetSwapInterval"
---

# SDL\_GL\_SetSwapInterval(3)

Set the swap interval for the current OpenGL context.

## NAME

SDL\_GL\_SetSwapInterval - Set the swap interval for the current OpenGL context.

## HEADER FILE

Defined in SDL3/SDL\_video.h

## SYNOPSIS

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

**bool SDL\_GL\_SetSwapInterval(int interval);**

## DESCRIPTION

Some systems allow specifying -1 for the interval, to enable adaptive vsync. Adaptive vsync works the same as vsync, but if you've already missed the vertical retrace for a given frame, it swaps buffers immediately, which might be less jarring for the user during occasional framerate drops. If an application requests adaptive vsync and the system does not support it, this function will fail and return false. In such a case, you should probably retry the call with 1 for the interval.

Adaptive vsync is implemented for some glX drivers with GLX\_EXT\_swap\_control\_tear, and for some Windows drivers with WGL\_EXT\_swap\_control\_tear.

Read more on the Khronos wiki: https://www.khronos.org/opengl/wiki/Swap\_Interval#Adaptive\_Vsync

## FUNCTION PARAMETERS

- *interval*

  0 for immediate updates, 1 for updates synchronized with the vertical retrace, -1 for adaptive vsync.

## 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\_GL\_GetSwapInterval**(3)](/SDL_GL_GetSwapInterval/3.md)
