SDL_CREATEWINDOWWITHPROPERTIES(3)
π SDL_CreateWindowWithProperties π
okay bestie, welcome to the SDL3 FUNCTIONS manual, and today's main character is SDL_CreateWindowWithProperties β the glow-up version of making a window, where instead of a million positional args you hand it a whole bag of properties. iykyk. β¨
π NAME π
SDL_CreateWindowWithProperties β creates a window with the specified properties. periodt.
π¦ SYNOPSIS π¦
#include <SDL3/SDL_video.h>
SDL_Window * SDL_CreateWindowWithProperties(SDL_PropertiesID props);
πΈ DESCRIPTION πΈ
so. you ask for a window size, right? but it's giving request, not demand π β the desktop layout and your window manager's whole personality can absolutely hand you something different. so your app needs to be ready to handle a window of any size. no cap.
these are the supported properties, bestie:
SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEANβtrueif the window should be always on topSDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEANβtrueif the window has no window decorationSDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEANβtrueif the"tooltip"and"menu"window types should be automatically constrained to be entirely within display bounds (default),falseif no constraints on the position are desired.SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEANβtrueif the window will be used with an externally managed graphics context.SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEANβtrueif the window should accept keyboard input (defaults true)SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEANβtrueif the window should start in fullscreen mode at desktop resolutionSDL_PROP_WINDOW_CREATE_HEIGHT_NUMBERβ the height of the windowSDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEANβtrueif the window should start hiddenSDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEANβtrueif the window uses a high pixel density buffer if possibleSDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEANβtrueif the window should start maximizedSDL_PROP_WINDOW_CREATE_MENU_BOOLEANβtrueif the window is a popup menuSDL_PROP_WINDOW_CREATE_METAL_BOOLEANβtrueif the window will be used with Metal renderingSDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEANβtrueif the window should start minimizedSDL_PROP_WINDOW_CREATE_MODAL_BOOLEANβtrueif the window is modal to its parentSDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEANβtrueif the window starts with grabbed mouse focusSDL_PROP_WINDOW_CREATE_OPENGL_BOOLEANβtrueif the window will be used with OpenGL renderingSDL_PROP_WINDOW_CREATE_PARENT_POINTERβ anSDL_Windowthat will be the parent of this window, required for windows with the"tooltip","menu", and"modal"propertiesSDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEANβtrueif the window should be resizableSDL_PROP_WINDOW_CREATE_TITLE_STRINGβ the title of the window, in UTF-8 encodingSDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEANβtrueif the window show transparent in the areas with alpha of 0SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEANβtrueif the window is a tooltipSDL_PROP_WINDOW_CREATE_UTILITY_BOOLEANβtrueif the window is a utility window, not showing in the task bar and window listSDL_PROP_WINDOW_CREATE_VULKAN_BOOLEANβtrueif the window will be used with Vulkan renderingSDL_PROP_WINDOW_CREATE_WIDTH_NUMBERβ the width of the windowSDL_PROP_WINDOW_CREATE_X_NUMBERβ the x position of the window, orSDL_WINDOWPOS_CENTERED, defaults toSDL_WINDOWPOS_UNDEFINED. This is relative to the parent for windows with the"tooltip"or"menu"property set.SDL_PROP_WINDOW_CREATE_Y_NUMBERβ the y position of the window, orSDL_WINDOWPOS_CENTERED, defaults toSDL_WINDOWPOS_UNDEFINED. This is relative to the parent for windows with the"tooltip"or"menu"property set.
π these are additional supported properties on macOS π
SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTERβ the (__unsafe_unretained)NSWindowassociated with the window, if you want to wrap an existing window.SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTERβ the (__unsafe_unretained)NSViewassociated with the window, defaults to[window contentView]
π§ these are additional supported properties on iOS, tvOS, and visionOS π§
SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTERβ the (__unsafe_unretained)UIWindowSceneassociated with the window, defaults to the active window scene.
π these are additional supported properties on Wayland π
SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN-trueif the application wants to use the Wayland surface for a custom role and does not want it attached to an XDG toplevel window. SeeREADME-waylandfor more information on using custom surfaces.SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN-trueif the application wants an associatedwl_egl_windowobject to be created and attached to the window, even if the window does not have the OpenGL property orSDL_WINDOW_OPENGLflag set.SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER- thewl_surfaceassociated with the window, if you want to wrap an existing window. SeeREADME-waylandfor more information.
π these are additional supported properties on Windows π
SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTERβ theHWNDassociated with the window, if you want to wrap an existing window.SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTERβ optional, another window to share pixel format with, useful for OpenGL windows
π₯ these are additional supported properties with X11 π₯
SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBERβ the X11 Window associated with the window, if you want to wrap an existing window.
the window is implicitly shown if the "hidden" property is not set. ok noted bestie π«Ά
β 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'#'signSDL_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 javascriptwindow.screenobject"#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 inSDL_CreatePopupWindow().
ok now the part that lowkey trips people up π β 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), because 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(). that's the move. do that.
π FUNCTION PARAMETERS π
propsβ the properties to use.
β¨ RETURN VALUE β¨
Returns the window that was created or NULL on failure; call SDL_GetError() for more information. so if you get NULL, go ask SDL_GetError() what went wrong, she always knows π
π§΅ THREAD SAFETY π§΅
This function should only be called on the main thread. like, do not try it anywhere else. main thread only. periodt.
π AVAILABILITY π
This function is available since SDL 3.2.0.
π¦ SEE ALSO π¦
mwah π that's the whole page, you ate that. this lil manual moment came to you from Simple Directmedia Layer, version SDL 3.4.18 β go forth and make windows bestie, and remember: every property, every platform, no notes. πΈππ«Ά
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms