SDL 3.0
SDL_video.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * # CategoryVideo
24 *
25 * SDL video functions.
26 */
27
28#ifndef SDL_video_h_
29#define SDL_video_h_
30
31#include <SDL3/SDL_stdinc.h>
32#include <SDL3/SDL_error.h>
33#include <SDL3/SDL_pixels.h>
34#include <SDL3/SDL_properties.h>
35#include <SDL3/SDL_rect.h>
36#include <SDL3/SDL_surface.h>
37
38#include <SDL3/SDL_begin_code.h>
39/* Set up for C function definitions, even when using C++ */
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44
47
48/* Global video properties... */
49
50/**
51 * The pointer to the global `wl_display` object used by the Wayland video
52 * backend.
53 *
54 * Can be set before the video subsystem is initialized to import an external
55 * `wl_display` object from an application or toolkit for use in SDL, or read
56 * after initialization to export the `wl_display` used by the Wayland video
57 * backend. Setting this property after the video subsystem has been
58 * initialized has no effect, and reading it when the video subsystem is
59 * uninitialized will either return the user provided value, if one was set
60 * prior to initialization, or NULL. See docs/README-wayland.md for more
61 * information.
62 */
63#define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display"
64
65/**
66 * System theme.
67 *
68 * \since This enum is available since SDL 3.0.0.
69 */
70typedef enum SDL_SystemTheme
71{
72 SDL_SYSTEM_THEME_UNKNOWN, /**< Unknown system theme */
73 SDL_SYSTEM_THEME_LIGHT, /**< Light colored system theme */
74 SDL_SYSTEM_THEME_DARK /**< Dark colored system theme */
76
77/* Internal display mode data */
79
80/**
81 * The structure that defines a display mode.
82 *
83 * \since This struct is available since SDL 3.0.0.
84 *
85 * \sa SDL_GetFullscreenDisplayModes
86 * \sa SDL_GetDesktopDisplayMode
87 * \sa SDL_GetCurrentDisplayMode
88 * \sa SDL_SetWindowFullscreenMode
89 * \sa SDL_GetWindowFullscreenMode
90 */
91typedef struct SDL_DisplayMode
92{
93 SDL_DisplayID displayID; /**< the display this mode is associated with */
94 SDL_PixelFormat format; /**< pixel format */
95 int w; /**< width */
96 int h; /**< height */
97 float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */
98 float refresh_rate; /**< refresh rate (or 0.0f for unspecified) */
99 int refresh_rate_numerator; /**< precise refresh rate numerator (or 0 for unspecified) */
100 int refresh_rate_denominator; /**< precise refresh rate denominator */
101
103
105
106/**
107 * Display orientation values; the way a display is rotated.
108 *
109 * \since This enum is available since SDL 3.0.0.
110 */
112{
113 SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */
114 SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */
115 SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */
116 SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */
117 SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */
119
120/**
121 * The struct used as an opaque handle to a window.
122 *
123 * \since This struct is available since SDL 3.0.0.
124 *
125 * \sa SDL_CreateWindow
126 */
127typedef struct SDL_Window SDL_Window;
128
129/**
130 * The flags on a window.
131 *
132 * These cover a lot of true/false, or on/off, window state. Some of it is
133 * immutable after being set through SDL_CreateWindow(), some of it can be
134 * changed on existing windows by the app, and some of it might be altered by
135 * the user or system outside of the app's control.
136 *
137 * \since This datatype is available since SDL 3.0.0.
138 *
139 * \sa SDL_GetWindowFlags
140 */
142
143#define SDL_WINDOW_FULLSCREEN SDL_UINT64_C(0x0000000000000001) /**< window is in fullscreen mode */
144#define SDL_WINDOW_OPENGL SDL_UINT64_C(0x0000000000000002) /**< window usable with OpenGL context */
145#define SDL_WINDOW_OCCLUDED SDL_UINT64_C(0x0000000000000004) /**< window is occluded */
146#define SDL_WINDOW_HIDDEN SDL_UINT64_C(0x0000000000000008) /**< window is neither mapped onto the desktop nor shown in the taskbar/dock/window list; SDL_ShowWindow() is required for it to become visible */
147#define SDL_WINDOW_BORDERLESS SDL_UINT64_C(0x0000000000000010) /**< no window decoration */
148#define SDL_WINDOW_RESIZABLE SDL_UINT64_C(0x0000000000000020) /**< window can be resized */
149#define SDL_WINDOW_MINIMIZED SDL_UINT64_C(0x0000000000000040) /**< window is minimized */
150#define SDL_WINDOW_MAXIMIZED SDL_UINT64_C(0x0000000000000080) /**< window is maximized */
151#define SDL_WINDOW_MOUSE_GRABBED SDL_UINT64_C(0x0000000000000100) /**< window has grabbed mouse input */
152#define SDL_WINDOW_INPUT_FOCUS SDL_UINT64_C(0x0000000000000200) /**< window has input focus */
153#define SDL_WINDOW_MOUSE_FOCUS SDL_UINT64_C(0x0000000000000400) /**< window has mouse focus */
154#define SDL_WINDOW_EXTERNAL SDL_UINT64_C(0x0000000000000800) /**< window not created by SDL */
155#define SDL_WINDOW_MODAL SDL_UINT64_C(0x0000000000001000) /**< window is modal */
156#define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */
157#define SDL_WINDOW_MOUSE_CAPTURE SDL_UINT64_C(0x0000000000004000) /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
158#define SDL_WINDOW_ALWAYS_ON_TOP SDL_UINT64_C(0x0000000000008000) /**< window should always be above others */
159#define SDL_WINDOW_UTILITY SDL_UINT64_C(0x0000000000020000) /**< window should be treated as a utility window, not showing in the task bar and window list */
160#define SDL_WINDOW_TOOLTIP SDL_UINT64_C(0x0000000000040000) /**< window should be treated as a tooltip and does not get mouse or keyboard focus, requires a parent window */
161#define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */
162#define SDL_WINDOW_KEYBOARD_GRABBED SDL_UINT64_C(0x0000000000100000) /**< window has grabbed keyboard input */
163#define SDL_WINDOW_VULKAN SDL_UINT64_C(0x0000000010000000) /**< window usable for Vulkan surface */
164#define SDL_WINDOW_METAL SDL_UINT64_C(0x0000000020000000) /**< window usable for Metal view */
165#define SDL_WINDOW_TRANSPARENT SDL_UINT64_C(0x0000000040000000) /**< window with transparent buffer */
166#define SDL_WINDOW_NOT_FOCUSABLE SDL_UINT64_C(0x0000000080000000) /**< window should not be focusable */
167
168
169/**
170 * Used to indicate that you don't care what the window position is.
171 *
172 * \since This macro is available since SDL 3.0.0.
173 */
174#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
175#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
176#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
177#define SDL_WINDOWPOS_ISUNDEFINED(X) \
178 (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
179
180/**
181 * Used to indicate that the window position should be centered.
182 *
183 * \since This macro is available since SDL 3.0.0.
184 */
185#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
186#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
187#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
188#define SDL_WINDOWPOS_ISCENTERED(X) \
189 (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
190
191/**
192 * Window flash operation.
193 *
194 * \since This enum is available since SDL 3.0.0.
195 */
197{
198 SDL_FLASH_CANCEL, /**< Cancel any window flash state */
199 SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */
200 SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */
202
203/**
204 * An opaque handle to an OpenGL context.
205 *
206 * \since This datatype is available since SDL 3.0.0.
207 *
208 * \sa SDL_GL_CreateContext
209 */
210typedef struct SDL_GLContextState *SDL_GLContext;
211
212/**
213 * Opaque EGL types.
214 *
215 * \since This datatype is available since SDL 3.0.0.
216 */
217typedef void *SDL_EGLDisplay;
218typedef void *SDL_EGLConfig;
219typedef void *SDL_EGLSurface;
220typedef intptr_t SDL_EGLAttrib;
221typedef int SDL_EGLint;
222
223/**
224 * EGL attribute initialization callback types.
225 *
226 * \since This datatype is available since SDL 3.0.0.
227 */
229typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void);
230
231/**
232 * An enumeration of OpenGL configuration attributes.
233 *
234 * While you can set most OpenGL attributes normally, the attributes listed
235 * above must be known before SDL creates the window that will be used with
236 * the OpenGL context. These attributes are set and read with
237 * SDL_GL_SetAttribute() and SDL_GL_GetAttribute().
238 *
239 * In some cases, these attributes are minimum requests; the GL does not
240 * promise to give you exactly what you asked for. It's possible to ask for a
241 * 16-bit depth buffer and get a 24-bit one instead, for example, or to ask
242 * for no stencil buffer and still have one available. Context creation should
243 * fail if the GL can't provide your requested attributes at a minimum, but
244 * you should check to see exactly what you got.
245 *
246 * \since This enum is available since SDL 3.0.0.
247 */
279
280/**
281 * Possible values to be set for the SDL_GL_CONTEXT_PROFILE_MASK attribute.
282 *
283 * \since This enum is available since SDL 3.0.0.
284 */
285typedef enum SDL_GLprofile
286{
289 SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
291
292/**
293 * Possible values to be set for the SDL_GL_CONTEXT_FLAGS attribute.
294 *
295 * \since This enum is available since SDL 3.0.0.
296 */
304
305/**
306 * Possible values to be set for the SDL_GL_CONTEXT_RELEASE_BEHAVIOR
307 * attribute.
308 *
309 * \since This enum is available since SDL 3.0.0.
310 */
316
317/**
318 * Possible values to be set SDL_GL_CONTEXT_RESET_NOTIFICATION attribute.
319 *
320 * \since This enum is available since SDL 3.0.0.
321 */
327
328/* Function prototypes */
329
330/**
331 * Get the number of video drivers compiled into SDL.
332 *
333 * \returns a number >= 1 on success or a negative error code on failure; call
334 * SDL_GetError() for more information.
335 *
336 * \since This function is available since SDL 3.0.0.
337 *
338 * \sa SDL_GetVideoDriver
339 */
340extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
341
342/**
343 * Get the name of a built in video driver.
344 *
345 * The video drivers are presented in the order in which they are normally
346 * checked during initialization.
347 *
348 * The names of drivers are all simple, low-ASCII identifiers, like "cocoa",
349 * "x11" or "windows". These never have Unicode characters, and are not meant
350 * to be proper names.
351 *
352 * \param index the index of a video driver.
353 * \returns the name of the video driver with the given **index**.
354 *
355 * \since This function is available since SDL 3.0.0.
356 *
357 * \sa SDL_GetNumVideoDrivers
358 */
359extern SDL_DECLSPEC const char * SDLCALL SDL_GetVideoDriver(int index);
360
361/**
362 * Get the name of the currently initialized video driver.
363 *
364 * The names of drivers are all simple, low-ASCII identifiers, like "cocoa",
365 * "x11" or "windows". These never have Unicode characters, and are not meant
366 * to be proper names.
367 *
368 * \returns the name of the current video driver or NULL if no driver has been
369 * initialized.
370 *
371 * \since This function is available since SDL 3.0.0.
372 *
373 * \sa SDL_GetNumVideoDrivers
374 * \sa SDL_GetVideoDriver
375 */
376extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentVideoDriver(void);
377
378/**
379 * Get the current system theme.
380 *
381 * \returns the current system theme, light, dark, or unknown.
382 *
383 * \since This function is available since SDL 3.0.0.
384 */
385extern SDL_DECLSPEC SDL_SystemTheme SDLCALL SDL_GetSystemTheme(void);
386
387/**
388 * Get a list of currently connected displays.
389 *
390 * \param count a pointer filled in with the number of displays returned, may
391 * be NULL.
392 * \returns a 0 terminated array of display instance IDs or NULL on failure;
393 * call SDL_GetError() for more information. This should be freed
394 * with SDL_free() when it is no longer needed.
395 *
396 * \since This function is available since SDL 3.0.0.
397 */
398extern SDL_DECLSPEC SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count);
399
400/**
401 * Return the primary display.
402 *
403 * \returns the instance ID of the primary display on success or 0 on failure;
404 * call SDL_GetError() for more information.
405 *
406 * \since This function is available since SDL 3.0.0.
407 *
408 * \sa SDL_GetDisplays
409 */
410extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
411
412/**
413 * Get the properties associated with a display.
414 *
415 * The following read-only properties are provided by SDL:
416 *
417 * - `SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN`: true if the display has HDR
418 * headroom above the SDR white point. This is for informational and
419 * diagnostic purposes only, as not all platforms provide this information
420 * at the display level.
421 *
422 * On KMS/DRM:
423 *
424 * - `SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER`: the "panel
425 * orientation" property for the display in degrees of clockwise rotation.
426 * Note that this is provided only as a hint, and the application is
427 * responsible for any coordinate transformations needed to conform to the
428 * requested display orientation.
429 *
430 * \param displayID the instance ID of the display to query.
431 * \returns a valid property ID on success or 0 on failure; call
432 * SDL_GetError() for more information.
433 *
434 * \since This function is available since SDL 3.0.0.
435 */
436extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID);
437
438#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
439#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
440
441/**
442 * Get the name of a display in UTF-8 encoding.
443 *
444 * \param displayID the instance ID of the display to query.
445 * \returns the name of a display or NULL on failure; call SDL_GetError() for
446 * more information.
447 *
448 * \since This function is available since SDL 3.0.0.
449 *
450 * \sa SDL_GetDisplays
451 */
452extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
453
454/**
455 * Get the desktop area represented by a display.
456 *
457 * The primary display is always located at (0,0).
458 *
459 * \param displayID the instance ID of the display to query.
460 * \param rect the SDL_Rect structure filled in with the display bounds.
461 * \returns 0 on success or a negative error code on failure; call
462 * SDL_GetError() for more information.
463 *
464 * \since This function is available since SDL 3.0.0.
465 *
466 * \sa SDL_GetDisplayUsableBounds
467 * \sa SDL_GetDisplays
468 */
469extern SDL_DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
470
471/**
472 * Get the usable desktop area represented by a display, in screen
473 * coordinates.
474 *
475 * This is the same area as SDL_GetDisplayBounds() reports, but with portions
476 * reserved by the system removed. For example, on Apple's macOS, this
477 * subtracts the area occupied by the menu bar and dock.
478 *
479 * Setting a window to be fullscreen generally bypasses these unusable areas,
480 * so these are good guidelines for the maximum space available to a
481 * non-fullscreen window.
482 *
483 * \param displayID the instance ID of the display to query.
484 * \param rect the SDL_Rect structure filled in with the display bounds.
485 * \returns 0 on success or a negative error code on failure; call
486 * SDL_GetError() for more information.
487 *
488 * \since This function is available since SDL 3.0.0.
489 *
490 * \sa SDL_GetDisplayBounds
491 * \sa SDL_GetDisplays
492 */
493extern SDL_DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
494
495/**
496 * Get the orientation of a display when it is unrotated.
497 *
498 * \param displayID the instance ID of the display to query.
499 * \returns the SDL_DisplayOrientation enum value of the display, or
500 * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
501 *
502 * \since This function is available since SDL 3.0.0.
503 *
504 * \sa SDL_GetDisplays
505 */
507
508/**
509 * Get the orientation of a display.
510 *
511 * \param displayID the instance ID of the display to query.
512 * \returns the SDL_DisplayOrientation enum value of the display, or
513 * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
514 *
515 * \since This function is available since SDL 3.0.0.
516 *
517 * \sa SDL_GetDisplays
518 */
520
521/**
522 * Get the content scale of a display.
523 *
524 * The content scale is the expected scale for content based on the DPI
525 * settings of the display. For example, a 4K display might have a 2.0 (200%)
526 * display scale, which means that the user expects UI elements to be twice as
527 * big on this display, to aid in readability.
528 *
529 * \param displayID the instance ID of the display to query.
530 * \returns the content scale of the display, or 0.0f on failure; call
531 * SDL_GetError() for more information.
532 *
533 * \since This function is available since SDL 3.0.0.
534 *
535 * \sa SDL_GetDisplays
536 */
537extern SDL_DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displayID);
538
539/**
540 * Get a list of fullscreen display modes available on a display.
541 *
542 * The display modes are sorted in this priority:
543 *
544 * - w -> largest to smallest
545 * - h -> largest to smallest
546 * - bits per pixel -> more colors to fewer colors
547 * - packed pixel layout -> largest to smallest
548 * - refresh rate -> highest to lowest
549 * - pixel density -> lowest to highest
550 *
551 * \param displayID the instance ID of the display to query.
552 * \param count a pointer filled in with the number of display modes returned,
553 * may be NULL.
554 * \returns a NULL terminated array of display mode pointers or NULL on
555 * failure; call SDL_GetError() for more information. This is a
556 * single allocation that should be freed with SDL_free() when it is
557 * no longer needed.
558 *
559 * \since This function is available since SDL 3.0.0.
560 *
561 * \sa SDL_GetDisplays
562 */
563extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count);
564
565/**
566 * Get the closest match to the requested display mode.
567 *
568 * The available display modes are scanned and `closest` is filled in with the
569 * closest mode matching the requested mode and returned. The mode format and
570 * refresh rate default to the desktop mode if they are set to 0. The modes
571 * are scanned with size being first priority, format being second priority,
572 * and finally checking the refresh rate. If all the available modes are too
573 * small, then NULL is returned.
574 *
575 * \param displayID the instance ID of the display to query.
576 * \param w the width in pixels of the desired display mode.
577 * \param h the height in pixels of the desired display mode.
578 * \param refresh_rate the refresh rate of the desired display mode, or 0.0f
579 * for the desktop refresh rate.
580 * \param include_high_density_modes boolean to include high density modes in
581 * the search.
582 * \param mode a pointer filled in with the closest display mode equal to or
583 * larger than the desired mode.
584 * \returns 0 on success or a negative error code on failure; call
585 * SDL_GetError() for more information.
586 *
587 * \since This function is available since SDL 3.0.0.
588 *
589 * \sa SDL_GetDisplays
590 * \sa SDL_GetFullscreenDisplayModes
591 */
592extern SDL_DECLSPEC int SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, SDL_bool include_high_density_modes, SDL_DisplayMode *mode);
593
594/**
595 * Get information about the desktop's display mode.
596 *
597 * There's a difference between this function and SDL_GetCurrentDisplayMode()
598 * when SDL runs fullscreen and has changed the resolution. In that case this
599 * function will return the previous native display mode, and not the current
600 * display mode.
601 *
602 * \param displayID the instance ID of the display to query.
603 * \returns a pointer to the desktop display mode or NULL on failure; call
604 * SDL_GetError() for more information.
605 *
606 * \since This function is available since SDL 3.0.0.
607 *
608 * \sa SDL_GetCurrentDisplayMode
609 * \sa SDL_GetDisplays
610 */
611extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID);
612
613/**
614 * Get information about the current display mode.
615 *
616 * There's a difference between this function and SDL_GetDesktopDisplayMode()
617 * when SDL runs fullscreen and has changed the resolution. In that case this
618 * function will return the current display mode, and not the previous native
619 * display mode.
620 *
621 * \param displayID the instance ID of the display to query.
622 * \returns a pointer to the desktop display mode or NULL on failure; call
623 * SDL_GetError() for more information.
624 *
625 * \since This function is available since SDL 3.0.0.
626 *
627 * \sa SDL_GetDesktopDisplayMode
628 * \sa SDL_GetDisplays
629 */
630extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID);
631
632/**
633 * Get the display containing a point.
634 *
635 * \param point the point to query.
636 * \returns the instance ID of the display containing the point or 0 on
637 * failure; call SDL_GetError() for more information.
638 *
639 * \since This function is available since SDL 3.0.0.
640 *
641 * \sa SDL_GetDisplayBounds
642 * \sa SDL_GetDisplays
643 */
644extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
645
646/**
647 * Get the display primarily containing a rect.
648 *
649 * \param rect the rect to query.
650 * \returns the instance ID of the display entirely containing the rect or
651 * closest to the center of the rect on success or 0 on failure; call
652 * SDL_GetError() for more information.
653 *
654 * \since This function is available since SDL 3.0.0.
655 *
656 * \sa SDL_GetDisplayBounds
657 * \sa SDL_GetDisplays
658 */
659extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
660
661/**
662 * Get the display associated with a window.
663 *
664 * \param window the window to query.
665 * \returns the instance ID of the display containing the center of the window
666 * on success or 0 on failure; call SDL_GetError() for more
667 * information.
668 *
669 * \since This function is available since SDL 3.0.0.
670 *
671 * \sa SDL_GetDisplayBounds
672 * \sa SDL_GetDisplays
673 */
674extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
675
676/**
677 * Get the pixel density of a window.
678 *
679 * This is a ratio of pixel size to window size. For example, if the window is
680 * 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it
681 * would have a pixel density of 2.0.
682 *
683 * \param window the window to query.
684 * \returns the pixel density or 0.0f on failure; call SDL_GetError() for more
685 * information.
686 *
687 * \since This function is available since SDL 3.0.0.
688 *
689 * \sa SDL_GetWindowDisplayScale
690 */
691extern SDL_DECLSPEC float SDLCALL SDL_GetWindowPixelDensity(SDL_Window *window);
692
693/**
694 * Get the content display scale relative to a window's pixel size.
695 *
696 * This is a combination of the window pixel density and the display content
697 * scale, and is the expected scale for displaying content in this window. For
698 * example, if a 3840x2160 window had a display scale of 2.0, the user expects
699 * the content to take twice as many pixels and be the same physical size as
700 * if it were being displayed in a 1920x1080 window with a display scale of
701 * 1.0.
702 *
703 * Conceptually this value corresponds to the scale display setting, and is
704 * updated when that setting is changed, or the window moves to a display with
705 * a different scale setting.
706 *
707 * \param window the window to query.
708 * \returns the display scale, or 0.0f on failure; call SDL_GetError() for
709 * more information.
710 *
711 * \since This function is available since SDL 3.0.0.
712 */
713extern SDL_DECLSPEC float SDLCALL SDL_GetWindowDisplayScale(SDL_Window *window);
714
715/**
716 * Set the display mode to use when a window is visible and fullscreen.
717 *
718 * This only affects the display mode used when the window is fullscreen. To
719 * change the window size when the window is not fullscreen, use
720 * SDL_SetWindowSize().
721 *
722 * If the window is currently in the fullscreen state, this request is
723 * asynchronous on some windowing systems and the new mode dimensions may not
724 * be applied immediately upon the return of this function. If an immediate
725 * change is required, call SDL_SyncWindow() to block until the changes have
726 * taken effect.
727 *
728 * When the new mode takes effect, an SDL_EVENT_WINDOW_RESIZED and/or an
729 * SDL_EVENT_WINDOOW_PIXEL_SIZE_CHANGED event will be emitted with the new
730 * mode dimensions.
731 *
732 * \param window the window to affect.
733 * \param mode a pointer to the display mode to use, which can be NULL for
734 * borderless fullscreen desktop mode, or one of the fullscreen
735 * modes returned by SDL_GetFullscreenDisplayModes() to set an
736 * exclusive fullscreen mode.
737 * \returns 0 on success or a negative error code on failure; call
738 * SDL_GetError() for more information.
739 *
740 * \since This function is available since SDL 3.0.0.
741 *
742 * \sa SDL_GetWindowFullscreenMode
743 * \sa SDL_SetWindowFullscreen
744 * \sa SDL_SyncWindow
745 */
746extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode);
747
748/**
749 * Query the display mode to use when a window is visible at fullscreen.
750 *
751 * \param window the window to query.
752 * \returns a pointer to the exclusive fullscreen mode to use or NULL for
753 * borderless fullscreen desktop mode.
754 *
755 * \since This function is available since SDL 3.0.0.
756 *
757 * \sa SDL_SetWindowFullscreenMode
758 * \sa SDL_SetWindowFullscreen
759 */
760extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetWindowFullscreenMode(SDL_Window *window);
761
762/**
763 * Get the raw ICC profile data for the screen the window is currently on.
764 *
765 * \param window the window to query.
766 * \param size the size of the ICC profile.
767 * \returns the raw ICC profile data on success or NULL on failure; call
768 * SDL_GetError() for more information. This should be freed with
769 * SDL_free() when it is no longer needed.
770 *
771 * \since This function is available since SDL 3.0.0.
772 */
773extern SDL_DECLSPEC void * SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size);
774
775/**
776 * Get the pixel format associated with the window.
777 *
778 * \param window the window to query.
779 * \returns the pixel format of the window on success or
780 * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more
781 * information.
782 *
783 * \since This function is available since SDL 3.0.0.
784 */
785extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
786
787/**
788 * Get a list of valid windows.
789 *
790 * \param count a pointer filled in with the number of windows returned, may
791 * be NULL.
792 * \returns a NULL terminated array of SDL_Window pointers or NULL on failure;
793 * call SDL_GetError() for more information. This is a single
794 * allocation that should be freed with SDL_free() when it is no
795 * longer needed.
796 *
797 * \since This function is available since SDL 3.0.0.
798 */
799extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count);
800
801/**
802 * Create a window with the specified dimensions and flags.
803 *
804 * `flags` may be any of the following OR'd together:
805 *
806 * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution
807 * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context
808 * - `SDL_WINDOW_OCCLUDED`: window partially or completely obscured by another
809 * window
810 * - `SDL_WINDOW_HIDDEN`: window is not visible
811 * - `SDL_WINDOW_BORDERLESS`: no window decoration
812 * - `SDL_WINDOW_RESIZABLE`: window can be resized
813 * - `SDL_WINDOW_MINIMIZED`: window is minimized
814 * - `SDL_WINDOW_MAXIMIZED`: window is maximized
815 * - `SDL_WINDOW_MOUSE_GRABBED`: window has grabbed mouse focus
816 * - `SDL_WINDOW_INPUT_FOCUS`: window has input focus
817 * - `SDL_WINDOW_MOUSE_FOCUS`: window has mouse focus
818 * - `SDL_WINDOW_EXTERNAL`: window not created by SDL
819 * - `SDL_WINDOW_MODAL`: window is modal
820 * - `SDL_WINDOW_HIGH_PIXEL_DENSITY`: window uses high pixel density back
821 * buffer if possible
822 * - `SDL_WINDOW_MOUSE_CAPTURE`: window has mouse captured (unrelated to
823 * MOUSE_GRABBED)
824 * - `SDL_WINDOW_ALWAYS_ON_TOP`: window should always be above others
825 * - `SDL_WINDOW_UTILITY`: window should be treated as a utility window, not
826 * showing in the task bar and window list
827 * - `SDL_WINDOW_TOOLTIP`: window should be treated as a tooltip and does not
828 * get mouse or keyboard focus, requires a parent window
829 * - `SDL_WINDOW_POPUP_MENU`: window should be treated as a popup menu,
830 * requires a parent window
831 * - `SDL_WINDOW_KEYBOARD_GRABBED`: window has grabbed keyboard input
832 * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance
833 * - `SDL_WINDOW_METAL`: window usable with a Metal instance
834 * - `SDL_WINDOW_TRANSPARENT`: window with transparent buffer
835 * - `SDL_WINDOW_NOT_FOCUSABLE`: window should not be focusable
836 *
837 * The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set.
838 *
839 * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
840 * property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
841 *
842 * The window pixel size may differ from its window coordinate size if the
843 * window is on a high pixel density display. Use SDL_GetWindowSize() to query
844 * the client area's size in window coordinates, and
845 * SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to query the
846 * drawable size in pixels. Note that the drawable size can vary after the
847 * window is created and should be queried again if you get an
848 * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event.
849 *
850 * If the window is created with any of the SDL_WINDOW_OPENGL or
851 * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
852 * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the
853 * corresponding UnloadLibrary function is called by SDL_DestroyWindow().
854 *
855 * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
856 * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail.
857 *
858 * If SDL_WINDOW_METAL is specified on an OS that does not support Metal,
859 * SDL_CreateWindow() will fail.
860 *
861 * If you intend to use this window with an SDL_Renderer, you should use
862 * SDL_CreateWindowAndRenderer() instead of this function, to avoid window
863 * flicker.
864 *
865 * On non-Apple devices, SDL requires you to either not link to the Vulkan
866 * loader or link to a dynamic library version. This limitation may be removed
867 * in a future version of SDL.
868 *
869 * \param title the title of the window, in UTF-8 encoding.
870 * \param w the width of the window.
871 * \param h the height of the window.
872 * \param flags 0, or one or more SDL_WindowFlags OR'd together.
873 * \returns the window that was created or NULL on failure; call
874 * SDL_GetError() for more information.
875 *
876 * \since This function is available since SDL 3.0.0.
877 *
878 * \sa SDL_CreatePopupWindow
879 * \sa SDL_CreateWindowWithProperties
880 * \sa SDL_DestroyWindow
881 */
882extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int w, int h, SDL_WindowFlags flags);
883
884/**
885 * Create a child popup window of the specified parent window.
886 *
887 * 'flags' **must** contain exactly one of the following: -
888 * 'SDL_WINDOW_TOOLTIP': The popup window is a tooltip and will not pass any
889 * input events. - 'SDL_WINDOW_POPUP_MENU': The popup window is a popup menu.
890 * The topmost popup menu will implicitly gain the keyboard focus.
891 *
892 * The following flags are not relevant to popup window creation and will be
893 * ignored:
894 *
895 * - 'SDL_WINDOW_MINIMIZED'
896 * - 'SDL_WINDOW_MAXIMIZED'
897 * - 'SDL_WINDOW_FULLSCREEN'
898 * - 'SDL_WINDOW_BORDERLESS'
899 *
900 * The parent parameter **must** be non-null and a valid window. The parent of
901 * a popup window can be either a regular, toplevel window, or another popup
902 * window.
903 *
904 * Popup windows cannot be minimized, maximized, made fullscreen, raised,
905 * flash, be made a modal window, be the parent of a modal window, or grab the
906 * mouse and/or keyboard. Attempts to do so will fail.
907 *
908 * Popup windows implicitly do not have a border/decorations and do not appear
909 * on the taskbar/dock or in lists of windows such as alt-tab menus.
910 *
911 * If a parent window is hidden, any child popup windows will be recursively
912 * hidden as well. Child popup windows not explicitly hidden will be restored
913 * when the parent is shown.
914 *
915 * If the parent window is destroyed, any child popup windows will be
916 * recursively destroyed as well.
917 *
918 * \param parent the parent of the window, must not be NULL.
919 * \param offset_x the x position of the popup window relative to the origin
920 * of the parent.
921 * \param offset_y the y position of the popup window relative to the origin
922 * of the parent window.
923 * \param w the width of the window.
924 * \param h the height of the window.
925 * \param flags SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP_MENU, and zero or more
926 * additional SDL_WindowFlags OR'd together.
927 * \returns the window that was created or NULL on failure; call
928 * SDL_GetError() for more information.
929 *
930 * \since This function is available since SDL 3.0.0.
931 *
932 * \sa SDL_CreateWindow
933 * \sa SDL_CreateWindowWithProperties
934 * \sa SDL_DestroyWindow
935 * \sa SDL_GetWindowParent
936 */
937extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags);
938
939/**
940 * Create a window with the specified properties.
941 *
942 * These are the supported properties:
943 *
944 * - `SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN`: true if the window should
945 * be always on top
946 * - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no
947 * window decoration
948 * - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the
949 * window will be used with an externally managed graphics context.
950 * - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should
951 * accept keyboard input (defaults true)
952 * - `SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN`: true if the window should
953 * start in fullscreen mode at desktop resolution
954 * - `SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER`: the height of the window
955 * - `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN`: true if the window should start
956 * hidden
957 * - `SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN`: true if the window
958 * uses a high pixel density buffer if possible
959 * - `SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN`: true if the window should
960 * start maximized
961 * - `SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN`: true if the window is a popup menu
962 * - `SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN`: true if the window will be used
963 * with Metal rendering
964 * - `SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN`: true if the window should
965 * start minimized
966 * - `SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN`: true if the window is modal to
967 * its parent
968 * - `SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN`: true if the window starts
969 * with grabbed mouse focus
970 * - `SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`: true if the window will be used
971 * with OpenGL rendering
972 * - `SDL_PROP_WINDOW_CREATE_PARENT_POINTER`: an SDL_Window that will be the
973 * parent of this window, required for windows with the "toolip", "menu",
974 * and "modal" properties
975 * - `SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN`: true if the window should be
976 * resizable
977 * - `SDL_PROP_WINDOW_CREATE_TITLE_STRING`: the title of the window, in UTF-8
978 * encoding
979 * - `SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN`: true if the window show
980 * transparent in the areas with alpha of 0
981 * - `SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN`: true if the window is a tooltip
982 * - `SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN`: true if the window is a utility
983 * window, not showing in the task bar and window list
984 * - `SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN`: true if the window will be used
985 * with Vulkan rendering
986 * - `SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER`: the width of the window
987 * - `SDL_PROP_WINDOW_CREATE_X_NUMBER`: the x position of the window, or
988 * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is
989 * relative to the parent for windows with the "parent" property set.
990 * - `SDL_PROP_WINDOW_CREATE_Y_NUMBER`: the y position of the window, or
991 * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is
992 * relative to the parent for windows with the "parent" property set.
993 *
994 * These are additional supported properties on macOS:
995 *
996 * - `SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`: the
997 * `(__unsafe_unretained)` NSWindow associated with the window, if you want
998 * to wrap an existing window.
999 * - `SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`: the `(__unsafe_unretained)`
1000 * NSView associated with the window, defaults to `[window contentView]`
1001 *
1002 * These are additional supported properties on Wayland:
1003 *
1004 * - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if
1005 * the application wants to use the Wayland surface for a custom role and
1006 * does not want it attached to an XDG toplevel window. See
1007 * [README/wayland](README/wayland) for more information on using custom
1008 * surfaces.
1009 * - `SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN` - true if the
1010 * application wants an associated `wl_egl_window` object to be created,
1011 * even if the window does not have the OpenGL property or flag set.
1012 * - `SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER` - the wl_surface
1013 * associated with the window, if you want to wrap an existing window. See
1014 * [README/wayland](README/wayland) for more information.
1015 *
1016 * These are additional supported properties on Windows:
1017 *
1018 * - `SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER`: the HWND associated with the
1019 * window, if you want to wrap an existing window.
1020 * - `SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER`: optional,
1021 * another window to share pixel format with, useful for OpenGL windows
1022 *
1023 * These are additional supported properties with X11:
1024 *
1025 * - `SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER`: the X11 Window associated
1026 * with the window, if you want to wrap an existing window.
1027 *
1028 * The window is implicitly shown if the "hidden" property is not set.
1029 *
1030 * Windows with the "tooltip" and "menu" properties are popup windows and have
1031 * the behaviors and guidelines outlined in SDL_CreatePopupWindow().
1032 *
1033 * If this window is being created to be used with an SDL_Renderer, you should
1034 * not add a graphics API specific property
1035 * (`SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`, etc), as SDL will handle that
1036 * internally when it chooses a renderer. However, SDL might need to recreate
1037 * your window at that point, which may cause the window to appear briefly,
1038 * and then flicker as it is recreated. The correct approach to this is to
1039 * create the window with the `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN` property
1040 * set to true, then create the renderer, then show the window with
1041 * SDL_ShowWindow().
1042 *
1043 * \param props the properties to use.
1044 * \returns the window that was created or NULL on failure; call
1045 * SDL_GetError() for more information.
1046 *
1047 * \since This function is available since SDL 3.0.0.
1048 *
1049 * \sa SDL_CreateProperties
1050 * \sa SDL_CreateWindow
1051 * \sa SDL_DestroyWindow
1052 */
1054
1055#define SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN "always_on_top"
1056#define SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN "borderless"
1057#define SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN "focusable"
1058#define SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN "external_graphics_context"
1059#define SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN "fullscreen"
1060#define SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER "height"
1061#define SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN "hidden"
1062#define SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN "high_pixel_density"
1063#define SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN "maximized"
1064#define SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN "menu"
1065#define SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN "metal"
1066#define SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN "minimized"
1067#define SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN "modal"
1068#define SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN "mouse_grabbed"
1069#define SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN "opengl"
1070#define SDL_PROP_WINDOW_CREATE_PARENT_POINTER "parent"
1071#define SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN "resizable"
1072#define SDL_PROP_WINDOW_CREATE_TITLE_STRING "title"
1073#define SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN "transparent"
1074#define SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN "tooltip"
1075#define SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN "utility"
1076#define SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN "vulkan"
1077#define SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER "width"
1078#define SDL_PROP_WINDOW_CREATE_X_NUMBER "x"
1079#define SDL_PROP_WINDOW_CREATE_Y_NUMBER "y"
1080#define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "cocoa.window"
1081#define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "cocoa.view"
1082#define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "wayland.surface_role_custom"
1083#define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "wayland.create_egl_window"
1084#define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "wayland.wl_surface"
1085#define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "win32.hwnd"
1086#define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "win32.pixel_format_hwnd"
1087#define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "x11.window"
1088
1089/**
1090 * Get the numeric ID of a window.
1091 *
1092 * The numeric ID is what SDL_WindowEvent references, and is necessary to map
1093 * these events to specific SDL_Window objects.
1094 *
1095 * \param window the window to query.
1096 * \returns the ID of the window on success or 0 on failure; call
1097 * SDL_GetError() for more information.
1098 *
1099 * \since This function is available since SDL 3.0.0.
1100 *
1101 * \sa SDL_GetWindowFromID
1102 */
1103extern SDL_DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window);
1104
1105/**
1106 * Get a window from a stored ID.
1107 *
1108 * The numeric ID is what SDL_WindowEvent references, and is necessary to map
1109 * these events to specific SDL_Window objects.
1110 *
1111 * \param id the ID of the window.
1112 * \returns the window associated with `id` or NULL if it doesn't exist; call
1113 * SDL_GetError() for more information.
1114 *
1115 * \since This function is available since SDL 3.0.0.
1116 *
1117 * \sa SDL_GetWindowID
1118 */
1119extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(SDL_WindowID id);
1120
1121/**
1122 * Get parent of a window.
1123 *
1124 * \param window the window to query.
1125 * \returns the parent of the window on success or NULL if the window has no
1126 * parent.
1127 *
1128 * \since This function is available since SDL 3.0.0.
1129 *
1130 * \sa SDL_CreatePopupWindow
1131 */
1132extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window);
1133
1134/**
1135 * Get the properties associated with a window.
1136 *
1137 * The following read-only properties are provided by SDL:
1138 *
1139 * - `SDL_PROP_WINDOW_SHAPE_POINTER`: the surface associated with a shaped
1140 * window
1141 * - `SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN`: true if the window has HDR
1142 * headroom above the SDR white point. This property can change dynamically
1143 * when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
1144 * - `SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT`: the value of SDR white in the
1145 * SDL_COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the
1146 * SDR white level in scRGB colorspace, and on Apple platforms this is
1147 * always 1.0 for EDR content. This property can change dynamically when
1148 * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
1149 * - `SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT`: the additional high dynamic range
1150 * that can be displayed, in terms of the SDR white point. When HDR is not
1151 * enabled, this will be 1.0. This property can change dynamically when
1152 * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
1153 *
1154 * On Android:
1155 *
1156 * - `SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER`: the ANativeWindow associated
1157 * with the window
1158 * - `SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER`: the EGLSurface associated with
1159 * the window
1160 *
1161 * On iOS:
1162 *
1163 * - `SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER`: the `(__unsafe_unretained)`
1164 * UIWindow associated with the window
1165 * - `SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER`: the NSInteger tag
1166 * assocated with metal views on the window
1167 * - `SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER`: the OpenGL view's
1168 * framebuffer object. It must be bound when rendering to the screen using
1169 * OpenGL.
1170 * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER`: the OpenGL view's
1171 * renderbuffer object. It must be bound when SDL_GL_SwapWindow is called.
1172 * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER`: the OpenGL
1173 * view's resolve framebuffer, when MSAA is used.
1174 *
1175 * On KMS/DRM:
1176 *
1177 * - `SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER`: the device index associated
1178 * with the window (e.g. the X in /dev/dri/cardX)
1179 * - `SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER`: the DRM FD associated with the
1180 * window
1181 * - `SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER`: the GBM device associated
1182 * with the window
1183 *
1184 * On macOS:
1185 *
1186 * - `SDL_PROP_WINDOW_COCOA_WINDOW_POINTER`: the `(__unsafe_unretained)`
1187 * NSWindow associated with the window
1188 * - `SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER`: the NSInteger tag
1189 * assocated with metal views on the window
1190 *
1191 * On Vivante:
1192 *
1193 * - `SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER`: the EGLNativeDisplayType
1194 * associated with the window
1195 * - `SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER`: the EGLNativeWindowType
1196 * associated with the window
1197 * - `SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER`: the EGLSurface associated with
1198 * the window
1199 *
1200 * On UWP:
1201 *
1202 * - `SDL_PROP_WINDOW_WINRT_WINDOW_POINTER`: the IInspectable CoreWindow
1203 * associated with the window
1204 *
1205 * On Windows:
1206 *
1207 * - `SDL_PROP_WINDOW_WIN32_HWND_POINTER`: the HWND associated with the window
1208 * - `SDL_PROP_WINDOW_WIN32_HDC_POINTER`: the HDC associated with the window
1209 * - `SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER`: the HINSTANCE associated with
1210 * the window
1211 *
1212 * On Wayland:
1213 *
1214 * Note: The `xdg_*` window objects do not internally persist across window
1215 * show/hide calls. They will be null if the window is hidden and must be
1216 * queried each time it is shown.
1217 *
1218 * - `SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER`: the wl_display associated with
1219 * the window
1220 * - `SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER`: the wl_surface associated with
1221 * the window
1222 * - `SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER`: the wl_egl_window
1223 * associated with the window
1224 * - `SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER`: the xdg_surface associated
1225 * with the window
1226 * - `SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER`: the xdg_toplevel role
1227 * associated with the window
1228 * - 'SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING': the export
1229 * handle associated with the window
1230 * - `SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER`: the xdg_popup role
1231 * associated with the window
1232 * - `SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER`: the xdg_positioner
1233 * associated with the window, in popup mode
1234 *
1235 * On X11:
1236 *
1237 * - `SDL_PROP_WINDOW_X11_DISPLAY_POINTER`: the X11 Display associated with
1238 * the window
1239 * - `SDL_PROP_WINDOW_X11_SCREEN_NUMBER`: the screen number associated with
1240 * the window
1241 * - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the
1242 * window
1243 *
1244 * \param window the window to query.
1245 * \returns a valid property ID on success or 0 on failure; call
1246 * SDL_GetError() for more information.
1247 *
1248 * \since This function is available since SDL 3.0.0.
1249 */
1250extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window *window);
1251
1252#define SDL_PROP_WINDOW_SHAPE_POINTER "SDL.window.shape"
1253#define SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN "SDL.window.HDR_enabled"
1254#define SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT "SDL.window.SDR_white_level"
1255#define SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT "SDL.window.HDR_headroom"
1256#define SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER "SDL.window.android.window"
1257#define SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER "SDL.window.android.surface"
1258#define SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER "SDL.window.uikit.window"
1259#define SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER "SDL.window.uikit.metal_view_tag"
1260#define SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.framebuffer"
1261#define SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER "SDL.window.uikit.opengl.renderbuffer"
1262#define SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.resolve_framebuffer"
1263#define SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER "SDL.window.kmsdrm.dev_index"
1264#define SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER "SDL.window.kmsdrm.drm_fd"
1265#define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev"
1266#define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window"
1267#define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag"
1268#define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display"
1269#define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window"
1270#define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface"
1271#define SDL_PROP_WINDOW_WINRT_WINDOW_POINTER "SDL.window.winrt.window"
1272#define SDL_PROP_WINDOW_WIN32_HWND_POINTER "SDL.window.win32.hwnd"
1273#define SDL_PROP_WINDOW_WIN32_HDC_POINTER "SDL.window.win32.hdc"
1274#define SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER "SDL.window.win32.instance"
1275#define SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER "SDL.window.wayland.display"
1276#define SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER "SDL.window.wayland.surface"
1277#define SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER "SDL.window.wayland.egl_window"
1278#define SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER "SDL.window.wayland.xdg_surface"
1279#define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER "SDL.window.wayland.xdg_toplevel"
1280#define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING "SDL.window.wayland.xdg_toplevel_export_handle"
1281#define SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER "SDL.window.wayland.xdg_popup"
1282#define SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER "SDL.window.wayland.xdg_positioner"
1283#define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display"
1284#define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen"
1285#define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window"
1286
1287/**
1288 * Get the window flags.
1289 *
1290 * \param window the window to query.
1291 * \returns a mask of the SDL_WindowFlags associated with `window`.
1292 *
1293 * \since This function is available since SDL 3.0.0.
1294 *
1295 * \sa SDL_CreateWindow
1296 * \sa SDL_HideWindow
1297 * \sa SDL_MaximizeWindow
1298 * \sa SDL_MinimizeWindow
1299 * \sa SDL_SetWindowFullscreen
1300 * \sa SDL_SetWindowMouseGrab
1301 * \sa SDL_ShowWindow
1302 */
1303extern SDL_DECLSPEC SDL_WindowFlags SDLCALL SDL_GetWindowFlags(SDL_Window *window);
1304
1305/**
1306 * Set the title of a window.
1307 *
1308 * This string is expected to be in UTF-8 encoding.
1309 *
1310 * \param window the window to change.
1311 * \param title the desired window title in UTF-8 format.
1312 * \returns 0 on success or a negative error code on failure; call
1313 * SDL_GetError() for more information.
1314 *
1315 * \since This function is available since SDL 3.0.0.
1316 *
1317 * \sa SDL_GetWindowTitle
1318 */
1319extern SDL_DECLSPEC int SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
1320
1321/**
1322 * Get the title of a window.
1323 *
1324 * \param window the window to query.
1325 * \returns the title of the window in UTF-8 format or "" if there is no
1326 * title.
1327 *
1328 * \since This function is available since SDL 3.0.0.
1329 *
1330 * \sa SDL_SetWindowTitle
1331 */
1332extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
1333
1334/**
1335 * Set the icon for a window.
1336 *
1337 * \param window the window to change.
1338 * \param icon an SDL_Surface structure containing the icon for the window.
1339 * \returns 0 on success or a negative error code on failure; call
1340 * SDL_GetError() for more information.
1341 *
1342 * \since This function is available since SDL 3.0.0.
1343 */
1344extern SDL_DECLSPEC int SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
1345
1346/**
1347 * Request that the window's position be set.
1348 *
1349 * If, at the time of this request, the window is in a fixed-size state such
1350 * as maximized, this request may be deferred until the window returns to a
1351 * resizable state.
1352 *
1353 * This can be used to reposition fullscreen-desktop windows onto a different
1354 * display, however, exclusive fullscreen windows are locked to a specific
1355 * display and can only be repositioned programmatically via
1356 * SDL_SetWindowFullscreenMode().
1357 *
1358 * On some windowing systems this request is asynchronous and the new
1359 * coordinates may not have have been applied immediately upon the return of
1360 * this function. If an immediate change is required, call SDL_SyncWindow() to
1361 * block until the changes have taken effect.
1362 *
1363 * When the window position changes, an SDL_EVENT_WINDOW_MOVED event will be
1364 * emitted with the window's new coordinates. Note that the new coordinates
1365 * may not match the exact coordinates requested, as some windowing systems
1366 * can restrict the position of the window in certain scenarios (e.g.
1367 * constraining the position so the window is always within desktop bounds).
1368 * Additionally, as this is just a request, it can be denied by the windowing
1369 * system.
1370 *
1371 * \param window the window to reposition.
1372 * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
1373 * `SDL_WINDOWPOS_UNDEFINED`.
1374 * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
1375 * `SDL_WINDOWPOS_UNDEFINED`.
1376 * \returns 0 on success or a negative error code on failure; call
1377 * SDL_GetError() for more information.
1378 *
1379 * \since This function is available since SDL 3.0.0.
1380 *
1381 * \sa SDL_GetWindowPosition
1382 * \sa SDL_SyncWindow
1383 */
1384extern SDL_DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
1385
1386/**
1387 * Get the position of a window.
1388 *
1389 * This is the current position of the window as last reported by the
1390 * windowing system.
1391 *
1392 * If you do not need the value for one of the positions a NULL may be passed
1393 * in the `x` or `y` parameter.
1394 *
1395 * \param window the window to query.
1396 * \param x a pointer filled in with the x position of the window, may be
1397 * NULL.
1398 * \param y a pointer filled in with the y position of the window, may be
1399 * NULL.
1400 * \returns 0 on success or a negative error code on failure; call
1401 * SDL_GetError() for more information.
1402 *
1403 * \since This function is available since SDL 3.0.0.
1404 *
1405 * \sa SDL_SetWindowPosition
1406 */
1407extern SDL_DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
1408
1409/**
1410 * Request that the size of a window's client area be set.
1411 *
1412 * If, at the time of this request, the window in a fixed-size state, such as
1413 * maximized or fullscreen, the request will be deferred until the window
1414 * exits this state and becomes resizable again.
1415 *
1416 * To change the fullscreen mode of a window, use
1417 * SDL_SetWindowFullscreenMode()
1418 *
1419 * On some windowing systems, this request is asynchronous and the new window
1420 * size may not have have been applied immediately upon the return of this
1421 * function. If an immediate change is required, call SDL_SyncWindow() to
1422 * block until the changes have taken effect.
1423 *
1424 * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be
1425 * emitted with the new window dimensions. Note that the new dimensions may
1426 * not match the exact size requested, as some windowing systems can restrict
1427 * the window size in certain scenarios (e.g. constraining the size of the
1428 * content area to remain within the usable desktop bounds). Additionally, as
1429 * this is just a request, it can be denied by the windowing system.
1430 *
1431 * \param window the window to change.
1432 * \param w the width of the window, must be > 0.
1433 * \param h the height of the window, must be > 0.
1434 * \returns 0 on success or a negative error code on failure; call
1435 * SDL_GetError() for more information.
1436 *
1437 * \since This function is available since SDL 3.0.0.
1438 *
1439 * \sa SDL_GetWindowSize
1440 * \sa SDL_SetWindowFullscreenMode
1441 * \sa SDL_SyncWindow
1442 */
1443extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
1444
1445/**
1446 * Get the size of a window's client area.
1447 *
1448 * The window pixel size may differ from its window coordinate size if the
1449 * window is on a high pixel density display. Use SDL_GetWindowSizeInPixels()
1450 * or SDL_GetRenderOutputSize() to get the real client area size in pixels.
1451 *
1452 * \param window the window to query the width and height from.
1453 * \param w a pointer filled in with the width of the window, may be NULL.
1454 * \param h a pointer filled in with the height of the window, may be NULL.
1455 * \returns 0 on success or a negative error code on failure; call
1456 * SDL_GetError() for more information.
1457 *
1458 * \since This function is available since SDL 3.0.0.
1459 *
1460 * \sa SDL_GetRenderOutputSize
1461 * \sa SDL_GetWindowSizeInPixels
1462 * \sa SDL_SetWindowSize
1463 */
1464extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
1465
1466/**
1467 * Get the safe area for this window.
1468 *
1469 * Some devices have portions of the screen which are partially obscured or
1470 * not interactive, possibly due to on-screen controls, curved edges, camera
1471 * notches, TV overscan, etc. This function provides the area of the window
1472 * which is safe to have interactible content. You should continue rendering
1473 * into the rest of the window, but it should not contain visually important
1474 * or interactible content.
1475 *
1476 * \param window the window to query.
1477 * \param rect a pointer filled in with the client area that is safe for
1478 * interactive content.
1479 * \returns 0 on success or a negative error code on failure; call
1480 * SDL_GetError() for more information.
1481 *
1482 * \since This function is available since SDL 3.0.0.
1483 */
1484extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect);
1485
1486/**
1487 * Request that the aspect ratio of a window's client area be set.
1488 *
1489 * The aspect ratio is the ratio of width divided by height, e.g. 2560x1600
1490 * would be 1.6. Larger aspect ratios are wider and smaller aspect ratios are
1491 * narrower.
1492 *
1493 * If, at the time of this request, the window in a fixed-size state, such as
1494 * maximized or fullscreen, the request will be deferred until the window
1495 * exits this state and becomes resizable again.
1496 *
1497 * On some windowing systems, this request is asynchronous and the new window
1498 * aspect ratio may not have have been applied immediately upon the return of
1499 * this function. If an immediate change is required, call SDL_SyncWindow() to
1500 * block until the changes have taken effect.
1501 *
1502 * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be
1503 * emitted with the new window dimensions. Note that the new dimensions may
1504 * not match the exact aspect ratio requested, as some windowing systems can
1505 * restrict the window size in certain scenarios (e.g. constraining the size
1506 * of the content area to remain within the usable desktop bounds).
1507 * Additionally, as this is just a request, it can be denied by the windowing
1508 * system.
1509 *
1510 * \param window the window to change.
1511 * \param min_aspect the minimum aspect ratio of the window, or 0.0f for no
1512 * limit.
1513 * \param max_aspect the maximum aspect ratio of the window, or 0.0f for no
1514 * limit.
1515 * \returns 0 on success or a negative error code on failure; call
1516 * SDL_GetError() for more information.
1517 *
1518 * \since This function is available since SDL 3.0.0.
1519 *
1520 * \sa SDL_GetWindowAspectRatio
1521 * \sa SDL_SyncWindow
1522 */
1523extern SDL_DECLSPEC int SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect);
1524
1525/**
1526 * Get the size of a window's client area.
1527 *
1528 * \param window the window to query the width and height from.
1529 * \param min_aspect a pointer filled in with the minimum aspect ratio of the
1530 * window, may be NULL.
1531 * \param max_aspect a pointer filled in with the maximum aspect ratio of the
1532 * window, may be NULL.
1533 * \returns 0 on success or a negative error code on failure; call
1534 * SDL_GetError() for more information.
1535 *
1536 * \since This function is available since SDL 3.0.0.
1537 *
1538 * \sa SDL_SetWindowAspectRatio
1539 */
1540extern SDL_DECLSPEC int SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect);
1541
1542/**
1543 * Get the size of a window's borders (decorations) around the client area.
1544 *
1545 * Note: If this function fails (returns -1), the size values will be
1546 * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the
1547 * window in question was borderless.
1548 *
1549 * Note: This function may fail on systems where the window has not yet been
1550 * decorated by the display server (for example, immediately after calling
1551 * SDL_CreateWindow). It is recommended that you wait at least until the
1552 * window has been presented and composited, so that the window system has a
1553 * chance to decorate the window and provide the border dimensions to SDL.
1554 *
1555 * This function also returns -1 if getting the information is not supported.
1556 *
1557 * \param window the window to query the size values of the border
1558 * (decorations) from.
1559 * \param top pointer to variable for storing the size of the top border; NULL
1560 * is permitted.
1561 * \param left pointer to variable for storing the size of the left border;
1562 * NULL is permitted.
1563 * \param bottom pointer to variable for storing the size of the bottom
1564 * border; NULL is permitted.
1565 * \param right pointer to variable for storing the size of the right border;
1566 * NULL is permitted.
1567 * \returns 0 on success or a negative error code on failure; call
1568 * SDL_GetError() for more information.
1569 *
1570 * \since This function is available since SDL 3.0.0.
1571 *
1572 * \sa SDL_GetWindowSize
1573 */
1574extern SDL_DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
1575
1576/**
1577 * Get the size of a window's client area, in pixels.
1578 *
1579 * \param window the window from which the drawable size should be queried.
1580 * \param w a pointer to variable for storing the width in pixels, may be
1581 * NULL.
1582 * \param h a pointer to variable for storing the height in pixels, may be
1583 * NULL.
1584 * \returns 0 on success or a negative error code on failure; call
1585 * SDL_GetError() for more information.
1586 *
1587 * \since This function is available since SDL 3.0.0.
1588 *
1589 * \sa SDL_CreateWindow
1590 * \sa SDL_GetWindowSize
1591 */
1592extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
1593
1594/**
1595 * Set the minimum size of a window's client area.
1596 *
1597 * \param window the window to change.
1598 * \param min_w the minimum width of the window, or 0 for no limit.
1599 * \param min_h the minimum height of the window, or 0 for no limit.
1600 * \returns 0 on success or a negative error code on failure; call
1601 * SDL_GetError() for more information.
1602 *
1603 * \since This function is available since SDL 3.0.0.
1604 *
1605 * \sa SDL_GetWindowMinimumSize
1606 * \sa SDL_SetWindowMaximumSize
1607 */
1608extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
1609
1610/**
1611 * Get the minimum size of a window's client area.
1612 *
1613 * \param window the window to query.
1614 * \param w a pointer filled in with the minimum width of the window, may be
1615 * NULL.
1616 * \param h a pointer filled in with the minimum height of the window, may be
1617 * NULL.
1618 * \returns 0 on success or a negative error code on failure; call
1619 * SDL_GetError() for more information.
1620 *
1621 * \since This function is available since SDL 3.0.0.
1622 *
1623 * \sa SDL_GetWindowMaximumSize
1624 * \sa SDL_SetWindowMinimumSize
1625 */
1626extern SDL_DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
1627
1628/**
1629 * Set the maximum size of a window's client area.
1630 *
1631 * \param window the window to change.
1632 * \param max_w the maximum width of the window, or 0 for no limit.
1633 * \param max_h the maximum height of the window, or 0 for no limit.
1634 * \returns 0 on success or a negative error code on failure; call
1635 * SDL_GetError() for more information.
1636 *
1637 * \since This function is available since SDL 3.0.0.
1638 *
1639 * \sa SDL_GetWindowMaximumSize
1640 * \sa SDL_SetWindowMinimumSize
1641 */
1642extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
1643
1644/**
1645 * Get the maximum size of a window's client area.
1646 *
1647 * \param window the window to query.
1648 * \param w a pointer filled in with the maximum width of the window, may be
1649 * NULL.
1650 * \param h a pointer filled in with the maximum height of the window, may be
1651 * NULL.
1652 * \returns 0 on success or a negative error code on failure; call
1653 * SDL_GetError() for more information.
1654 *
1655 * \since This function is available since SDL 3.0.0.
1656 *
1657 * \sa SDL_GetWindowMinimumSize
1658 * \sa SDL_SetWindowMaximumSize
1659 */
1660extern SDL_DECLSPEC int SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
1661
1662/**
1663 * Set the border state of a window.
1664 *
1665 * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add
1666 * or remove the border from the actual window. This is a no-op if the
1667 * window's border already matches the requested state.
1668 *
1669 * You can't change the border state of a fullscreen window.
1670 *
1671 * \param window the window of which to change the border state.
1672 * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border.
1673 * \returns 0 on success or a negative error code on failure; call
1674 * SDL_GetError() for more information.
1675 *
1676 * \since This function is available since SDL 3.0.0.
1677 *
1678 * \sa SDL_GetWindowFlags
1679 */
1680extern SDL_DECLSPEC int SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
1681
1682/**
1683 * Set the user-resizable state of a window.
1684 *
1685 * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and
1686 * allow/disallow user resizing of the window. This is a no-op if the window's
1687 * resizable state already matches the requested state.
1688 *
1689 * You can't change the resizable state of a fullscreen window.
1690 *
1691 * \param window the window of which to change the resizable state.
1692 * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow.
1693 * \returns 0 on success or a negative error code on failure; call
1694 * SDL_GetError() for more information.
1695 *
1696 * \since This function is available since SDL 3.0.0.
1697 *
1698 * \sa SDL_GetWindowFlags
1699 */
1700extern SDL_DECLSPEC int SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
1701
1702/**
1703 * Set the window to always be above the others.
1704 *
1705 * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This
1706 * will bring the window to the front and keep the window above the rest.
1707 *
1708 * \param window the window of which to change the always on top state.
1709 * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
1710 * disable.
1711 * \returns 0 on success or a negative error code on failure; call
1712 * SDL_GetError() for more information.
1713 *
1714 * \since This function is available since SDL 3.0.0.
1715 *
1716 * \sa SDL_GetWindowFlags
1717 */
1718extern SDL_DECLSPEC int SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
1719
1720/**
1721 * Show a window.
1722 *
1723 * \param window the window to show.
1724 * \returns 0 on success or a negative error code on failure; call
1725 * SDL_GetError() for more information.
1726 *
1727 * \since This function is available since SDL 3.0.0.
1728 *
1729 * \sa SDL_HideWindow
1730 * \sa SDL_RaiseWindow
1731 */
1732extern SDL_DECLSPEC int SDLCALL SDL_ShowWindow(SDL_Window *window);
1733
1734/**
1735 * Hide a window.
1736 *
1737 * \param window the window to hide.
1738 * \returns 0 on success or a negative error code on failure; call
1739 * SDL_GetError() for more information.
1740 *
1741 * \since This function is available since SDL 3.0.0.
1742 *
1743 * \sa SDL_ShowWindow
1744 */
1745extern SDL_DECLSPEC int SDLCALL SDL_HideWindow(SDL_Window *window);
1746
1747/**
1748 * Request that a window be raised above other windows and gain the input
1749 * focus.
1750 *
1751 * The result of this request is subject to desktop window manager policy,
1752 * particularly if raising the requested window would result in stealing focus
1753 * from another application. If the window is successfully raised and gains
1754 * input focus, an SDL_EVENT_WINDOW_FOCUS_GAINED event will be emitted, and
1755 * the window will have the SDL_WINDOW_INPUT_FOCUS flag set.
1756 *
1757 * \param window the window to raise.
1758 * \returns 0 on success or a negative error code on failure; call
1759 * SDL_GetError() for more information.
1760 *
1761 * \since This function is available since SDL 3.0.0.
1762 */
1763extern SDL_DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
1764
1765/**
1766 * Request that the window be made as large as possible.
1767 *
1768 * Non-resizable windows can't be maximized. The window must have the
1769 * SDL_WINDOW_RESIZABLE flag set, or this will have no effect.
1770 *
1771 * On some windowing systems this request is asynchronous and the new window
1772 * state may not have have been applied immediately upon the return of this
1773 * function. If an immediate change is required, call SDL_SyncWindow() to
1774 * block until the changes have taken effect.
1775 *
1776 * When the window state changes, an SDL_EVENT_WINDOW_MAXIMIZED event will be
1777 * emitted. Note that, as this is just a request, the windowing system can
1778 * deny the state change.
1779 *
1780 * When maximizing a window, whether the constraints set via
1781 * SDL_SetWindowMaximumSize() are honored depends on the policy of the window
1782 * manager. Win32 and macOS enforce the constraints when maximizing, while X11
1783 * and Wayland window managers may vary.
1784 *
1785 * \param window the window to maximize.
1786 * \returns 0 on success or a negative error code on failure; call
1787 * SDL_GetError() for more information.
1788 *
1789 * \since This function is available since SDL 3.0.0.
1790 *
1791 * \sa SDL_MinimizeWindow
1792 * \sa SDL_RestoreWindow
1793 * \sa SDL_SyncWindow
1794 */
1795extern SDL_DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
1796
1797/**
1798 * Request that the window be minimized to an iconic representation.
1799 *
1800 * On some windowing systems this request is asynchronous and the new window
1801 * state may not have have been applied immediately upon the return of this
1802 * function. If an immediate change is required, call SDL_SyncWindow() to
1803 * block until the changes have taken effect.
1804 *
1805 * When the window state changes, an SDL_EVENT_WINDOW_MINIMIZED event will be
1806 * emitted. Note that, as this is just a request, the windowing system can
1807 * deny the state change.
1808 *
1809 * \param window the window to minimize.
1810 * \returns 0 on success or a negative error code on failure; call
1811 * SDL_GetError() for more information.
1812 *
1813 * \since This function is available since SDL 3.0.0.
1814 *
1815 * \sa SDL_MaximizeWindow
1816 * \sa SDL_RestoreWindow
1817 * \sa SDL_SyncWindow
1818 */
1819extern SDL_DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
1820
1821/**
1822 * Request that the size and position of a minimized or maximized window be
1823 * restored.
1824 *
1825 * On some windowing systems this request is asynchronous and the new window
1826 * state may not have have been applied immediately upon the return of this
1827 * function. If an immediate change is required, call SDL_SyncWindow() to
1828 * block until the changes have taken effect.
1829 *
1830 * When the window state changes, an SDL_EVENT_WINDOW_RESTORED event will be
1831 * emitted. Note that, as this is just a request, the windowing system can
1832 * deny the state change.
1833 *
1834 * \param window the window to restore.
1835 * \returns 0 on success or a negative error code on failure; call
1836 * SDL_GetError() for more information.
1837 *
1838 * \since This function is available since SDL 3.0.0.
1839 *
1840 * \sa SDL_MaximizeWindow
1841 * \sa SDL_MinimizeWindow
1842 * \sa SDL_SyncWindow
1843 */
1844extern SDL_DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
1845
1846/**
1847 * Request that the window's fullscreen state be changed.
1848 *
1849 * By default a window in fullscreen state uses borderless fullscreen desktop
1850 * mode, but a specific exclusive display mode can be set using
1851 * SDL_SetWindowFullscreenMode().
1852 *
1853 * On some windowing systems this request is asynchronous and the new
1854 * fullscreen state may not have have been applied immediately upon the return
1855 * of this function. If an immediate change is required, call SDL_SyncWindow()
1856 * to block until the changes have taken effect.
1857 *
1858 * When the window state changes, an SDL_EVENT_WINDOW_ENTER_FULLSCREEN or
1859 * SDL_EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this
1860 * is just a request, it can be denied by the windowing system.
1861 *
1862 * \param window the window to change.
1863 * \param fullscreen SDL_TRUE for fullscreen mode, SDL_FALSE for windowed
1864 * mode.
1865 * \returns 0 on success or a negative error code on failure; call
1866 * SDL_GetError() for more information.
1867 *
1868 * \since This function is available since SDL 3.0.0.
1869 *
1870 * \sa SDL_GetWindowFullscreenMode
1871 * \sa SDL_SetWindowFullscreenMode
1872 * \sa SDL_SyncWindow
1873 */
1874extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen);
1875
1876/**
1877 * Block until any pending window state is finalized.
1878 *
1879 * On asynchronous windowing systems, this acts as a synchronization barrier
1880 * for pending window state. It will attempt to wait until any pending window
1881 * state has been applied and is guaranteed to return within finite time. Note
1882 * that for how long it can potentially block depends on the underlying window
1883 * system, as window state changes may involve somewhat lengthy animations
1884 * that must complete before the window is in its final requested state.
1885 *
1886 * On windowing systems where changes are immediate, this does nothing.
1887 *
1888 * \param window the window for which to wait for the pending state to be
1889 * applied.
1890 * \returns 0 on success, a positive value if the operation timed out before
1891 * the window was in the requested state, or a negative error code on
1892 * failure; call SDL_GetError() for more information.
1893 *
1894 * \since This function is available since SDL 3.0.0.
1895 *
1896 * \sa SDL_SetWindowSize
1897 * \sa SDL_SetWindowPosition
1898 * \sa SDL_SetWindowFullscreen
1899 * \sa SDL_MinimizeWindow
1900 * \sa SDL_MaximizeWindow
1901 * \sa SDL_RestoreWindow
1902 * \sa SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS
1903 */
1904extern SDL_DECLSPEC int SDLCALL SDL_SyncWindow(SDL_Window *window);
1905
1906/**
1907 * Return whether the window has a surface associated with it.
1908 *
1909 * \param window the window to query.
1910 * \returns SDL_TRUE if there is a surface associated with the window, or
1911 * SDL_FALSE otherwise.
1912 *
1913 * \since This function is available since SDL 3.0.0.
1914 *
1915 * \sa SDL_GetWindowSurface
1916 */
1917extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowHasSurface(SDL_Window *window);
1918
1919/**
1920 * Get the SDL surface associated with the window.
1921 *
1922 * A new surface will be created with the optimal format for the window, if
1923 * necessary. This surface will be freed when the window is destroyed. Do not
1924 * free this surface.
1925 *
1926 * This surface will be invalidated if the window is resized. After resizing a
1927 * window this function must be called again to return a valid surface.
1928 *
1929 * You may not combine this with 3D or the rendering API on this window.
1930 *
1931 * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`.
1932 *
1933 * \param window the window to query.
1934 * \returns the surface associated with the window, or NULL on failure; call
1935 * SDL_GetError() for more information.
1936 *
1937 * \since This function is available since SDL 3.0.0.
1938 *
1939 * \sa SDL_DestroyWindowSurface
1940 * \sa SDL_WindowHasSurface
1941 * \sa SDL_UpdateWindowSurface
1942 * \sa SDL_UpdateWindowSurfaceRects
1943 */
1944extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window *window);
1945
1946/**
1947 * Toggle VSync for the window surface.
1948 *
1949 * When a window surface is created, vsync defaults to
1950 * SDL_WINDOW_SURFACE_VSYNC_DISABLED.
1951 *
1952 * The `vsync` parameter can be 1 to synchronize present with every vertical
1953 * refresh, 2 to synchronize present with every second vertical refresh, etc.,
1954 * SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync),
1955 * or SDL_WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is
1956 * supported by every driver, so you should check the return value to see
1957 * whether the requested setting is supported.
1958 *
1959 * \param window the window.
1960 * \param vsync the vertical refresh sync interval.
1961 * \returns 0 on success or a negative error code on failure; call
1962 * SDL_GetError() for more information.
1963 *
1964 * \since This function is available since SDL 3.0.0.
1965 *
1966 * \sa SDL_GetWindowSurfaceVSync
1967 */
1968extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync);
1969
1970#define SDL_WINDOW_SURFACE_VSYNC_DISABLED 0
1971#define SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE (-1)
1972
1973/**
1974 * Get VSync for the window surface.
1975 *
1976 * \param window the window to query.
1977 * \param vsync an int filled with the current vertical refresh sync interval.
1978 * See SDL_SetWindowSurfaceVSync() for the meaning of the value.
1979 * \returns 0 on success or a negative error code on failure; call
1980 * SDL_GetError() for more information.
1981 *
1982 * \since This function is available since SDL 3.0.0.
1983 *
1984 * \sa SDL_SetWindowSurfaceVSync
1985 */
1986extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync);
1987
1988/**
1989 * Copy the window surface to the screen.
1990 *
1991 * This is the function you use to reflect any changes to the surface on the
1992 * screen.
1993 *
1994 * This function is equivalent to the SDL 1.2 API SDL_Flip().
1995 *
1996 * \param window the window to update.
1997 * \returns 0 on success or a negative error code on failure; call
1998 * SDL_GetError() for more information.
1999 *
2000 * \since This function is available since SDL 3.0.0.
2001 *
2002 * \sa SDL_GetWindowSurface
2003 * \sa SDL_UpdateWindowSurfaceRects
2004 */
2005extern SDL_DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
2006
2007/**
2008 * Copy areas of the window surface to the screen.
2009 *
2010 * This is the function you use to reflect changes to portions of the surface
2011 * on the screen.
2012 *
2013 * This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
2014 *
2015 * Note that this function will update _at least_ the rectangles specified,
2016 * but this is only intended as an optimization; in practice, this might
2017 * update more of the screen (or all of the screen!), depending on what method
2018 * SDL uses to send pixels to the system.
2019 *
2020 * \param window the window to update.
2021 * \param rects an array of SDL_Rect structures representing areas of the
2022 * surface to copy, in pixels.
2023 * \param numrects the number of rectangles.
2024 * \returns 0 on success or a negative error code on failure; call
2025 * SDL_GetError() for more information.
2026 *
2027 * \since This function is available since SDL 3.0.0.
2028 *
2029 * \sa SDL_GetWindowSurface
2030 * \sa SDL_UpdateWindowSurface
2031 */
2032extern SDL_DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
2033
2034/**
2035 * Destroy the surface associated with the window.
2036 *
2037 * \param window the window to update.
2038 * \returns 0 on success or a negative error code on failure; call
2039 * SDL_GetError() for more information.
2040 *
2041 * \since This function is available since SDL 3.0.0.
2042 *
2043 * \sa SDL_GetWindowSurface
2044 * \sa SDL_WindowHasSurface
2045 */
2046extern SDL_DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
2047
2048/**
2049 * Set a window's keyboard grab mode.
2050 *
2051 * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or
2052 * the Meta/Super key. Note that not all system keyboard shortcuts can be
2053 * captured by applications (one example is Ctrl+Alt+Del on Windows).
2054 *
2055 * This is primarily intended for specialized applications such as VNC clients
2056 * or VM frontends. Normal games should not use keyboard grab.
2057 *
2058 * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the
2059 * window is full-screen to ensure the user is not trapped in your
2060 * application. If you have a custom keyboard shortcut to exit fullscreen
2061 * mode, you may suppress this behavior with
2062 * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`.
2063 *
2064 * If the caller enables a grab while another window is currently grabbed, the
2065 * other window loses its grab in favor of the caller's window.
2066 *
2067 * \param window the window for which the keyboard grab mode should be set.
2068 * \param grabbed this is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
2069 * \returns 0 on success or a negative error code on failure; call
2070 * SDL_GetError() for more information.
2071 *
2072 * \since This function is available since SDL 3.0.0.
2073 *
2074 * \sa SDL_GetWindowKeyboardGrab
2075 * \sa SDL_SetWindowMouseGrab
2076 */
2077extern SDL_DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
2078
2079/**
2080 * Set a window's mouse grab mode.
2081 *
2082 * Mouse grab confines the mouse cursor to the window.
2083 *
2084 * \param window the window for which the mouse grab mode should be set.
2085 * \param grabbed this is SDL_TRUE to grab mouse, and SDL_FALSE to release.
2086 * \returns 0 on success or a negative error code on failure; call
2087 * SDL_GetError() for more information.
2088 *
2089 * \since This function is available since SDL 3.0.0.
2090 *
2091 * \sa SDL_GetWindowMouseGrab
2092 * \sa SDL_SetWindowKeyboardGrab
2093 */
2094extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
2095
2096/**
2097 * Get a window's keyboard grab mode.
2098 *
2099 * \param window the window to query.
2100 * \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise.
2101 *
2102 * \since This function is available since SDL 3.0.0.
2103 *
2104 * \sa SDL_SetWindowKeyboardGrab
2105 */
2106extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window *window);
2107
2108/**
2109 * Get a window's mouse grab mode.
2110 *
2111 * \param window the window to query.
2112 * \returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise.
2113 *
2114 * \since This function is available since SDL 3.0.0.
2115 *
2116 * \sa SDL_SetWindowKeyboardGrab
2117 */
2118extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window *window);
2119
2120/**
2121 * Get the window that currently has an input grab enabled.
2122 *
2123 * \returns the window if input is grabbed or NULL otherwise.
2124 *
2125 * \since This function is available since SDL 3.0.0.
2126 *
2127 * \sa SDL_SetWindowMouseGrab
2128 * \sa SDL_SetWindowKeyboardGrab
2129 */
2130extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
2131
2132/**
2133 * Confines the cursor to the specified area of a window.
2134 *
2135 * Note that this does NOT grab the cursor, it only defines the area a cursor
2136 * is restricted to when the window has mouse focus.
2137 *
2138 * \param window the window that will be associated with the barrier.
2139 * \param rect a rectangle area in window-relative coordinates. If NULL the
2140 * barrier for the specified window will be destroyed.
2141 * \returns 0 on success or a negative error code on failure; call
2142 * SDL_GetError() for more information.
2143 *
2144 * \since This function is available since SDL 3.0.0.
2145 *
2146 * \sa SDL_GetWindowMouseRect
2147 * \sa SDL_SetWindowMouseGrab
2148 */
2149extern SDL_DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
2150
2151/**
2152 * Get the mouse confinement rectangle of a window.
2153 *
2154 * \param window the window to query.
2155 * \returns a pointer to the mouse confinement rectangle of a window, or NULL
2156 * if there isn't one.
2157 *
2158 * \since This function is available since SDL 3.0.0.
2159 *
2160 * \sa SDL_SetWindowMouseRect
2161 */
2162extern SDL_DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window *window);
2163
2164/**
2165 * Set the opacity for a window.
2166 *
2167 * The parameter `opacity` will be clamped internally between 0.0f
2168 * (transparent) and 1.0f (opaque).
2169 *
2170 * This function also returns -1 if setting the opacity isn't supported.
2171 *
2172 * \param window the window which will be made transparent or opaque.
2173 * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque).
2174 * \returns 0 on success or a negative error code on failure; call
2175 * SDL_GetError() for more information.
2176 *
2177 * \since This function is available since SDL 3.0.0.
2178 *
2179 * \sa SDL_GetWindowOpacity
2180 */
2181extern SDL_DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity);
2182
2183/**
2184 * Get the opacity of a window.
2185 *
2186 * If transparency isn't supported on this platform, opacity will be returned
2187 * as 1.0f without error.
2188 *
2189 * \param window the window to get the current opacity value from.
2190 * \returns the opacity, (0.0f - transparent, 1.0f - opaque), or a negative
2191 * error code on failure; call SDL_GetError() for more information.
2192 *
2193 * \since This function is available since SDL 3.0.0.
2194 *
2195 * \sa SDL_SetWindowOpacity
2196 */
2197extern SDL_DECLSPEC float SDLCALL SDL_GetWindowOpacity(SDL_Window *window);
2198
2199/**
2200 * Set the window as a modal to a parent window.
2201 *
2202 * If the window is already modal to an existing window, it will be reparented
2203 * to the new owner. Setting the parent window to null unparents the modal
2204 * window and removes modal status.
2205 *
2206 * Setting a window as modal to a parent that is a descendent of the modal
2207 * window results in undefined behavior.
2208 *
2209 * \param modal_window the window that should be set modal.
2210 * \param parent_window the parent window for the modal window.
2211 * \returns 0 on success or a negative error code on failure; call
2212 * SDL_GetError() for more information.
2213 *
2214 * \since This function is available since SDL 3.0.0.
2215 */
2216extern SDL_DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window);
2217
2218/**
2219 * Set whether the window may have input focus.
2220 *
2221 * \param window the window to set focusable state.
2222 * \param focusable SDL_TRUE to allow input focus, SDL_FALSE to not allow
2223 * input focus.
2224 * \returns 0 on success or a negative error code on failure; call
2225 * SDL_GetError() for more information.
2226 *
2227 * \since This function is available since SDL 3.0.0.
2228 */
2229extern SDL_DECLSPEC int SDLCALL SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable);
2230
2231
2232/**
2233 * Display the system-level window menu.
2234 *
2235 * This default window menu is provided by the system and on some platforms
2236 * provides functionality for setting or changing privileged state on the
2237 * window, such as moving it between workspaces or displays, or toggling the
2238 * always-on-top property.
2239 *
2240 * On platforms or desktops where this is unsupported, this function does
2241 * nothing.
2242 *
2243 * \param window the window for which the menu will be displayed.
2244 * \param x the x coordinate of the menu, relative to the origin (top-left) of
2245 * the client area.
2246 * \param y the y coordinate of the menu, relative to the origin (top-left) of
2247 * the client area.
2248 * \returns 0 on success or a negative error code on failure; call
2249 * SDL_GetError() for more information.
2250 *
2251 * \since This function is available since SDL 3.0.0.
2252 */
2253extern SDL_DECLSPEC int SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
2254
2255/**
2256 * Possible return values from the SDL_HitTest callback.
2257 *
2258 * \since This enum is available since SDL 3.0.0.
2259 *
2260 * \sa SDL_HitTest
2261 */
2263{
2264 SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */
2265 SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */
2266 SDL_HITTEST_RESIZE_TOPLEFT, /**< Region is the resizable top-left corner border. */
2267 SDL_HITTEST_RESIZE_TOP, /**< Region is the resizable top border. */
2268 SDL_HITTEST_RESIZE_TOPRIGHT, /**< Region is the resizable top-right corner border. */
2269 SDL_HITTEST_RESIZE_RIGHT, /**< Region is the resizable right border. */
2270 SDL_HITTEST_RESIZE_BOTTOMRIGHT, /**< Region is the resizable bottom-right corner border. */
2271 SDL_HITTEST_RESIZE_BOTTOM, /**< Region is the resizable bottom border. */
2272 SDL_HITTEST_RESIZE_BOTTOMLEFT, /**< Region is the resizable bottom-left corner border. */
2273 SDL_HITTEST_RESIZE_LEFT /**< Region is the resizable left border. */
2275
2276/**
2277 * Callback used for hit-testing.
2278 *
2279 * \param win the SDL_Window where hit-testing was set on.
2280 * \param area an SDL_Point which should be hit-tested.
2281 * \param data what was passed as `callback_data` to SDL_SetWindowHitTest().
2282 * \returns an SDL_HitTestResult value.
2283 *
2284 * \sa SDL_SetWindowHitTest
2285 */
2287 const SDL_Point *area,
2288 void *data);
2289
2290/**
2291 * Provide a callback that decides if a window region has special properties.
2292 *
2293 * Normally windows are dragged and resized by decorations provided by the
2294 * system window manager (a title bar, borders, etc), but for some apps, it
2295 * makes sense to drag them from somewhere else inside the window itself; for
2296 * example, one might have a borderless window that wants to be draggable from
2297 * any part, or simulate its own title bar, etc.
2298 *
2299 * This function lets the app provide a callback that designates pieces of a
2300 * given window as special. This callback is run during event processing if we
2301 * need to tell the OS to treat a region of the window specially; the use of
2302 * this callback is known as "hit testing."
2303 *
2304 * Mouse input may not be delivered to your application if it is within a
2305 * special area; the OS will often apply that input to moving the window or
2306 * resizing the window and not deliver it to the application.
2307 *
2308 * Specifying NULL for a callback disables hit-testing. Hit-testing is
2309 * disabled by default.
2310 *
2311 * Platforms that don't support this functionality will return -1
2312 * unconditionally, even if you're attempting to disable hit-testing.
2313 *
2314 * Your callback may fire at any time, and its firing does not indicate any
2315 * specific behavior (for example, on Windows, this certainly might fire when
2316 * the OS is deciding whether to drag your window, but it fires for lots of
2317 * other reasons, too, some unrelated to anything you probably care about _and
2318 * when the mouse isn't actually at the location it is testing_). Since this
2319 * can fire at any time, you should try to keep your callback efficient,
2320 * devoid of allocations, etc.
2321 *
2322 * \param window the window to set hit-testing on.
2323 * \param callback the function to call when doing a hit-test.
2324 * \param callback_data an app-defined void pointer passed to **callback**.
2325 * \returns 0 on success or a negative error code on failure; call
2326 * SDL_GetError() for more information.
2327 *
2328 * \since This function is available since SDL 3.0.0.
2329 */
2330extern SDL_DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
2331
2332/**
2333 * Set the shape of a transparent window.
2334 *
2335 * This sets the alpha channel of a transparent window and any fully
2336 * transparent areas are also transparent to mouse clicks. If you are using
2337 * something besides the SDL render API, then you are responsible for setting
2338 * the alpha channel of the window yourself.
2339 *
2340 * The shape is copied inside this function, so you can free it afterwards. If
2341 * your shape surface changes, you should call SDL_SetWindowShape() again to
2342 * update the window.
2343 *
2344 * The window must have been created with the SDL_WINDOW_TRANSPARENT flag.
2345 *
2346 * \param window the window.
2347 * \param shape the surface representing the shape of the window, or NULL to
2348 * remove any current shape.
2349 * \returns 0 on success or a negative error code on failure; call
2350 * SDL_GetError() for more information.
2351 *
2352 * \since This function is available since SDL 3.0.0.
2353 */
2354extern SDL_DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape);
2355
2356/**
2357 * Request a window to demand attention from the user.
2358 *
2359 * \param window the window to be flashed.
2360 * \param operation the operation to perform.
2361 * \returns 0 on success or a negative error code on failure; call
2362 * SDL_GetError() for more information.
2363 *
2364 * \since This function is available since SDL 3.0.0.
2365 */
2366extern SDL_DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
2367
2368/**
2369 * Destroy a window.
2370 *
2371 * Any popups or modal windows owned by the window will be recursively
2372 * destroyed as well.
2373 *
2374 * \param window the window to destroy.
2375 *
2376 * \since This function is available since SDL 3.0.0.
2377 *
2378 * \sa SDL_CreatePopupWindow
2379 * \sa SDL_CreateWindow
2380 * \sa SDL_CreateWindowWithProperties
2381 */
2382extern SDL_DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
2383
2384
2385/**
2386 * Check whether the screensaver is currently enabled.
2387 *
2388 * The screensaver is disabled by default.
2389 *
2390 * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`.
2391 *
2392 * \returns SDL_TRUE if the screensaver is enabled, SDL_FALSE if it is
2393 * disabled.
2394 *
2395 * \since This function is available since SDL 3.0.0.
2396 *
2397 * \sa SDL_DisableScreenSaver
2398 * \sa SDL_EnableScreenSaver
2399 */
2400extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ScreenSaverEnabled(void);
2401
2402/**
2403 * Allow the screen to be blanked by a screen saver.
2404 *
2405 * \returns 0 on success or a negative error code on failure; call
2406 * SDL_GetError() for more information.
2407 *
2408 * \since This function is available since SDL 3.0.0.
2409 *
2410 * \sa SDL_DisableScreenSaver
2411 * \sa SDL_ScreenSaverEnabled
2412 */
2413extern SDL_DECLSPEC int SDLCALL SDL_EnableScreenSaver(void);
2414
2415/**
2416 * Prevent the screen from being blanked by a screen saver.
2417 *
2418 * If you disable the screensaver, it is automatically re-enabled when SDL
2419 * quits.
2420 *
2421 * The screensaver is disabled by default, but this may by changed by
2422 * SDL_HINT_VIDEO_ALLOW_SCREENSAVER.
2423 *
2424 * \returns 0 on success or a negative error code on failure; call
2425 * SDL_GetError() for more information.
2426 *
2427 * \since This function is available since SDL 3.0.0.
2428 *
2429 * \sa SDL_EnableScreenSaver
2430 * \sa SDL_ScreenSaverEnabled
2431 */
2432extern SDL_DECLSPEC int SDLCALL SDL_DisableScreenSaver(void);
2433
2434
2435/**
2436 * \name OpenGL support functions
2437 */
2438/* @{ */
2439
2440/**
2441 * Dynamically load an OpenGL library.
2442 *
2443 * This should be done after initializing the video driver, but before
2444 * creating any OpenGL windows. If no OpenGL library is loaded, the default
2445 * library will be loaded upon creation of the first OpenGL window.
2446 *
2447 * If you do this, you need to retrieve all of the GL functions used in your
2448 * program from the dynamic library using SDL_GL_GetProcAddress().
2449 *
2450 * \param path the platform dependent OpenGL library name, or NULL to open the
2451 * default OpenGL library.
2452 * \returns 0 on success or a negative error code on failure; call
2453 * SDL_GetError() for more information.
2454 *
2455 * \since This function is available since SDL 3.0.0.
2456 *
2457 * \sa SDL_GL_GetProcAddress
2458 * \sa SDL_GL_UnloadLibrary
2459 */
2460extern SDL_DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
2461
2462/**
2463 * Get an OpenGL function by name.
2464 *
2465 * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all
2466 * GL functions must be retrieved this way. Usually this is used to retrieve
2467 * function pointers to OpenGL extensions.
2468 *
2469 * There are some quirks to looking up OpenGL functions that require some
2470 * extra care from the application. If you code carefully, you can handle
2471 * these quirks without any platform-specific code, though:
2472 *
2473 * - On Windows, function pointers are specific to the current GL context;
2474 * this means you need to have created a GL context and made it current
2475 * before calling SDL_GL_GetProcAddress(). If you recreate your context or
2476 * create a second context, you should assume that any existing function
2477 * pointers aren't valid to use with it. This is (currently) a
2478 * Windows-specific limitation, and in practice lots of drivers don't suffer
2479 * this limitation, but it is still the way the wgl API is documented to
2480 * work and you should expect crashes if you don't respect it. Store a copy
2481 * of the function pointers that comes and goes with context lifespan.
2482 * - On X11, function pointers returned by this function are valid for any
2483 * context, and can even be looked up before a context is created at all.
2484 * This means that, for at least some common OpenGL implementations, if you
2485 * look up a function that doesn't exist, you'll get a non-NULL result that
2486 * is _NOT_ safe to call. You must always make sure the function is actually
2487 * available for a given GL context before calling it, by checking for the
2488 * existence of the appropriate extension with SDL_GL_ExtensionSupported(),
2489 * or verifying that the version of OpenGL you're using offers the function
2490 * as core functionality.
2491 * - Some OpenGL drivers, on all platforms, *will* return NULL if a function
2492 * isn't supported, but you can't count on this behavior. Check for
2493 * extensions you use, and if you get a NULL anyway, act as if that
2494 * extension wasn't available. This is probably a bug in the driver, but you
2495 * can code defensively for this scenario anyhow.
2496 * - Just because you're on Linux/Unix, don't assume you'll be using X11.
2497 * Next-gen display servers are waiting to replace it, and may or may not
2498 * make the same promises about function pointers.
2499 * - OpenGL function pointers must be declared `APIENTRY` as in the example
2500 * code. This will ensure the proper calling convention is followed on
2501 * platforms where this matters (Win32) thereby avoiding stack corruption.
2502 *
2503 * \param proc the name of an OpenGL function.
2504 * \returns a pointer to the named OpenGL function. The returned pointer
2505 * should be cast to the appropriate function signature.
2506 *
2507 * \since This function is available since SDL 3.0.0.
2508 *
2509 * \sa SDL_GL_ExtensionSupported
2510 * \sa SDL_GL_LoadLibrary
2511 * \sa SDL_GL_UnloadLibrary
2512 */
2513extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc);
2514
2515/**
2516 * Get an EGL library function by name.
2517 *
2518 * If an EGL library is loaded, this function allows applications to get entry
2519 * points for EGL functions. This is useful to provide to an EGL API and
2520 * extension loader.
2521 *
2522 * \param proc the name of an EGL function.
2523 * \returns a pointer to the named EGL function. The returned pointer should
2524 * be cast to the appropriate function signature.
2525 *
2526 * \since This function is available since SDL 3.0.0.
2527 *
2528 * \sa SDL_EGL_GetCurrentDisplay
2529 */
2530extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
2531
2532/**
2533 * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
2534 *
2535 * \since This function is available since SDL 3.0.0.
2536 *
2537 * \sa SDL_GL_LoadLibrary
2538 */
2539extern SDL_DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
2540
2541/**
2542 * Check if an OpenGL extension is supported for the current context.
2543 *
2544 * This function operates on the current GL context; you must have created a
2545 * context and it must be current before calling this function. Do not assume
2546 * that all contexts you create will have the same set of extensions
2547 * available, or that recreating an existing context will offer the same
2548 * extensions again.
2549 *
2550 * While it's probably not a massive overhead, this function is not an O(1)
2551 * operation. Check the extensions you care about after creating the GL
2552 * context and save that information somewhere instead of calling the function
2553 * every time you need to know.
2554 *
2555 * \param extension the name of the extension to check.
2556 * \returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise.
2557 *
2558 * \since This function is available since SDL 3.0.0.
2559 */
2560extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension);
2561
2562/**
2563 * Reset all previously set OpenGL context attributes to their default values.
2564 *
2565 * \since This function is available since SDL 3.0.0.
2566 *
2567 * \sa SDL_GL_GetAttribute
2568 * \sa SDL_GL_SetAttribute
2569 */
2570extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
2571
2572/**
2573 * Set an OpenGL window attribute before window creation.
2574 *
2575 * This function sets the OpenGL attribute `attr` to `value`. The requested
2576 * attributes should be set before creating an OpenGL window. You should use
2577 * SDL_GL_GetAttribute() to check the values after creating the OpenGL
2578 * context, since the values obtained can differ from the requested ones.
2579 *
2580 * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to
2581 * set.
2582 * \param value the desired value for the attribute.
2583 * \returns 0 on success or a negative error code on failure; call
2584 * SDL_GetError() for more information.
2585 *
2586 * \since This function is available since SDL 3.0.0.
2587 *
2588 * \sa SDL_GL_GetAttribute
2589 * \sa SDL_GL_ResetAttributes
2590 */
2591extern SDL_DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
2592
2593/**
2594 * Get the actual value for an attribute from the current context.
2595 *
2596 * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to
2597 * get.
2598 * \param value a pointer filled in with the current value of `attr`.
2599 * \returns 0 on success or a negative error code on failure; call
2600 * SDL_GetError() for more information.
2601 *
2602 * \since This function is available since SDL 3.0.0.
2603 *
2604 * \sa SDL_GL_ResetAttributes
2605 * \sa SDL_GL_SetAttribute
2606 */
2607extern SDL_DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
2608
2609/**
2610 * Create an OpenGL context for an OpenGL window, and make it current.
2611 *
2612 * Windows users new to OpenGL should note that, for historical reasons, GL
2613 * functions added after OpenGL version 1.1 are not available by default.
2614 * Those functions must be loaded at run-time, either with an OpenGL
2615 * extension-handling library or with SDL_GL_GetProcAddress() and its related
2616 * functions.
2617 *
2618 * SDL_GLContext is opaque to the application.
2619 *
2620 * \param window the window to associate with the context.
2621 * \returns the OpenGL context associated with `window` or NULL on failure;
2622 * call SDL_GetError() for more information.
2623 *
2624 * \since This function is available since SDL 3.0.0.
2625 *
2626 * \sa SDL_GL_DestroyContext
2627 * \sa SDL_GL_MakeCurrent
2628 */
2629extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window);
2630
2631/**
2632 * Set up an OpenGL context for rendering into an OpenGL window.
2633 *
2634 * The context must have been created with a compatible window.
2635 *
2636 * \param window the window to associate with the context.
2637 * \param context the OpenGL context to associate with the window.
2638 * \returns 0 on success or a negative error code on failure; call
2639 * SDL_GetError() for more information.
2640 *
2641 * \since This function is available since SDL 3.0.0.
2642 *
2643 * \sa SDL_GL_CreateContext
2644 */
2645extern SDL_DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
2646
2647/**
2648 * Get the currently active OpenGL window.
2649 *
2650 * \returns the currently active OpenGL window on success or NULL on failure;
2651 * call SDL_GetError() for more information.
2652 *
2653 * \since This function is available since SDL 3.0.0.
2654 */
2655extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GL_GetCurrentWindow(void);
2656
2657/**
2658 * Get the currently active OpenGL context.
2659 *
2660 * \returns the currently active OpenGL context or NULL on failure; call
2661 * SDL_GetError() for more information.
2662 *
2663 * \since This function is available since SDL 3.0.0.
2664 *
2665 * \sa SDL_GL_MakeCurrent
2666 */
2667extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
2668
2669/**
2670 * Get the currently active EGL display.
2671 *
2672 * \returns the currently active EGL display or NULL on failure; call
2673 * SDL_GetError() for more information.
2674 *
2675 * \since This function is available since SDL 3.0.0.
2676 */
2677extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentDisplay(void);
2678
2679/**
2680 * Get the currently active EGL config.
2681 *
2682 * \returns the currently active EGL config or NULL on failure; call
2683 * SDL_GetError() for more information.
2684 *
2685 * \since This function is available since SDL 3.0.0.
2686 */
2687extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentConfig(void);
2688
2689/**
2690 * Get the EGL surface associated with the window.
2691 *
2692 * \param window the window to query.
2693 * \returns the EGLSurface pointer associated with the window, or NULL on
2694 * failure.
2695 *
2696 * \since This function is available since SDL 3.0.0.
2697 */
2698extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowSurface(SDL_Window *window);
2699
2700/**
2701 * Sets the callbacks for defining custom EGLAttrib arrays for EGL
2702 * initialization.
2703 *
2704 * Each callback should return a pointer to an EGL attribute array terminated
2705 * with EGL_NONE. Callbacks may return NULL pointers to signal an error, which
2706 * will cause the SDL_CreateWindow process to fail gracefully.
2707 *
2708 * The arrays returned by each callback will be appended to the existing
2709 * attribute arrays defined by SDL.
2710 *
2711 * NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes.
2712 *
2713 * \param platformAttribCallback callback for attributes to pass to
2714 * eglGetPlatformDisplay.
2715 * \param surfaceAttribCallback callback for attributes to pass to
2716 * eglCreateSurface.
2717 * \param contextAttribCallback callback for attributes to pass to
2718 * eglCreateContext.
2719 *
2720 * \since This function is available since SDL 3.0.0.
2721 */
2722extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback,
2723 SDL_EGLIntArrayCallback surfaceAttribCallback,
2724 SDL_EGLIntArrayCallback contextAttribCallback);
2725
2726/**
2727 * Set the swap interval for the current OpenGL context.
2728 *
2729 * Some systems allow specifying -1 for the interval, to enable adaptive
2730 * vsync. Adaptive vsync works the same as vsync, but if you've already missed
2731 * the vertical retrace for a given frame, it swaps buffers immediately, which
2732 * might be less jarring for the user during occasional framerate drops. If an
2733 * application requests adaptive vsync and the system does not support it,
2734 * this function will fail and return -1. In such a case, you should probably
2735 * retry the call with 1 for the interval.
2736 *
2737 * Adaptive vsync is implemented for some glX drivers with
2738 * GLX_EXT_swap_control_tear, and for some Windows drivers with
2739 * WGL_EXT_swap_control_tear.
2740 *
2741 * Read more on the Khronos wiki:
2742 * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
2743 *
2744 * \param interval 0 for immediate updates, 1 for updates synchronized with
2745 * the vertical retrace, -1 for adaptive vsync.
2746 * \returns 0 on success or a negative error code on failure; call
2747 * SDL_GetError() for more information.
2748 *
2749 * \since This function is available since SDL 3.0.0.
2750 *
2751 * \sa SDL_GL_GetSwapInterval
2752 */
2753extern SDL_DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
2754
2755/**
2756 * Get the swap interval for the current OpenGL context.
2757 *
2758 * If the system can't determine the swap interval, or there isn't a valid
2759 * current context, this function will set *interval to 0 as a safe default.
2760 *
2761 * \param interval output interval value. 0 if there is no vertical retrace
2762 * synchronization, 1 if the buffer swap is synchronized with
2763 * the vertical retrace, and -1 if late swaps happen
2764 * immediately instead of waiting for the next retrace.
2765 * \returns 0 on success or a negative error code on failure; call
2766 * SDL_GetError() for more information.
2767 *
2768 * \since This function is available since SDL 3.0.0.
2769 *
2770 * \sa SDL_GL_SetSwapInterval
2771 */
2772extern SDL_DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(int *interval);
2773
2774/**
2775 * Update a window with OpenGL rendering.
2776 *
2777 * This is used with double-buffered OpenGL contexts, which are the default.
2778 *
2779 * On macOS, make sure you bind 0 to the draw framebuffer before swapping the
2780 * window, otherwise nothing will happen. If you aren't using
2781 * glBindFramebuffer(), this is the default and you won't have to do anything
2782 * extra.
2783 *
2784 * \param window the window to change.
2785 * \returns 0 on success or a negative error code on failure; call
2786 * SDL_GetError() for more information.
2787 *
2788 * \since This function is available since SDL 3.0.0.
2789 */
2790extern SDL_DECLSPEC int SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
2791
2792/**
2793 * Delete an OpenGL context.
2794 *
2795 * \param context the OpenGL context to be deleted.
2796 * \returns 0 on success or a negative error code on failure; call
2797 * SDL_GetError() for more information.
2798 *
2799 * \since This function is available since SDL 3.0.0.
2800 *
2801 * \sa SDL_GL_CreateContext
2802 */
2803extern SDL_DECLSPEC int SDLCALL SDL_GL_DestroyContext(SDL_GLContext context);
2804
2805/* @} *//* OpenGL support functions */
2806
2807
2808/* Ends C function definitions when using C++ */
2809#ifdef __cplusplus
2810}
2811#endif
2812#include <SDL3/SDL_close_code.h>
2813
2814#endif /* SDL_video_h_ */
SDL_PixelFormat
Definition SDL_pixels.h:227
Uint32 SDL_PropertiesID
SDL_MALLOC size_t size
Definition SDL_stdinc.h:531
int SDL_bool
Definition SDL_stdinc.h:213
uint64_t Uint64
Definition SDL_stdinc.h:287
void(* SDL_FunctionPointer)(void)
uint32_t Uint32
Definition SDL_stdinc.h:265
SDL_SystemTheme
Definition SDL_video.h:71
@ SDL_SYSTEM_THEME_LIGHT
Definition SDL_video.h:73
@ SDL_SYSTEM_THEME_UNKNOWN
Definition SDL_video.h:72
@ SDL_SYSTEM_THEME_DARK
Definition SDL_video.h:74
int SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed)
struct SDL_GLContextState * SDL_GLContext
Definition SDL_video.h:210
SDL_HitTestResult
Definition SDL_video.h:2263
@ SDL_HITTEST_DRAGGABLE
Definition SDL_video.h:2265
@ SDL_HITTEST_RESIZE_LEFT
Definition SDL_video.h:2273
@ SDL_HITTEST_RESIZE_TOP
Definition SDL_video.h:2267
@ SDL_HITTEST_RESIZE_TOPRIGHT
Definition SDL_video.h:2268
@ SDL_HITTEST_NORMAL
Definition SDL_video.h:2264
@ SDL_HITTEST_RESIZE_BOTTOM
Definition SDL_video.h:2271
@ SDL_HITTEST_RESIZE_BOTTOMRIGHT
Definition SDL_video.h:2270
@ SDL_HITTEST_RESIZE_BOTTOMLEFT
Definition SDL_video.h:2272
@ SDL_HITTEST_RESIZE_RIGHT
Definition SDL_video.h:2269
@ SDL_HITTEST_RESIZE_TOPLEFT
Definition SDL_video.h:2266
SDL_DisplayID SDL_GetDisplayForPoint(const SDL_Point *point)
int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window)
int SDL_UpdateWindowSurface(SDL_Window *window)
SDL_EGLAttrib *(* SDL_EGLAttribArrayCallback)(void)
Definition SDL_video.h:228
int SDL_RaiseWindow(SDL_Window *window)
SDL_bool SDL_ScreenSaverEnabled(void)
int SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync)
SDL_Surface * SDL_GetWindowSurface(SDL_Window *window)
const char * SDL_GetDisplayName(SDL_DisplayID displayID)
SDL_bool SDL_GL_ExtensionSupported(const char *extension)
int SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect)
int SDL_ShowWindow(SDL_Window *window)
int SDL_GL_SetSwapInterval(int interval)
SDL_WindowFlags SDL_GetWindowFlags(SDL_Window *window)
SDL_bool SDL_WindowHasSurface(SDL_Window *window)
struct SDL_DisplayModeData SDL_DisplayModeData
Definition SDL_video.h:78
void * SDL_EGLDisplay
Definition SDL_video.h:217
int SDL_GL_GetSwapInterval(int *interval)
const char * SDL_GetWindowTitle(SDL_Window *window)
int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape)
SDL_HitTestResult(* SDL_HitTest)(SDL_Window *win, const SDL_Point *area, void *data)
Definition SDL_video.h:2286
SDL_GLattr
Definition SDL_video.h:249
@ SDL_GL_EGL_PLATFORM
Definition SDL_video.h:277
@ SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
Definition SDL_video.h:272
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR
Definition SDL_video.h:273
@ SDL_GL_DOUBLEBUFFER
Definition SDL_video.h:255
@ SDL_GL_STENCIL_SIZE
Definition SDL_video.h:257
@ SDL_GL_CONTEXT_MAJOR_VERSION
Definition SDL_video.h:267
@ SDL_GL_CONTEXT_RESET_NOTIFICATION
Definition SDL_video.h:274
@ SDL_GL_ACCUM_ALPHA_SIZE
Definition SDL_video.h:261
@ SDL_GL_MULTISAMPLESAMPLES
Definition SDL_video.h:264
@ SDL_GL_CONTEXT_MINOR_VERSION
Definition SDL_video.h:268
@ SDL_GL_FLOATBUFFERS
Definition SDL_video.h:276
@ SDL_GL_STEREO
Definition SDL_video.h:262
@ SDL_GL_MULTISAMPLEBUFFERS
Definition SDL_video.h:263
@ SDL_GL_ACCUM_GREEN_SIZE
Definition SDL_video.h:259
@ SDL_GL_BLUE_SIZE
Definition SDL_video.h:252
@ SDL_GL_SHARE_WITH_CURRENT_CONTEXT
Definition SDL_video.h:271
@ SDL_GL_RETAINED_BACKING
Definition SDL_video.h:266
@ SDL_GL_RED_SIZE
Definition SDL_video.h:250
@ SDL_GL_ALPHA_SIZE
Definition SDL_video.h:253
@ SDL_GL_BUFFER_SIZE
Definition SDL_video.h:254
@ SDL_GL_ACCELERATED_VISUAL
Definition SDL_video.h:265
@ SDL_GL_ACCUM_BLUE_SIZE
Definition SDL_video.h:260
@ SDL_GL_DEPTH_SIZE
Definition SDL_video.h:256
@ SDL_GL_ACCUM_RED_SIZE
Definition SDL_video.h:258
@ SDL_GL_CONTEXT_FLAGS
Definition SDL_video.h:269
@ SDL_GL_CONTEXT_PROFILE_MASK
Definition SDL_video.h:270
@ SDL_GL_CONTEXT_NO_ERROR
Definition SDL_video.h:275
@ SDL_GL_GREEN_SIZE
Definition SDL_video.h:251
SDL_PixelFormat SDL_GetWindowPixelFormat(SDL_Window *window)
void SDL_GL_ResetAttributes(void)
SDL_FlashOperation
Definition SDL_video.h:197
@ SDL_FLASH_UNTIL_FOCUSED
Definition SDL_video.h:200
@ SDL_FLASH_BRIEFLY
Definition SDL_video.h:199
@ SDL_FLASH_CANCEL
Definition SDL_video.h:198
SDL_EGLint *(* SDL_EGLIntArrayCallback)(void)
Definition SDL_video.h:229
void * SDL_GetWindowICCProfile(SDL_Window *window, size_t *size)
int SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation)
Uint32 SDL_DisplayID
Definition SDL_video.h:45
float SDL_GetWindowOpacity(SDL_Window *window)
int SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable)
int SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h)
SDL_PropertiesID SDL_GetWindowProperties(SDL_Window *window)
SDL_DisplayID SDL_GetDisplayForRect(const SDL_Rect *rect)
intptr_t SDL_EGLAttrib
Definition SDL_video.h:220
SDL_DisplayMode ** SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count)
int SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed)
int SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right)
const SDL_Rect * SDL_GetWindowMouseRect(SDL_Window *window)
float SDL_GetWindowDisplayScale(SDL_Window *window)
int SDL_DisableScreenSaver(void)
SDL_bool SDL_GetWindowKeyboardGrab(SDL_Window *window)
int SDL_RestoreWindow(SDL_Window *window)
int SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects)
SDL_DisplayID * SDL_GetDisplays(int *count)
SDL_Window * SDL_GetWindowFromID(SDL_WindowID id)
int SDL_SetWindowTitle(SDL_Window *window, const char *title)
int SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered)
struct SDL_Window SDL_Window
Definition SDL_video.h:127
SDL_WindowID SDL_GetWindowID(SDL_Window *window)
SDL_DisplayID SDL_GetPrimaryDisplay(void)
int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect)
SDL_Window ** SDL_GetWindows(int *count)
SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
const char * SDL_GetCurrentVideoDriver(void)
int SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync)
void * SDL_EGLConfig
Definition SDL_video.h:218
float SDL_GetWindowPixelDensity(SDL_Window *window)
int SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top)
int SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon)
int SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h)
int SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect)
const SDL_DisplayMode * SDL_GetDesktopDisplayMode(SDL_DisplayID displayID)
Uint32 SDL_WindowID
Definition SDL_video.h:46
int SDL_GetWindowPosition(SDL_Window *window, int *x, int *y)
int SDL_MinimizeWindow(SDL_Window *window)
SDL_EGLConfig SDL_EGL_GetCurrentConfig(void)
SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
int SDL_EGLint
Definition SDL_video.h:221
void SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback, SDL_EGLIntArrayCallback surfaceAttribCallback, SDL_EGLIntArrayCallback contextAttribCallback)
SDL_FunctionPointer SDL_EGL_GetProcAddress(const char *proc)
SDL_FunctionPointer SDL_GL_GetProcAddress(const char *proc)
int SDL_SetWindowSize(SDL_Window *window, int w, int h)
SDL_EGLDisplay SDL_EGL_GetCurrentDisplay(void)
int SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, SDL_bool include_high_density_modes, SDL_DisplayMode *mode)
SDL_Window * SDL_CreateWindow(const char *title, int w, int h, SDL_WindowFlags flags)
Uint64 SDL_WindowFlags
Definition SDL_video.h:141
SDL_GLContext SDL_GL_GetCurrentContext(void)
SDL_Window * SDL_GetGrabbedWindow(void)
void SDL_GL_UnloadLibrary(void)
int SDL_HideWindow(SDL_Window *window)
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
int SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect)
int SDL_SetWindowOpacity(SDL_Window *window, float opacity)
SDL_GLcontextReleaseFlag
Definition SDL_video.h:312
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE
Definition SDL_video.h:313
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH
Definition SDL_video.h:314
int SDL_GetNumVideoDrivers(void)
float SDL_GetDisplayContentScale(SDL_DisplayID displayID)
SDL_Window * SDL_GL_GetCurrentWindow(void)
int SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect)
SDL_Window * SDL_CreateWindowWithProperties(SDL_PropertiesID props)
int SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y)
int SDL_MaximizeWindow(SDL_Window *window)
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context)
int SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h)
int SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode)
SDL_DisplayOrientation SDL_GetNaturalDisplayOrientation(SDL_DisplayID displayID)
const char * SDL_GetVideoDriver(int index)
SDL_bool SDL_GetWindowMouseGrab(SDL_Window *window)
int SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h)
int SDL_GL_DestroyContext(SDL_GLContext context)
void * SDL_EGLSurface
Definition SDL_video.h:219
SDL_GLcontextFlag
Definition SDL_video.h:298
@ SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG
Definition SDL_video.h:300
@ SDL_GL_CONTEXT_RESET_ISOLATION_FLAG
Definition SDL_video.h:302
@ SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG
Definition SDL_video.h:301
@ SDL_GL_CONTEXT_DEBUG_FLAG
Definition SDL_video.h:299
SDL_DisplayOrientation SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID)
int SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data)
void SDL_DestroyWindow(SDL_Window *window)
SDL_EGLSurface SDL_EGL_GetWindowSurface(SDL_Window *window)
int SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable)
int SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h)
int SDL_DestroyWindowSurface(SDL_Window *window)
int SDL_EnableScreenSaver(void)
const SDL_DisplayMode * SDL_GetWindowFullscreenMode(SDL_Window *window)
const SDL_DisplayMode * SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
SDL_Window * SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags)
int SDL_GL_SwapWindow(SDL_Window *window)
int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
SDL_SystemTheme SDL_GetSystemTheme(void)
int SDL_SetWindowPosition(SDL_Window *window, int x, int y)
SDL_GLprofile
Definition SDL_video.h:286
@ SDL_GL_CONTEXT_PROFILE_COMPATIBILITY
Definition SDL_video.h:288
@ SDL_GL_CONTEXT_PROFILE_ES
Definition SDL_video.h:289
@ SDL_GL_CONTEXT_PROFILE_CORE
Definition SDL_video.h:287
int SDL_SyncWindow(SDL_Window *window)
int SDL_GL_LoadLibrary(const char *path)
int SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen)
int SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
SDL_Window * SDL_GetWindowParent(SDL_Window *window)
int SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect)
SDL_DisplayOrientation
Definition SDL_video.h:112
@ SDL_ORIENTATION_LANDSCAPE
Definition SDL_video.h:114
@ SDL_ORIENTATION_PORTRAIT
Definition SDL_video.h:116
@ SDL_ORIENTATION_PORTRAIT_FLIPPED
Definition SDL_video.h:117
@ SDL_ORIENTATION_LANDSCAPE_FLIPPED
Definition SDL_video.h:115
@ SDL_ORIENTATION_UNKNOWN
Definition SDL_video.h:113
SDL_GLContextResetNotification
Definition SDL_video.h:323
@ SDL_GL_CONTEXT_RESET_NO_NOTIFICATION
Definition SDL_video.h:324
@ SDL_GL_CONTEXT_RESET_LOSE_CONTEXT
Definition SDL_video.h:325
SDL_PropertiesID SDL_GetDisplayProperties(SDL_DisplayID displayID)
int refresh_rate_numerator
Definition SDL_video.h:99
int refresh_rate_denominator
Definition SDL_video.h:100
SDL_DisplayModeData * internal
Definition SDL_video.h:102
SDL_PixelFormat format
Definition SDL_video.h:94
float pixel_density
Definition SDL_video.h:97
SDL_DisplayID displayID
Definition SDL_video.h:93
float refresh_rate
Definition SDL_video.h:98