---
name: "SDL_CreateSurface"
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_CreateSurface"
---

# SDL\_CreateSurface(3)

Allocate a new surface with a specific pixel format.

## NAME

SDL\_CreateSurface - Allocate a new surface with a specific pixel format.

## HEADER FILE

Defined in SDL3/SDL\_surface.h

## SYNOPSIS

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

**SDL\_Surface \* SDL\_CreateSurface(int width, int height, SDL\_PixelFormat format);**

## DESCRIPTION

The pixels of the new surface are initialized to zero.

## FUNCTION PARAMETERS

- *width*

  the width of the surface.

- *height*

  the height of the surface.

- *format*

  the  **SDL\_PixelFormat**\
    for the new surface's pixel format.

## RETURN VALUE

( **SDL\_Surface**\
  \*) Returns the new  **SDL\_Surface**

structure that is created or NULL on failure; call

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

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_CreateSurfaceFrom**(3)](/SDL_CreateSurfaceFrom/3.md), **•**(3), [**SDL\_DestroySurface**(3)](/SDL_DestroySurface/3.md)
