---
name: "SDL_CreateWindow"
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_CreateWindow"
---

# SDL\_CreateWindow(3)

Create a window with the specified dimensions and flags.

## NAME

SDL\_CreateWindow - Create a window with the specified dimensions and flags.

## HEADER FILE

Defined in SDL3/SDL\_video.h

## SYNOPSIS

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

**SDL\_Window \* SDL\_CreateWindow(const char \*title, int w, int h, SDL\_WindowFlags flags);**

## DESCRIPTION

**flags** may be any of the following OR'd together:

•  **SDL\_WINDOW\_FULLSCREEN** : fullscreen window at\
   desktop resolution

•  **SDL\_WINDOW\_OPENGL** : window usable with an OpenGL\
   context

•  **SDL\_WINDOW\_OCCLUDED** : window partially or\
   completely obscured by another window

•  **SDL\_WINDOW\_HIDDEN** : window is not visible

•  **SDL\_WINDOW\_BORDERLESS** : no window decoration

•  **SDL\_WINDOW\_RESIZABLE** : window can be resized

•  **SDL\_WINDOW\_MINIMIZED** : window is minimized

•  **SDL\_WINDOW\_MAXIMIZED** : window is maximized

•  **SDL\_WINDOW\_MOUSE\_GRABBED** : window has\
   grabbed mouse focus

•  **SDL\_WINDOW\_INPUT\_FOCUS** : window has input\
   focus

•  **SDL\_WINDOW\_MOUSE\_FOCUS** : window has mouse\
   focus

•  **SDL\_WINDOW\_EXTERNAL** : window not created by SDL

•  **SDL\_WINDOW\_MODAL** : window is modal

•  **SDL\_WINDOW\_HIGH\_PIXEL\_DENSITY** : window\
   uses high pixel density back buffer if possible

•  **SDL\_WINDOW\_MOUSE\_CAPTURE** : window has mouse\
   captured (unrelated to MOUSE\_GRABBED)

•  **SDL\_WINDOW\_ALWAYS\_ON\_TOP** : window should\
   always be above others

•  **SDL\_WINDOW\_UTILITY** : window should be treated as a\
   utility window, not showing in the task bar and window list

•  **SDL\_WINDOW\_TOOLTIP** : window should be treated as a\
   tooltip and does not get mouse or keyboard focus, requires a parent\
   window

•  **SDL\_WINDOW\_POPUP\_MENU** : window should be\
   treated as a popup menu, requires a parent window

•  **SDL\_WINDOW\_KEYBOARD\_GRABBED** : window has\
   grabbed keyboard input

•  **SDL\_WINDOW\_VULKAN** : window usable with a Vulkan\
   instance

•  **SDL\_WINDOW\_METAL** : window usable with a Metal\
   instance

•  **SDL\_WINDOW\_TRANSPARENT** : window with\
   transparent buffer

•  **SDL\_WINDOW\_NOT\_FOCUSABLE** : window should not\
   be focusable

The  **SDL\_Window**\
  is implicitly shown if

**SDL\_WINDOW\_HIDDEN**\
  is not set.

On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist property to YES, otherwise you will not receive a High-DPI OpenGL canvas.

The window pixel size may differ from its window coordinate size if the window is on a high pixel density display. Use

**SDL\_GetWindowSize** () to query the client area's size in window coordinates, and

**SDL\_GetWindowSizeInPixels** () or

**SDL\_GetRenderOutputSize** () to query the drawable size in pixels. Note that the drawable size can vary after the window is created and should be queried again if you get an

**SDL\_EVENT\_WINDOW\_PIXEL\_SIZE\_CHANGED**

event.

If the window is created with any of the

**SDL\_WINDOW\_OPENGL**\
  or

**SDL\_WINDOW\_VULKAN**\
  flags, then the corresponding LoadLibrary function ( **SDL\_GL\_LoadLibrary**\
  or

**SDL\_Vulkan\_LoadLibrary** ) is called and the corresponding UnloadLibrary function is called by

**SDL\_DestroyWindow** ().

If  **SDL\_WINDOW\_VULKAN**\
  is specified and there isn't a working Vulkan driver,  **SDL\_CreateWindow** () will fail, because  **SDL\_Vulkan\_LoadLibrary** () will fail.

If  **SDL\_WINDOW\_METAL**\
  is specified on an OS that does not support Metal,  **SDL\_CreateWindow** () will fail.

If you intend to use this window with an  **SDL\_Renderer** , you should use  **SDL\_CreateWindowAndRenderer** () instead of this function, to avoid window flicker.

On non-Apple devices, SDL requires you to either not link to the Vulkan loader or link to a dynamic library version. This limitation may be removed in a future version of SDL.

## FUNCTION PARAMETERS

- *title*

  the title of the window, in UTF-8 encoding.

- *w*

  the width of the window.

- *h*

  the height of the window.

- *flags*

  0, or one or more  **SDL\_WindowFlags**\
    OR'd together.

## RETURN VALUE

( **SDL\_Window**\
  \*) Returns the window that was created 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\_CreateWindowAndRenderer**(3)](/SDL_CreateWindowAndRenderer/3.md), **•**(3), [**SDL\_CreatePopupWindow**(3)](/SDL_CreatePopupWindow/3.md), **•**(3), [**SDL\_CreateWindowWithProperties**(3)](/SDL_CreateWindowWithProperties/3.md), **•**(3), [**SDL\_DestroyWindow**(3)](/SDL_DestroyWindow/3.md)
