---
name: "SDL_CreateRenderer"
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_CreateRenderer"
---

# SDL\_CreateRenderer(3)

Create a 2D rendering context for a window.

## NAME

SDL\_CreateRenderer - Create a 2D rendering context for a window.

## HEADER FILE

Defined in SDL3/SDL\_render.h

## SYNOPSIS

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

**SDL\_Renderer \* SDL\_CreateRenderer(SDL\_Window \*window, const char \*name);**

## DESCRIPTION

If you want a specific renderer, you can specify its name here. A list of available renderers can be obtained by calling

**SDL\_GetRenderDriver** () multiple times, with indices from 0 to  **SDL\_GetNumRenderDrivers** ()-1. If you don't need a specific renderer, specify NULL and SDL will attempt to choose the best option for you, based on what is available on the user's system.

If **name** is a comma-separated list, SDL will try each name, in the order listed, until one succeeds or all of them fail.

By default the rendering size matches the window size in pixels, but you can call

**SDL\_SetRenderLogicalPresentation** () to change the content size and scaling options.

## FUNCTION PARAMETERS

- *window*

  the window where rendering is displayed.

- *name*

  the name of the rendering driver to initialize, or NULL to let SDL choose one.

## RETURN VALUE

( **SDL\_Renderer**\
  \*) Returns a valid rendering context or NULL if there was an error; 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\_CreateRendererWithProperties**(3)](/SDL_CreateRendererWithProperties/3.md), **•**(3), [**SDL\_CreateSoftwareRenderer**(3)](/SDL_CreateSoftwareRenderer/3.md), **•**(3), [**SDL\_DestroyRenderer**(3)](/SDL_DestroyRenderer/3.md), **•**(3), [**SDL\_GetNumRenderDrivers**(3)](/SDL_GetNumRenderDrivers/3.md), **•**(3), [**SDL\_GetRenderDriver**(3)](/SDL_GetRenderDriver/3.md), **•**(3), [**SDL\_GetRendererName**(3)](/SDL_GetRendererName/3.md)
