SDL_CreateWindowFrom() now takes a set of properties that describe the native window and options.

This commit is contained in:
Sam Lantinga
2023-11-12 21:37:00 -08:00
parent 6afae6681b
commit 1c4723ac66
27 changed files with 94 additions and 169 deletions

View File

@@ -1801,47 +1801,6 @@ extern "C" {
*/
#define SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP "SDL_VIDEO_WAYLAND_EMULATE_MOUSE_WARP"
/**
* A variable that is the address of another SDL_Window* (as a hex string formatted with "%p").
*
* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has
* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly
* created SDL_Window:
*
* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is
* needed for example when sharing an OpenGL context across multiple windows.
*
* 2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for
* OpenGL rendering.
*
* This variable can be set to the following values:
* The address (as a string "%p") of the SDL_Window* that new windows created with SDL_CreateWindowFrom() should
* share a pixel format with.
*/
#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
/**
* When calling SDL_CreateWindowFrom(), make the window compatible with OpenGL.
*
* This variable can be set to the following values:
* "0" - Don't add any graphics flags to the SDL_WindowFlags
* "1" - Add SDL_WINDOW_OPENGL to the SDL_WindowFlags
*
* By default SDL will not make the foreign window compatible with OpenGL.
*/
#define SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL "SDL_VIDEO_FOREIGN_WINDOW_OPENGL"
/**
* When calling SDL_CreateWindowFrom(), make the window compatible with Vulkan.
*
* This variable can be set to the following values:
* "0" - Don't add any graphics flags to the SDL_WindowFlags
* "1" - Add SDL_WINDOW_VULKAN to the SDL_WindowFlags
*
* By default SDL will not make the foreign window compatible with Vulkan.
*/
#define SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN "SDL_VIDEO_FOREIGN_WINDOW_VULKAN"
/**
* A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries
*

View File

@@ -868,14 +868,34 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowWithPosition(const char *tit
extern DECLSPEC SDL_Window *SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, Uint32 flags);
/**
* Create an SDL window from an existing native window.
* Create an SDL window from properties representing an existing native window.
*
* In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows)
* the hint `SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT` needs to be configured
* before using SDL_CreateWindowFrom().
* These are the supported properties:
*
* \param data a pointer to driver-dependent window creation data, typically
* your native window cast to a void*
* On macOS:
* ```
* "cocoa.window" (pointer) - the (__unsafe_unretained) NSWindow associated with the window
* "cocoa.view" (pointer) - optional, the (__unsafe_unretained) NSView associated with the window, defaults to [window contentView]
* ```
*
* On Windows:
* ```
* "win32.hwnd" (pointer) - the HWND associated with the window
* "win32.pixel_format_hwnd" (pointer) - optional, another window to share pixel format with, useful for OpenGL windows
* ```
*
* On X11:
* ```
* "x11.window" (number) - the X11 Window associated with the window
* ```
*
* On all platforms:
* ```
* "opengl" (boolean) - optional, true if the window will be used with OpenGL rendering
* "vulkan" (boolean) - optional, true if the window will be used with Vulkan rendering
* ```
*
* \param props a set of properties describing the native window and options
* \returns the window that was created or NULL on failure; call
* SDL_GetError() for more information.
*
@@ -884,7 +904,7 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, in
* \sa SDL_CreateWindow
* \sa SDL_DestroyWindow
*/
extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowFrom(const void *data);
extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowFrom(SDL_PropertiesID props);
/**
* Get the numeric ID of a window.