SDL_CreateWindowWithProperties

Function SDL_CreateWindowWithProperties 

Source
pub unsafe extern "C" fn SDL_CreateWindowWithProperties(
    props: SDL_PropertiesID,
) -> *mut SDL_Window
Expand description

Create a window with the specified properties.

The window size is a request and may be different than expected based on the desktop layout and window manager policies. Your application should be prepared to handle a window of any size.

These are the supported properties:

These are additional supported properties on macOS:

These are additional supported properties on iOS, tvOS, and visionOS:

These are additional supported properties on Wayland:

These are additional supported properties on Windows:

These are additional supported properties with X11:

The window is implicitly shown if the “hidden” property is not set.

These are additional supported properties with Emscripten:

  • SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING: the id given to the canvas element. This should start with a ‘#’ sign
  • SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING: override the binding element for keyboard inputs for this canvas. The variable can be one of:
  • “#window”: the javascript window object (default)
  • “#document”: the javascript document object
  • “#screen”: the javascript window.screen object
  • “#canvas”: the WebGL canvas element
  • “#none”: Don’t bind anything at all
  • any other string without a leading # sign applies to the element on the page with that ID. Windows with the “tooltip” and “menu” properties are popup windows and have the behaviors and guidelines outlined in SDL_CreatePopupWindow().

If this window is being created to be used with an SDL_Renderer, you should not add a graphics API specific property (SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, etc), as SDL will handle that internally when it chooses a renderer. However, SDL might need to recreate your window at that point, which may cause the window to appear briefly, and then flicker as it is recreated. The correct approach to this is to create the window with the SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN property set to true, then create the renderer, then show the window with SDL_ShowWindow().

§Parameters

  • props: the properties to use.

§Return value

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