---
name: "SDL_GL_CreateContext"
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_CreateContext"
---

# SDL\_GL\_CreateContext(3)

Create an OpenGL context for an OpenGL window, and make it current.

## NAME

SDL\_GL\_CreateContext - Create an OpenGL context for an OpenGL window, and make it current.

## HEADER FILE

Defined in SDL3/SDL\_video.h

## SYNOPSIS

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

**SDL\_GLContext SDL\_GL\_CreateContext(SDL\_Window \*window);**

## DESCRIPTION

Windows users new to OpenGL should note that, for historical reasons, GL functions added after OpenGL version 1.1 are not available by default. Those functions must be loaded at run-time, either with an OpenGL extension-handling library or with

**SDL\_GL\_GetProcAddress** () and its related functions.

**SDL\_GLContext**\
  is opaque to the application.

## FUNCTION PARAMETERS

- *window*

  the window to associate with the context.

## RETURN VALUE

( **SDL\_GLContext** ) Returns the OpenGL context associated with **window** or NULL 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\_DestroyContext**(3)](/SDL_GL_DestroyContext/3.md), **•**(3), [**SDL\_GL\_MakeCurrent**(3)](/SDL_GL_MakeCurrent/3.md)
