SDL 3.0
SDL_video.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2023 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 * \file SDL_video.h
24 *
25 * Header file for 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_pixels.h>
33#include <SDL3/SDL_rect.h>
34#include <SDL3/SDL_surface.h>
35
36#include <SDL3/SDL_begin_code.h>
37/* Set up for C function definitions, even when using C++ */
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42
45
46/**
47 * \brief The structure that defines a display mode
48 *
49 * \sa SDL_GetFullscreenDisplayModes()
50 * \sa SDL_GetDesktopDisplayMode()
51 * \sa SDL_GetCurrentDisplayMode()
52 * \sa SDL_SetWindowFullscreenMode()
53 * \sa SDL_GetWindowFullscreenMode()
54 */
55typedef struct
56{
57 SDL_DisplayID displayID; /**< the display this mode is associated with */
58 Uint32 format; /**< pixel format */
59 int pixel_w; /**< width in pixels (used for creating back buffers) */
60 int pixel_h; /**< height in pixels (used for creating back buffers) */
61 int screen_w; /**< width in screen coordinates (used for creating windows) */
62 int screen_h; /**< height in screen coordinates (used for creating windows) */
63 float display_scale; /**< scale converting screen coordinates to pixels (e.g. a 2560x1440 screen size mode with 1.5 scale would have 3840x2160 pixels) */
64 float refresh_rate; /**< refresh rate (or zero for unspecified) */
65 void *driverdata; /**< driver-specific data, initialize to 0 */
67
68/**
69 * \brief The type used to identify a window
70 *
71 * \sa SDL_CreateWindow()
72 * \sa SDL_CreateWindowFrom()
73 * \sa SDL_DestroyWindow()
74 * \sa SDL_FlashWindow()
75 * \sa SDL_GetWindowData()
76 * \sa SDL_GetWindowFlags()
77 * \sa SDL_GetWindowGrab()
78 * \sa SDL_GetWindowKeyboardGrab()
79 * \sa SDL_GetWindowMouseGrab()
80 * \sa SDL_GetWindowPosition()
81 * \sa SDL_GetWindowSize()
82 * \sa SDL_GetWindowTitle()
83 * \sa SDL_HideWindow()
84 * \sa SDL_MaximizeWindow()
85 * \sa SDL_MinimizeWindow()
86 * \sa SDL_RaiseWindow()
87 * \sa SDL_RestoreWindow()
88 * \sa SDL_SetWindowData()
89 * \sa SDL_SetWindowFullscreen()
90 * \sa SDL_SetWindowGrab()
91 * \sa SDL_SetWindowKeyboardGrab()
92 * \sa SDL_SetWindowMouseGrab()
93 * \sa SDL_SetWindowIcon()
94 * \sa SDL_SetWindowPosition()
95 * \sa SDL_SetWindowSize()
96 * \sa SDL_SetWindowBordered()
97 * \sa SDL_SetWindowResizable()
98 * \sa SDL_SetWindowTitle()
99 * \sa SDL_ShowWindow()
100 */
101typedef struct SDL_Window SDL_Window;
102
103/**
104 * \brief The flags on a window
105 *
106 * \sa SDL_GetWindowFlags()
107 */
108typedef enum
109{
110 SDL_WINDOW_FULLSCREEN = 0x00000001, /**< window is in fullscreen mode */
111 SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
112 /* 0x00000004 was SDL_WINDOW_SHOWN in SDL2, please reserve this bit for sdl2-compat. */
113 SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
114 SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
115 SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
116 SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */
117 SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */
118 SDL_WINDOW_MOUSE_GRABBED = 0x00000100, /**< window has grabbed mouse input */
119 SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
120 SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
121 /* 0x00001000 was SDL_WINDOW_FULLSCREEN_DESKTOP in SDL2, please reserve this bit for sdl2-compat. */
122 SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
123 /* 0x00002000 was SDL_WINDOW_ALLOW_HIGHDPI in SDL2, please reserve this bit for sdl2-compat. */
124 SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
125 SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */
126 SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */
127 SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */
128 SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */
129 SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */
130 SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000, /**< window has grabbed keyboard input */
131 SDL_WINDOW_VULKAN = 0x10000000, /**< window usable for Vulkan surface */
132 SDL_WINDOW_METAL = 0x20000000, /**< window usable for Metal view */
133
135
136/**
137 * \brief Used to indicate that you don't care what the window position is.
138 */
139#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
140#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
141#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
142#define SDL_WINDOWPOS_ISUNDEFINED(X) \
143 (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
144
145/**
146 * \brief Used to indicate that the window position should be centered.
147 */
148#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
149#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
150#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
151#define SDL_WINDOWPOS_ISCENTERED(X) \
152 (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
153
154/**
155 * \brief Display orientation
156 */
157typedef enum
158{
159 SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */
160 SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */
161 SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */
162 SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */
163 SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */
165
166/**
167 * \brief Window flash operation
168 */
169typedef enum
170{
171 SDL_FLASH_CANCEL, /**< Cancel any window flash state */
172 SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */
173 SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */
175
176/**
177 * \brief An opaque handle to an OpenGL context.
178 */
179typedef void *SDL_GLContext;
180
181/**
182 * \brief Opaque EGL types.
183 */
184typedef void *SDL_EGLDisplay;
185typedef void *SDL_EGLConfig;
186typedef void *SDL_EGLSurface;
187typedef intptr_t SDL_EGLAttrib;
188typedef int SDL_EGLint;
189
190/**
191 * \brief EGL attribute initialization callback types.
192 */
194typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void);
195
196/**
197 * \brief OpenGL configuration attributes
198 */
199typedef enum
200{
230
231typedef enum
232{
235 SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
237
238typedef enum
239{
245
246typedef enum
247{
251
252typedef enum
253{
257
258/* Function prototypes */
259
260/**
261 * Get the number of video drivers compiled into SDL.
262 *
263 * \returns a number >= 1 on success or a negative error code on failure; call
264 * SDL_GetError() for more information.
265 *
266 * \since This function is available since SDL 3.0.0.
267 *
268 * \sa SDL_GetVideoDriver
269 */
270extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
271
272/**
273 * Get the name of a built in video driver.
274 *
275 * The video drivers are presented in the order in which they are normally
276 * checked during initialization.
277 *
278 * \param index the index of a video driver
279 * \returns the name of the video driver with the given **index**.
280 *
281 * \since This function is available since SDL 3.0.0.
282 *
283 * \sa SDL_GetNumVideoDrivers
284 */
285extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
286
287/**
288 * Get the name of the currently initialized video driver.
289 *
290 * \returns the name of the current video driver or NULL if no driver has been
291 * initialized.
292 *
293 * \since This function is available since SDL 3.0.0.
294 *
295 * \sa SDL_GetNumVideoDrivers
296 * \sa SDL_GetVideoDriver
297 */
298extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
299
300/**
301 * Get a list of currently connected displays.
302 *
303 * \param count a pointer filled in with the number of displays returned
304 * \returns a 0 terminated array of display instance IDs which should be freed
305 * with SDL_free(), or NULL on error; call SDL_GetError() for more
306 * details.
307 *
308 * \since This function is available since SDL 3.0.0.
309 */
310extern DECLSPEC SDL_DisplayID *SDLCALL SDL_GetDisplays(int *count);
311
312/**
313 * Return the primary display.
314 *
315 * \returns the instance ID of the primary display on success or 0 on failure;
316 * call SDL_GetError() for more information.
317 *
318 * \since This function is available since SDL 3.0.0.
319 *
320 * \sa SDL_GetDisplays
321 */
322extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
323
324/**
325 * Get the name of a display in UTF-8 encoding.
326 *
327 * \param displayID the instance ID of the display to query
328 * \returns the name of a display or NULL on failure; call SDL_GetError() for
329 * more information.
330 *
331 * \since This function is available since SDL 3.0.0.
332 *
333 * \sa SDL_GetDisplays
334 */
335extern DECLSPEC const char *SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
336
337/**
338 * Get the desktop area represented by a display, in screen coordinates.
339 *
340 * The primary display is always located at (0,0).
341 *
342 * \param displayID the instance ID of the display to query
343 * \param rect the SDL_Rect structure filled in with the display bounds
344 * \returns 0 on success or a negative error code on failure; call
345 * SDL_GetError() for more information.
346 *
347 * \since This function is available since SDL 3.0.0.
348 *
349 * \sa SDL_GetDisplayUsableBounds
350 * \sa SDL_GetDisplays
351 */
352extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
353
354/**
355 * Get the usable desktop area represented by a display, in screen
356 * coordinates.
357 *
358 * This is the same area as SDL_GetDisplayBounds() reports, but with portions
359 * reserved by the system removed. For example, on Apple's macOS, this
360 * subtracts the area occupied by the menu bar and dock.
361 *
362 * Setting a window to be fullscreen generally bypasses these unusable areas,
363 * so these are good guidelines for the maximum space available to a
364 * non-fullscreen window.
365 *
366 * \param displayID the instance ID of the display to query
367 * \param rect the SDL_Rect structure filled in with the display bounds
368 * \returns 0 on success or a negative error code on failure; call
369 * SDL_GetError() for more information.
370 *
371 * \since This function is available since SDL 3.0.0.
372 *
373 * \sa SDL_GetDisplayBounds
374 * \sa SDL_GetDisplays
375 */
376extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
377
378/**
379 * Get the dots/pixels-per-inch for a display.
380 *
381 * Diagonal, horizontal and vertical DPI can all be optionally returned if the
382 * appropriate parameter is non-NULL.
383 *
384 * **WARNING**: This reports the DPI that the hardware reports, and it is not
385 * always reliable! It is almost always better to use SDL_GetWindowSize() to
386 * find the window size, which might be in logical points instead of pixels,
387 * and then SDL_GetWindowSizeInPixels() or SDL_GetRendererOutputSize(), and
388 * compare the two values to get an actual scaling value between the two. We
389 * will be rethinking how high-dpi details should be managed in SDL3 to make
390 * things more consistent, reliable, and clear.
391 *
392 * \param displayID the instance ID of the display to query
393 * \param ddpi a pointer filled in with the diagonal DPI of the display; may
394 * be NULL
395 * \param hdpi a pointer filled in with the horizontal DPI of the display; may
396 * be NULL
397 * \param vdpi a pointer filled in with the vertical DPI of the display; may
398 * be NULL
399 * \returns 0 on success or a negative error code on failure; call
400 * SDL_GetError() for more information.
401 *
402 * \since This function is available since SDL 3.0.0.
403 *
404 * \sa SDL_GetDisplays
405 */
406extern DECLSPEC int SDLCALL SDL_GetDisplayPhysicalDPI(SDL_DisplayID displayID, float *ddpi, float *hdpi, float *vdpi);
407
408/**
409 * Get the orientation of a display.
410 *
411 * \param displayID the instance ID of the display to query
412 * \returns The SDL_DisplayOrientation enum value of the display, or
413 * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
414 *
415 * \since This function is available since SDL 3.0.0.
416 *
417 * \sa SDL_GetDisplays
418 */
420
421/**
422 * Get a list of fullscreen display modes available on a display.
423 *
424 * The display modes are sorted in this priority:
425 * - screen_w -> largest to smallest
426 * - screen_h -> largest to smallest
427 * - pixel_w -> largest to smallest
428 * - pixel_h -> largest to smallest
429 * - bits per pixel -> more colors to fewer colors
430 * - packed pixel layout -> largest to smallest
431 * - refresh rate -> highest to lowest
432 *
433 * \param displayID the instance ID of the display to query
434 * \param count a pointer filled in with the number of displays returned
435 * \returns a NULL terminated array of display mode pointers which should be freed
436 * with SDL_free(), or NULL on error; call SDL_GetError() for more
437 * details.
438 *
439 * \since This function is available since SDL 3.0.0.
440 *
441 * \sa SDL_GetDisplays
442 */
443extern DECLSPEC const SDL_DisplayMode **SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count);
444
445/**
446 * Get the closest match to the requested display mode.
447 *
448 * The available display modes are scanned and `closest` is filled in with the
449 * closest mode matching the requested mode and returned. The mode format and
450 * refresh rate default to the desktop mode if they are set to 0. The modes
451 * are scanned with size being first priority, format being second priority,
452 * and finally checking the refresh rate. If all the available modes are too
453 * small, then NULL is returned.
454 *
455 * \param displayID the instance ID of the display to query
456 * \param w the width in pixels of the desired display mode
457 * \param h the height in pixels of the desired display mode
458 * \param refresh_rate the refresh rate of the desired display mode, or 0.0f for the desktop refresh rate
459 * \returns a pointer to the closest display mode equal to or larger than the desired mode, or NULL on error; call SDL_GetError() for more information.
460 * \returns the passed in value `closest` or NULL if no matching video mode
461 * was available; call SDL_GetError() for more information.
462 *
463 * \since This function is available since SDL 3.0.0.
464 *
465 * \sa SDL_GetDisplays
466 * \sa SDL_GetFullscreenDisplayModes
467 */
468extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate);
469
470/**
471 * Get information about the desktop's display mode.
472 *
473 * There's a difference between this function and SDL_GetCurrentDisplayMode()
474 * when SDL runs fullscreen and has changed the resolution. In that case this
475 * function will return the previous native display mode, and not the current
476 * display mode.
477 *
478 * \param displayID the instance ID of the display to query
479 * \returns a pointer to the desktop display mode or NULL on error; call
480 * SDL_GetError() for more information.
481 *
482 * \since This function is available since SDL 3.0.0.
483 *
484 * \sa SDL_GetCurrentDisplayMode
485 * \sa SDL_GetDisplays
486 */
487extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID);
488
489/**
490 * Get information about the current display mode.
491 *
492 * There's a difference between this function and SDL_GetDesktopDisplayMode()
493 * when SDL runs fullscreen and has changed the resolution. In that case this
494 * function will return the current display mode, and not the previous native
495 * display mode.
496 *
497 * \param displayID the instance ID of the display to query
498 * \returns a pointer to the desktop display mode or NULL on error; call
499 * SDL_GetError() for more information.
500 *
501 * \since This function is available since SDL 3.0.0.
502 *
503 * \sa SDL_GetDesktopDisplayMode
504 * \sa SDL_GetDisplays
505 */
506extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID);
507
508/**
509 * Get the display containing a point
510 *
511 * \param point the point to query
512 * \returns the instance ID of the display containing the point or 0 on
513 * failure; call SDL_GetError() for more information.
514 *
515 * \since This function is available since SDL 3.0.0.
516 *
517 * \sa SDL_GetDisplayBounds
518 * \sa SDL_GetDisplays
519 */
520extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
521
522/**
523 * Get the display primarily containing a rect
524 *
525 * \param rect the rect to query
526 * \returns the instance ID of the display entirely containing the rect or
527 * closest to the center of the rect on success or 0 on failure; call
528 * SDL_GetError() for more information.
529 *
530 * \since This function is available since SDL 3.0.0.
531 *
532 * \sa SDL_GetDisplayBounds
533 * \sa SDL_GetDisplays
534 */
535extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
536
537/**
538 * Get the display associated with a window.
539 *
540 * \param window the window to query
541 * \returns the instance ID of the display containing the center of the window
542 * on success or 0 on failure; call SDL_GetError() for more
543 * information.
544 *
545 * \since This function is available since SDL 3.0.0.
546 *
547 * \sa SDL_GetDisplayBounds
548 * \sa SDL_GetDisplays
549 */
550extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
551
552/**
553 * Set the display mode to use when a window is visible and fullscreen.
554 *
555 * This only affects the display mode used when the window is fullscreen. To
556 * change the window size when the window is not fullscreen, use
557 * SDL_SetWindowSize().
558 *
559 * \param window the window to affect
560 * \param mode a pointer to the display mode to use, which can be NULL for desktop mode, or one of the fullscreen modes returned by SDL_GetFullscreenDisplayModes().
561 * \returns 0 on success or a negative error code on failure; call
562 * SDL_GetError() for more information.
563 *
564 * \since This function is available since SDL 3.0.0.
565 *
566 * \sa SDL_GetWindowFullscreenMode
567 * \sa SDL_SetWindowFullscreen
568 */
569extern DECLSPEC int SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode);
570
571/**
572 * Query the display mode to use when a window is visible at fullscreen.
573 *
574 * \param window the window to query
575 * \returns a pointer to the fullscreen mode to use or NULL for desktop mode
576 *
577 * \since This function is available since SDL 3.0.0.
578 *
579 * \sa SDL_SetWindowFullscreenMode
580 * \sa SDL_SetWindowFullscreen
581 */
582extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetWindowFullscreenMode(SDL_Window *window);
583
584/**
585 * Get the raw ICC profile data for the screen the window is currently on.
586 *
587 * Data returned should be freed with SDL_free.
588 *
589 * \param window the window to query
590 * \param size the size of the ICC profile
591 * \returns the raw ICC profile data on success or NULL on failure; call
592 * SDL_GetError() for more information.
593 *
594 * \since This function is available since SDL 3.0.0.
595 */
596extern DECLSPEC void *SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size);
597
598/**
599 * Get the pixel format associated with the window.
600 *
601 * \param window the window to query
602 * \returns the pixel format of the window on success or
603 * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more
604 * information.
605 *
606 * \since This function is available since SDL 3.0.0.
607 */
608extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
609
610/**
611 * Create a window with the specified position, dimensions, and flags.
612 *
613 * `flags` may be any of the following OR'd together:
614 *
615 * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution
616 * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context
617 * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance
618 * - `SDL_WINDOW_METAL`: window usable with a Metal instance
619 * - `SDL_WINDOW_HIDDEN`: window is not visible
620 * - `SDL_WINDOW_BORDERLESS`: no window decoration
621 * - `SDL_WINDOW_RESIZABLE`: window can be resized
622 * - `SDL_WINDOW_MINIMIZED`: window is minimized
623 * - `SDL_WINDOW_MAXIMIZED`: window is maximized
624 * - `SDL_WINDOW_MOUSE_GRABBED`: window has grabbed mouse focus
625 *
626 * The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set.
627 *
628 * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
629 * property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
630 *
631 * The window size in pixels may differ from its size in screen coordinates if
632 * the window is on a high density display (one with an OS scaling factor).
633 * Use SDL_GetWindowSize() to query the client area's size in screen
634 * coordinates, and SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize()
635 * to query the drawable size in pixels. Note that the drawable size can vary
636 * after the window is created and should be queried again if you get an
637 * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event.
638 *
639 * If the window is set fullscreen, the width and height parameters `w` and
640 * `h` will not be used. However, invalid size parameters (e.g. too large) may
641 * still fail. Window size is actually limited to 16384 x 16384 for all
642 * platforms at window creation.
643 *
644 * If the window is created with any of the SDL_WINDOW_OPENGL or
645 * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
646 * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the
647 * corresponding UnloadLibrary function is called by SDL_DestroyWindow().
648 *
649 * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
650 * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail.
651 *
652 * If SDL_WINDOW_METAL is specified on an OS that does not support Metal,
653 * SDL_CreateWindow() will fail.
654 *
655 * On non-Apple devices, SDL requires you to either not link to the Vulkan
656 * loader or link to a dynamic library version. This limitation may be removed
657 * in a future version of SDL.
658 *
659 * \param title the title of the window, in UTF-8 encoding
660 * \param x the x position of the window, `SDL_WINDOWPOS_CENTERED`, or
661 * `SDL_WINDOWPOS_UNDEFINED`
662 * \param y the y position of the window, `SDL_WINDOWPOS_CENTERED`, or
663 * `SDL_WINDOWPOS_UNDEFINED`
664 * \param w the width of the window, in screen coordinates
665 * \param h the height of the window, in screen coordinates
666 * \param flags 0, or one or more SDL_WindowFlags OR'd together
667 * \returns the window that was created or NULL on failure; call
668 * SDL_GetError() for more information.
669 *
670 * \since This function is available since SDL 3.0.0.
671 *
672 * \sa SDL_CreateWindowFrom
673 * \sa SDL_DestroyWindow
674 */
675extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags);
676
677/**
678 * Create an SDL window from an existing native window.
679 *
680 * In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows)
681 * the hint `SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT` needs to be configured
682 * before using SDL_CreateWindowFrom().
683 *
684 * \param data a pointer to driver-dependent window creation data, typically
685 * your native window cast to a void*
686 * \returns the window that was created or NULL on failure; call
687 * SDL_GetError() for more information.
688 *
689 * \since This function is available since SDL 3.0.0.
690 *
691 * \sa SDL_CreateWindow
692 * \sa SDL_DestroyWindow
693 */
694extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowFrom(const void *data);
695
696/**
697 * Get the numeric ID of a window.
698 *
699 * The numeric ID is what SDL_WindowEvent references, and is necessary to map
700 * these events to specific SDL_Window objects.
701 *
702 * \param window the window to query
703 * \returns the ID of the window on success or 0 on failure; call
704 * SDL_GetError() for more information.
705 *
706 * \since This function is available since SDL 3.0.0.
707 *
708 * \sa SDL_GetWindowFromID
709 */
710extern DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window);
711
712/**
713 * Get a window from a stored ID.
714 *
715 * The numeric ID is what SDL_WindowEvent references, and is necessary to map
716 * these events to specific SDL_Window objects.
717 *
718 * \param id the ID of the window
719 * \returns the window associated with `id` or NULL if it doesn't exist; call
720 * SDL_GetError() for more information.
721 *
722 * \since This function is available since SDL 3.0.0.
723 *
724 * \sa SDL_GetWindowID
725 */
726extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowFromID(SDL_WindowID id);
727
728/**
729 * Get the window flags.
730 *
731 * \param window the window to query
732 * \returns a mask of the SDL_WindowFlags associated with `window`
733 *
734 * \since This function is available since SDL 3.0.0.
735 *
736 * \sa SDL_CreateWindow
737 * \sa SDL_HideWindow
738 * \sa SDL_MaximizeWindow
739 * \sa SDL_MinimizeWindow
740 * \sa SDL_SetWindowFullscreen
741 * \sa SDL_SetWindowGrab
742 * \sa SDL_ShowWindow
743 */
744extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window *window);
745
746/**
747 * Set the title of a window.
748 *
749 * This string is expected to be in UTF-8 encoding.
750 *
751 * \param window the window to change
752 * \param title the desired window title in UTF-8 format
753 * \returns 0 on success or a negative error code on failure; call
754 * SDL_GetError() for more information.
755 *
756 * \since This function is available since SDL 3.0.0.
757 *
758 * \sa SDL_GetWindowTitle
759 */
760extern DECLSPEC int SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
761
762/**
763 * Get the title of a window.
764 *
765 * \param window the window to query
766 * \returns the title of the window in UTF-8 format or "" if there is no
767 * title.
768 *
769 * \since This function is available since SDL 3.0.0.
770 *
771 * \sa SDL_SetWindowTitle
772 */
773extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window *window);
774
775/**
776 * Set the icon for a window.
777 *
778 * \param window the window to change
779 * \param icon an SDL_Surface structure containing the icon for the window
780 * \returns 0 on success or a negative error code on failure; call
781 * SDL_GetError() for more information.
782 *
783 * \since This function is available since SDL 3.0.0.
784 */
785extern DECLSPEC int SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
786
787/**
788 * Associate an arbitrary named pointer with a window.
789 *
790 * `name` is case-sensitive.
791 *
792 * \param window the window to associate with the pointer
793 * \param name the name of the pointer
794 * \param userdata the associated pointer
795 * \returns the previous value associated with `name`.
796 *
797 * \since This function is available since SDL 3.0.0.
798 *
799 * \sa SDL_GetWindowData
800 */
801extern DECLSPEC void *SDLCALL SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata);
802
803/**
804 * Retrieve the data pointer associated with a window.
805 *
806 * \param window the window to query
807 * \param name the name of the pointer
808 * \returns the value associated with `name`.
809 *
810 * \since This function is available since SDL 3.0.0.
811 *
812 * \sa SDL_SetWindowData
813 */
814extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *name);
815
816/**
817 * Set the position of a window, in screen coordinates.
818 *
819 * \param window the window to reposition
820 * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
821 * `SDL_WINDOWPOS_UNDEFINED`
822 * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
823 * `SDL_WINDOWPOS_UNDEFINED`
824 * \returns 0 on success or a negative error code on failure; call
825 * SDL_GetError() for more information.
826 *
827 * \since This function is available since SDL 3.0.0.
828 *
829 * \sa SDL_GetWindowPosition
830 */
831extern DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
832
833/**
834 * Get the position of a window, in screen coordinates.
835 *
836 * If you do not need the value for one of the positions a NULL may be passed
837 * in the `x` or `y` parameter.
838 *
839 * \param window the window to query
840 * \param x a pointer filled in with the x position of the window, may be NULL
841 * \param y a pointer filled in with the y position of the window, may be NULL
842 * \returns 0 on success or a negative error code on failure; call
843 * SDL_GetError() for more information.
844 *
845 * \since This function is available since SDL 3.0.0.
846 *
847 * \sa SDL_SetWindowPosition
848 */
849extern DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
850
851/**
852 * Set the size of a window's client area, in screen coordinates.
853 *
854 * The window size in screen coordinates may differ from the size in pixels if
855 * the window is on a high density display (one with an OS scaling factor).
856 *
857 * This only affects the size of the window when not in fullscreen mode. To change
858 * the fullscreen mode of a window, use SDL_SetWindowFullscreenMode()
859 *
860 * \param window the window to change
861 * \param w the width of the window, must be > 0
862 * \param h the height of the window, must be > 0
863 * \returns 0 on success or a negative error code on failure; call
864 * SDL_GetError() for more information.
865 *
866 * \since This function is available since SDL 3.0.0.
867 *
868 * \sa SDL_GetWindowSize
869 * \sa SDL_SetWindowFullscreenMode
870 */
871extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
872
873/**
874 * Get the size of a window's client area, in screen coordinates.
875 *
876 * NULL can safely be passed as the `w` or `h` parameter if the width or
877 * height value is not desired.
878 *
879 * The window size in screen coordinates may differ from the size in pixels if
880 * the window is on a high density display (one with an OS scaling factor).
881 * Use SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to get the
882 * real client area size in pixels.
883 *
884 * \param window the window to query the width and height from
885 * \param w a pointer filled in with the width of the window, may be NULL
886 * \param h a pointer filled in with the height of the window, may be NULL
887 * \returns 0 on success or a negative error code on failure; call
888 * SDL_GetError() for more information.
889 *
890 * \since This function is available since SDL 3.0.0.
891 *
892 * \sa SDL_GetRenderOutputSize
893 * \sa SDL_GetWindowSizeInPixels
894 * \sa SDL_SetWindowSize
895 */
896extern DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
897
898/**
899 * Get the size of a window's borders (decorations) around the client area, in
900 * screen coordinates.
901 *
902 * Note: If this function fails (returns -1), the size values will be
903 * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the
904 * window in question was borderless.
905 *
906 * Note: This function may fail on systems where the window has not yet been
907 * decorated by the display server (for example, immediately after calling
908 * SDL_CreateWindow). It is recommended that you wait at least until the
909 * window has been presented and composited, so that the window system has a
910 * chance to decorate the window and provide the border dimensions to SDL.
911 *
912 * This function also returns -1 if getting the information is not supported.
913 *
914 * \param window the window to query the size values of the border
915 * (decorations) from
916 * \param top pointer to variable for storing the size of the top border; NULL
917 * is permitted
918 * \param left pointer to variable for storing the size of the left border;
919 * NULL is permitted
920 * \param bottom pointer to variable for storing the size of the bottom
921 * border; NULL is permitted
922 * \param right pointer to variable for storing the size of the right border;
923 * NULL is permitted
924 * \returns 0 on success or a negative error code on failure; call
925 * SDL_GetError() for more information.
926 *
927 * \since This function is available since SDL 3.0.0.
928 *
929 * \sa SDL_GetWindowSize
930 */
931extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
932
933/**
934 * Get the size of a window's client area, in pixels.
935 *
936 * The window size in pixels may differ from the size in screen coordinates if
937 * the window is on a high density display (one with an OS scaling factor).
938 *
939 * \param window the window from which the drawable size should be queried
940 * \param w a pointer to variable for storing the width in pixels, may be NULL
941 * \param h a pointer to variable for storing the height in pixels, may be
942 * NULL
943 * \returns 0 on success or a negative error code on failure; call
944 * SDL_GetError() for more information.
945 *
946 * \since This function is available since SDL 3.0.0.
947 *
948 * \sa SDL_CreateWindow
949 * \sa SDL_GetWindowSize
950 */
951extern DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
952
953/**
954 * Set the minimum size of a window's client area, in screen coordinates.
955 *
956 * \param window the window to change
957 * \param min_w the minimum width of the window
958 * \param min_h the minimum height of the window
959 * \returns 0 on success or a negative error code on failure; call
960 * SDL_GetError() for more information.
961 *
962 * \since This function is available since SDL 3.0.0.
963 *
964 * \sa SDL_GetWindowMinimumSize
965 * \sa SDL_SetWindowMaximumSize
966 */
967extern DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
968
969/**
970 * Get the minimum size of a window's client area, in screen coordinates.
971 *
972 * \param window the window to query
973 * \param w a pointer filled in with the minimum width of the window, may be
974 * NULL
975 * \param h a pointer filled in with the minimum height of the window, may be
976 * NULL
977 * \returns 0 on success or a negative error code on failure; call
978 * SDL_GetError() for more information.
979 *
980 * \since This function is available since SDL 3.0.0.
981 *
982 * \sa SDL_GetWindowMaximumSize
983 * \sa SDL_SetWindowMinimumSize
984 */
985extern DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
986
987/**
988 * Set the maximum size of a window's client area, in screen coordinates.
989 *
990 * \param window the window to change
991 * \param max_w the maximum width of the window
992 * \param max_h the maximum height of the window
993 * \returns 0 on success or a negative error code on failure; call
994 * SDL_GetError() for more information.
995 *
996 * \since This function is available since SDL 3.0.0.
997 *
998 * \sa SDL_GetWindowMaximumSize
999 * \sa SDL_SetWindowMinimumSize
1000 */
1001extern DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
1002
1003/**
1004 * Get the maximum size of a window's client area, in screen coordinates.
1005 *
1006 * \param window the window to query
1007 * \param w a pointer filled in with the maximum width of the window, may be
1008 * NULL
1009 * \param h a pointer filled in with the maximum height of the window, may be
1010 * NULL
1011 * \returns 0 on success or a negative error code on failure; call
1012 * SDL_GetError() for more information.
1013 *
1014 * \since This function is available since SDL 3.0.0.
1015 *
1016 * \sa SDL_GetWindowMinimumSize
1017 * \sa SDL_SetWindowMaximumSize
1018 */
1019extern DECLSPEC int SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
1020
1021/**
1022 * Set the border state of a window.
1023 *
1024 * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add
1025 * or remove the border from the actual window. This is a no-op if the
1026 * window's border already matches the requested state.
1027 *
1028 * You can't change the border state of a fullscreen window.
1029 *
1030 * \param window the window of which to change the border state
1031 * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border
1032 * \returns 0 on success or a negative error code on failure; call
1033 * SDL_GetError() for more information.
1034 *
1035 * \since This function is available since SDL 3.0.0.
1036 *
1037 * \sa SDL_GetWindowFlags
1038 */
1039extern DECLSPEC int SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
1040
1041/**
1042 * Set the user-resizable state of a window.
1043 *
1044 * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and
1045 * allow/disallow user resizing of the window. This is a no-op if the window's
1046 * resizable state already matches the requested state.
1047 *
1048 * You can't change the resizable state of a fullscreen window.
1049 *
1050 * \param window the window of which to change the resizable state
1051 * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow
1052 * \returns 0 on success or a negative error code on failure; call
1053 * SDL_GetError() for more information.
1054 *
1055 * \since This function is available since SDL 3.0.0.
1056 *
1057 * \sa SDL_GetWindowFlags
1058 */
1059extern DECLSPEC int SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
1060
1061/**
1062 * Set the window to always be above the others.
1063 *
1064 * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This
1065 * will bring the window to the front and keep the window above the rest.
1066 *
1067 * \param window The window of which to change the always on top state
1068 * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
1069 * disable
1070 * \returns 0 on success or a negative error code on failure; call
1071 * SDL_GetError() for more information.
1072 *
1073 * \since This function is available since SDL 3.0.0.
1074 *
1075 * \sa SDL_GetWindowFlags
1076 */
1077extern DECLSPEC int SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
1078
1079/**
1080 * Show a window.
1081 *
1082 * \param window the window to show
1083 * \returns 0 on success or a negative error code on failure; call
1084 * SDL_GetError() for more information.
1085 *
1086 * \since This function is available since SDL 3.0.0.
1087 *
1088 * \sa SDL_HideWindow
1089 * \sa SDL_RaiseWindow
1090 */
1091extern DECLSPEC int SDLCALL SDL_ShowWindow(SDL_Window *window);
1092
1093/**
1094 * Hide a window.
1095 *
1096 * \param window the window to hide
1097 * \returns 0 on success or a negative error code on failure; call
1098 * SDL_GetError() for more information.
1099 *
1100 * \since This function is available since SDL 3.0.0.
1101 *
1102 * \sa SDL_ShowWindow
1103 */
1104extern DECLSPEC int SDLCALL SDL_HideWindow(SDL_Window *window);
1105
1106/**
1107 * Raise a window above other windows and set the input focus.
1108 *
1109 * \param window the window to raise
1110 * \returns 0 on success or a negative error code on failure; call
1111 * SDL_GetError() for more information.
1112 *
1113 * \since This function is available since SDL 3.0.0.
1114 */
1115extern DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
1116
1117/**
1118 * Make a window as large as possible.
1119 *
1120 * \param window the window to maximize
1121 * \returns 0 on success or a negative error code on failure; call
1122 * SDL_GetError() for more information.
1123 *
1124 * \since This function is available since SDL 3.0.0.
1125 *
1126 * \sa SDL_MinimizeWindow
1127 * \sa SDL_RestoreWindow
1128 */
1129extern DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
1130
1131/**
1132 * Minimize a window to an iconic representation.
1133 *
1134 * \param window the window to minimize
1135 * \returns 0 on success or a negative error code on failure; call
1136 * SDL_GetError() for more information.
1137 *
1138 * \since This function is available since SDL 3.0.0.
1139 *
1140 * \sa SDL_MaximizeWindow
1141 * \sa SDL_RestoreWindow
1142 */
1143extern DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
1144
1145/**
1146 * Restore the size and position of a minimized or maximized window.
1147 *
1148 * \param window the window to restore
1149 * \returns 0 on success or a negative error code on failure; call
1150 * SDL_GetError() for more information.
1151 *
1152 * \since This function is available since SDL 3.0.0.
1153 *
1154 * \sa SDL_MaximizeWindow
1155 * \sa SDL_MinimizeWindow
1156 */
1157extern DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
1158
1159/**
1160 * Set a window's fullscreen state.
1161 *
1162 * By default a window in fullscreen state uses fullscreen desktop mode,
1163 * but a specific display mode can be set using SDL_SetWindowFullscreenMode().
1164 *
1165 * \param window the window to change
1166 * \param fullscreen SDL_TRUE for fullscreen mode, SDL_FALSE for windowed mode
1167 * \returns 0 on success or a negative error code on failure; call
1168 * SDL_GetError() for more information.
1169 *
1170 * \since This function is available since SDL 3.0.0.
1171 *
1172 * \sa SDL_GetWindowFullscreenMode
1173 * \sa SDL_SetWindowFullscreenMode
1174 */
1175extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen);
1176
1177/**
1178 * Get the SDL surface associated with the window.
1179 *
1180 * A new surface will be created with the optimal format for the window, if
1181 * necessary. This surface will be freed when the window is destroyed. Do not
1182 * free this surface.
1183 *
1184 * This surface will be invalidated if the window is resized. After resizing a
1185 * window this function must be called again to return a valid surface.
1186 *
1187 * You may not combine this with 3D or the rendering API on this window.
1188 *
1189 * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`.
1190 *
1191 * \param window the window to query
1192 * \returns the surface associated with the window, or NULL on failure; call
1193 * SDL_GetError() for more information.
1194 *
1195 * \since This function is available since SDL 3.0.0.
1196 *
1197 * \sa SDL_UpdateWindowSurface
1198 * \sa SDL_UpdateWindowSurfaceRects
1199 */
1200extern DECLSPEC SDL_Surface *SDLCALL SDL_GetWindowSurface(SDL_Window *window);
1201
1202/**
1203 * Copy the window surface to the screen.
1204 *
1205 * This is the function you use to reflect any changes to the surface on the
1206 * screen.
1207 *
1208 * This function is equivalent to the SDL 1.2 API SDL_Flip().
1209 *
1210 * \param window the window to update
1211 * \returns 0 on success or a negative error code on failure; call
1212 * SDL_GetError() for more information.
1213 *
1214 * \since This function is available since SDL 3.0.0.
1215 *
1216 * \sa SDL_GetWindowSurface
1217 * \sa SDL_UpdateWindowSurfaceRects
1218 */
1219extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
1220
1221/**
1222 * Copy areas of the window surface to the screen.
1223 *
1224 * This is the function you use to reflect changes to portions of the surface
1225 * on the screen.
1226 *
1227 * This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
1228 *
1229 * \param window the window to update
1230 * \param rects an array of SDL_Rect structures representing areas of the
1231 * surface to copy, in pixels
1232 * \param numrects the number of rectangles
1233 * \returns 0 on success or a negative error code on failure; call
1234 * SDL_GetError() for more information.
1235 *
1236 * \since This function is available since SDL 3.0.0.
1237 *
1238 * \sa SDL_GetWindowSurface
1239 * \sa SDL_UpdateWindowSurface
1240 */
1241extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
1242
1243/**
1244 * Set a window's input grab mode.
1245 *
1246 * When input is grabbed, the mouse is confined to the window. This function
1247 * will also grab the keyboard if `SDL_HINT_GRAB_KEYBOARD` is set. To grab the
1248 * keyboard without also grabbing the mouse, use SDL_SetWindowKeyboardGrab().
1249 *
1250 * If the caller enables a grab while another window is currently grabbed, the
1251 * other window loses its grab in favor of the caller's window.
1252 *
1253 * \param window the window for which the input grab mode should be set
1254 * \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input
1255 * \returns 0 on success or a negative error code on failure; call
1256 * SDL_GetError() for more information.
1257 *
1258 * \since This function is available since SDL 3.0.0.
1259 *
1260 * \sa SDL_GetGrabbedWindow
1261 * \sa SDL_GetWindowGrab
1262 */
1263extern DECLSPEC int SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
1264
1265/**
1266 * Set a window's keyboard grab mode.
1267 *
1268 * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or
1269 * the Meta/Super key. Note that not all system keyboard shortcuts can be
1270 * captured by applications (one example is Ctrl+Alt+Del on Windows).
1271 *
1272 * This is primarily intended for specialized applications such as VNC clients
1273 * or VM frontends. Normal games should not use keyboard grab.
1274 *
1275 * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the
1276 * window is full-screen to ensure the user is not trapped in your
1277 * application. If you have a custom keyboard shortcut to exit fullscreen
1278 * mode, you may suppress this behavior with
1279 * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`.
1280 *
1281 * If the caller enables a grab while another window is currently grabbed, the
1282 * other window loses its grab in favor of the caller's window.
1283 *
1284 * \param window The window for which the keyboard grab mode should be set.
1285 * \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
1286 * \returns 0 on success or a negative error code on failure; call
1287 * SDL_GetError() for more information.
1288 *
1289 * \since This function is available since SDL 3.0.0.
1290 *
1291 * \sa SDL_GetWindowKeyboardGrab
1292 * \sa SDL_SetWindowMouseGrab
1293 * \sa SDL_SetWindowGrab
1294 */
1295extern DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
1296
1297/**
1298 * Set a window's mouse grab mode.
1299 *
1300 * Mouse grab confines the mouse cursor to the window.
1301 *
1302 * \param window The window for which the mouse grab mode should be set.
1303 * \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release.
1304 * \returns 0 on success or a negative error code on failure; call
1305 * SDL_GetError() for more information.
1306 *
1307 * \since This function is available since SDL 3.0.0.
1308 *
1309 * \sa SDL_GetWindowMouseGrab
1310 * \sa SDL_SetWindowKeyboardGrab
1311 * \sa SDL_SetWindowGrab
1312 */
1313extern DECLSPEC int SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
1314
1315/**
1316 * Get a window's input grab mode.
1317 *
1318 * \param window the window to query
1319 * \returns SDL_TRUE if input is grabbed, SDL_FALSE otherwise.
1320 *
1321 * \since This function is available since SDL 3.0.0.
1322 *
1323 * \sa SDL_SetWindowGrab
1324 */
1325extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window *window);
1326
1327/**
1328 * Get a window's keyboard grab mode.
1329 *
1330 * \param window the window to query
1331 * \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise.
1332 *
1333 * \since This function is available since SDL 3.0.0.
1334 *
1335 * \sa SDL_SetWindowKeyboardGrab
1336 * \sa SDL_GetWindowGrab
1337 */
1338extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window *window);
1339
1340/**
1341 * Get a window's mouse grab mode.
1342 *
1343 * \param window the window to query
1344 * \returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise.
1345 *
1346 * \since This function is available since SDL 3.0.0.
1347 *
1348 * \sa SDL_SetWindowKeyboardGrab
1349 * \sa SDL_GetWindowGrab
1350 */
1351extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window *window);
1352
1353/**
1354 * Get the window that currently has an input grab enabled.
1355 *
1356 * \returns the window if input is grabbed or NULL otherwise.
1357 *
1358 * \since This function is available since SDL 3.0.0.
1359 *
1360 * \sa SDL_GetWindowGrab
1361 * \sa SDL_SetWindowGrab
1362 */
1363extern DECLSPEC SDL_Window *SDLCALL SDL_GetGrabbedWindow(void);
1364
1365/**
1366 * Confines the cursor to the specified area of a window.
1367 *
1368 * Note that this does NOT grab the cursor, it only defines the area a cursor
1369 * is restricted to when the window has mouse focus.
1370 *
1371 * \param window The window that will be associated with the barrier.
1372 * \param rect A rectangle area in window-relative coordinates. If NULL the
1373 * barrier for the specified window will be destroyed.
1374 * \returns 0 on success or a negative error code on failure; call
1375 * SDL_GetError() for more information.
1376 *
1377 * \since This function is available since SDL 3.0.0.
1378 *
1379 * \sa SDL_GetWindowMouseRect
1380 * \sa SDL_SetWindowMouseGrab
1381 */
1382extern DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
1383
1384/**
1385 * Get the mouse confinement rectangle of a window.
1386 *
1387 * \param window The window to query
1388 * \returns A pointer to the mouse confinement rectangle of a window, or NULL
1389 * if there isn't one.
1390 *
1391 * \since This function is available since SDL 3.0.0.
1392 *
1393 * \sa SDL_SetWindowMouseRect
1394 */
1395extern DECLSPEC const SDL_Rect *SDLCALL SDL_GetWindowMouseRect(SDL_Window *window);
1396
1397/**
1398 * Set the opacity for a window.
1399 *
1400 * The parameter `opacity` will be clamped internally between 0.0f
1401 * (transparent) and 1.0f (opaque).
1402 *
1403 * This function also returns -1 if setting the opacity isn't supported.
1404 *
1405 * \param window the window which will be made transparent or opaque
1406 * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque)
1407 * \returns 0 on success or a negative error code on failure; call
1408 * SDL_GetError() for more information.
1409 *
1410 * \since This function is available since SDL 3.0.0.
1411 *
1412 * \sa SDL_GetWindowOpacity
1413 */
1414extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity);
1415
1416/**
1417 * Get the opacity of a window.
1418 *
1419 * If transparency isn't supported on this platform, opacity will be reported
1420 * as 1.0f without error.
1421 *
1422 * The parameter `opacity` is ignored if it is NULL.
1423 *
1424 * This function also returns -1 if an invalid window was provided.
1425 *
1426 * \param window the window to get the current opacity value from
1427 * \param out_opacity the float filled in (0.0f - transparent, 1.0f - opaque)
1428 * \returns 0 on success or a negative error code on failure; call
1429 * SDL_GetError() for more information.
1430 *
1431 * \since This function is available since SDL 3.0.0.
1432 *
1433 * \sa SDL_SetWindowOpacity
1434 */
1435extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity);
1436
1437/**
1438 * Set the window as a modal for another window.
1439 *
1440 * \param modal_window the window that should be set modal
1441 * \param parent_window the parent window for the modal window
1442 * \returns 0 on success or a negative error code on failure; call
1443 * SDL_GetError() for more information.
1444 *
1445 * \since This function is available since SDL 3.0.0.
1446 */
1447extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window);
1448
1449/**
1450 * Explicitly set input focus to the window.
1451 *
1452 * You almost certainly want SDL_RaiseWindow() instead of this function. Use
1453 * this with caution, as you might give focus to a window that is completely
1454 * obscured by other windows.
1455 *
1456 * \param window the window that should get the input focus
1457 * \returns 0 on success or a negative error code on failure; call
1458 * SDL_GetError() for more information.
1459 *
1460 * \since This function is available since SDL 3.0.0.
1461 *
1462 * \sa SDL_RaiseWindow
1463 */
1464extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window *window);
1465
1466/**
1467 * Possible return values from the SDL_HitTest callback.
1468 *
1469 * \sa SDL_HitTest
1470 */
1471typedef enum
1472{
1473 SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */
1474 SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */
1484
1485/**
1486 * Callback used for hit-testing.
1487 *
1488 * \param win the SDL_Window where hit-testing was set on
1489 * \param area an SDL_Point which should be hit-tested
1490 * \param data what was passed as `callback_data` to SDL_SetWindowHitTest()
1491 * \return an SDL_HitTestResult value.
1492 *
1493 * \sa SDL_SetWindowHitTest
1494 */
1496 const SDL_Point *area,
1497 void *data);
1498
1499/**
1500 * Provide a callback that decides if a window region has special properties.
1501 *
1502 * Normally windows are dragged and resized by decorations provided by the
1503 * system window manager (a title bar, borders, etc), but for some apps, it
1504 * makes sense to drag them from somewhere else inside the window itself; for
1505 * example, one might have a borderless window that wants to be draggable from
1506 * any part, or simulate its own title bar, etc.
1507 *
1508 * This function lets the app provide a callback that designates pieces of a
1509 * given window as special. This callback is run during event processing if we
1510 * need to tell the OS to treat a region of the window specially; the use of
1511 * this callback is known as "hit testing."
1512 *
1513 * Mouse input may not be delivered to your application if it is within a
1514 * special area; the OS will often apply that input to moving the window or
1515 * resizing the window and not deliver it to the application.
1516 *
1517 * Specifying NULL for a callback disables hit-testing. Hit-testing is
1518 * disabled by default.
1519 *
1520 * Platforms that don't support this functionality will return -1
1521 * unconditionally, even if you're attempting to disable hit-testing.
1522 *
1523 * Your callback may fire at any time, and its firing does not indicate any
1524 * specific behavior (for example, on Windows, this certainly might fire when
1525 * the OS is deciding whether to drag your window, but it fires for lots of
1526 * other reasons, too, some unrelated to anything you probably care about _and
1527 * when the mouse isn't actually at the location it is testing_). Since this
1528 * can fire at any time, you should try to keep your callback efficient,
1529 * devoid of allocations, etc.
1530 *
1531 * \param window the window to set hit-testing on
1532 * \param callback the function to call when doing a hit-test
1533 * \param callback_data an app-defined void pointer passed to **callback**
1534 * \returns 0 on success or -1 on error (including unsupported); call
1535 * SDL_GetError() for more information.
1536 *
1537 * \since This function is available since SDL 3.0.0.
1538 */
1539extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
1540
1541/**
1542 * Request a window to demand attention from the user.
1543 *
1544 * \param window the window to be flashed
1545 * \param operation the flash operation
1546 * \returns 0 on success or a negative error code on failure; call
1547 * SDL_GetError() for more information.
1548 *
1549 * \since This function is available since SDL 3.0.0.
1550 */
1551extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
1552
1553/**
1554 * Destroy a window.
1555 *
1556 * If `window` is NULL, this function will return immediately after setting
1557 * the SDL error message to "Invalid window". See SDL_GetError().
1558 *
1559 * \param window the window to destroy
1560 * \returns 0 on success or a negative error code on failure; call
1561 * SDL_GetError() for more information.
1562 *
1563 * \since This function is available since SDL 3.0.0.
1564 *
1565 * \sa SDL_CreateWindow
1566 * \sa SDL_CreateWindowFrom
1567 */
1568extern DECLSPEC int SDLCALL SDL_DestroyWindow(SDL_Window *window);
1569
1570
1571/**
1572 * Check whether the screensaver is currently enabled.
1573 *
1574 * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2
1575 * the screensaver was enabled by default.
1576 *
1577 * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`.
1578 *
1579 * \returns SDL_TRUE if the screensaver is enabled, SDL_FALSE if it is
1580 * disabled.
1581 *
1582 * \since This function is available since SDL 3.0.0.
1583 *
1584 * \sa SDL_DisableScreenSaver
1585 * \sa SDL_EnableScreenSaver
1586 */
1587extern DECLSPEC SDL_bool SDLCALL SDL_ScreenSaverEnabled(void);
1588
1589/**
1590 * Allow the screen to be blanked by a screen saver.
1591 *
1592 * \since This function is available since SDL 3.0.0.
1593 *
1594 * \sa SDL_DisableScreenSaver
1595 * \sa SDL_ScreenSaverEnabled
1596 */
1597extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void);
1598
1599/**
1600 * Prevent the screen from being blanked by a screen saver.
1601 *
1602 * If you disable the screensaver, it is automatically re-enabled when SDL
1603 * quits.
1604 *
1605 * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2
1606 * the screensaver was enabled by default.
1607 *
1608 * \since This function is available since SDL 3.0.0.
1609 *
1610 * \sa SDL_EnableScreenSaver
1611 * \sa SDL_ScreenSaverEnabled
1612 */
1613extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void);
1614
1615
1616/**
1617 * \name OpenGL support functions
1618 */
1619/* @{ */
1620
1621/**
1622 * Dynamically load an OpenGL library.
1623 *
1624 * This should be done after initializing the video driver, but before
1625 * creating any OpenGL windows. If no OpenGL library is loaded, the default
1626 * library will be loaded upon creation of the first OpenGL window.
1627 *
1628 * If you do this, you need to retrieve all of the GL functions used in your
1629 * program from the dynamic library using SDL_GL_GetProcAddress().
1630 *
1631 * \param path the platform dependent OpenGL library name, or NULL to open the
1632 * default OpenGL library
1633 * \returns 0 on success or a negative error code on failure; call
1634 * SDL_GetError() for more information.
1635 *
1636 * \since This function is available since SDL 3.0.0.
1637 *
1638 * \sa SDL_GL_GetProcAddress
1639 * \sa SDL_GL_UnloadLibrary
1640 */
1641extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
1642
1643/**
1644 * Get an OpenGL function by name.
1645 *
1646 * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all
1647 * GL functions must be retrieved this way. Usually this is used to retrieve
1648 * function pointers to OpenGL extensions.
1649 *
1650 * There are some quirks to looking up OpenGL functions that require some
1651 * extra care from the application. If you code carefully, you can handle
1652 * these quirks without any platform-specific code, though:
1653 *
1654 * - On Windows, function pointers are specific to the current GL context;
1655 * this means you need to have created a GL context and made it current
1656 * before calling SDL_GL_GetProcAddress(). If you recreate your context or
1657 * create a second context, you should assume that any existing function
1658 * pointers aren't valid to use with it. This is (currently) a
1659 * Windows-specific limitation, and in practice lots of drivers don't suffer
1660 * this limitation, but it is still the way the wgl API is documented to
1661 * work and you should expect crashes if you don't respect it. Store a copy
1662 * of the function pointers that comes and goes with context lifespan.
1663 * - On X11, function pointers returned by this function are valid for any
1664 * context, and can even be looked up before a context is created at all.
1665 * This means that, for at least some common OpenGL implementations, if you
1666 * look up a function that doesn't exist, you'll get a non-NULL result that
1667 * is _NOT_ safe to call. You must always make sure the function is actually
1668 * available for a given GL context before calling it, by checking for the
1669 * existence of the appropriate extension with SDL_GL_ExtensionSupported(),
1670 * or verifying that the version of OpenGL you're using offers the function
1671 * as core functionality.
1672 * - Some OpenGL drivers, on all platforms, *will* return NULL if a function
1673 * isn't supported, but you can't count on this behavior. Check for
1674 * extensions you use, and if you get a NULL anyway, act as if that
1675 * extension wasn't available. This is probably a bug in the driver, but you
1676 * can code defensively for this scenario anyhow.
1677 * - Just because you're on Linux/Unix, don't assume you'll be using X11.
1678 * Next-gen display servers are waiting to replace it, and may or may not
1679 * make the same promises about function pointers.
1680 * - OpenGL function pointers must be declared `APIENTRY` as in the example
1681 * code. This will ensure the proper calling convention is followed on
1682 * platforms where this matters (Win32) thereby avoiding stack corruption.
1683 *
1684 * \param proc the name of an OpenGL function
1685 * \returns a pointer to the named OpenGL function. The returned pointer
1686 * should be cast to the appropriate function signature.
1687 *
1688 * \since This function is available since SDL 3.0.0.
1689 *
1690 * \sa SDL_GL_ExtensionSupported
1691 * \sa SDL_GL_LoadLibrary
1692 * \sa SDL_GL_UnloadLibrary
1693 */
1694extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc);
1695
1696/**
1697 * Get an EGL library function by name.
1698 *
1699 * If an EGL library is loaded, this function allows applications to get entry
1700 * points for EGL functions. This is useful to provide to an EGL API and
1701 * extension loader.
1702 *
1703 * \param proc the name of an EGL function
1704 * \returns a pointer to the named EGL function. The returned pointer should
1705 * be cast to the appropriate function signature.
1706 *
1707 * \since This function is available since SDL 3.0.0.
1708 *
1709 * \sa SDL_GL_GetCurrentEGLDisplay
1710 */
1711extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
1712
1713/**
1714 * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
1715 *
1716 * \since This function is available since SDL 3.0.0.
1717 *
1718 * \sa SDL_GL_LoadLibrary
1719 */
1720extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
1721
1722/**
1723 * Check if an OpenGL extension is supported for the current context.
1724 *
1725 * This function operates on the current GL context; you must have created a
1726 * context and it must be current before calling this function. Do not assume
1727 * that all contexts you create will have the same set of extensions
1728 * available, or that recreating an existing context will offer the same
1729 * extensions again.
1730 *
1731 * While it's probably not a massive overhead, this function is not an O(1)
1732 * operation. Check the extensions you care about after creating the GL
1733 * context and save that information somewhere instead of calling the function
1734 * every time you need to know.
1735 *
1736 * \param extension the name of the extension to check
1737 * \returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise.
1738 *
1739 * \since This function is available since SDL 3.0.0.
1740 */
1741extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension);
1742
1743/**
1744 * Reset all previously set OpenGL context attributes to their default values.
1745 *
1746 * \since This function is available since SDL 3.0.0.
1747 *
1748 * \sa SDL_GL_GetAttribute
1749 * \sa SDL_GL_SetAttribute
1750 */
1751extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
1752
1753/**
1754 * Set an OpenGL window attribute before window creation.
1755 *
1756 * This function sets the OpenGL attribute `attr` to `value`. The requested
1757 * attributes should be set before creating an OpenGL window. You should use
1758 * SDL_GL_GetAttribute() to check the values after creating the OpenGL
1759 * context, since the values obtained can differ from the requested ones.
1760 *
1761 * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to set
1762 * \param value the desired value for the attribute
1763 * \returns 0 on success or a negative error code on failure; call
1764 * SDL_GetError() for more information.
1765 *
1766 * \since This function is available since SDL 3.0.0.
1767 *
1768 * \sa SDL_GL_GetAttribute
1769 * \sa SDL_GL_ResetAttributes
1770 */
1771extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
1772
1773/**
1774 * Get the actual value for an attribute from the current context.
1775 *
1776 * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to get
1777 * \param value a pointer filled in with the current value of `attr`
1778 * \returns 0 on success or a negative error code on failure; call
1779 * SDL_GetError() for more information.
1780 *
1781 * \since This function is available since SDL 3.0.0.
1782 *
1783 * \sa SDL_GL_ResetAttributes
1784 * \sa SDL_GL_SetAttribute
1785 */
1786extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
1787
1788/**
1789 * Create an OpenGL context for an OpenGL window, and make it current.
1790 *
1791 * Windows users new to OpenGL should note that, for historical reasons, GL
1792 * functions added after OpenGL version 1.1 are not available by default.
1793 * Those functions must be loaded at run-time, either with an OpenGL
1794 * extension-handling library or with SDL_GL_GetProcAddress() and its related
1795 * functions.
1796 *
1797 * SDL_GLContext is an alias for `void *`. It's opaque to the application.
1798 *
1799 * \param window the window to associate with the context
1800 * \returns the OpenGL context associated with `window` or NULL on error; call
1801 * SDL_GetError() for more details.
1802 *
1803 * \since This function is available since SDL 3.0.0.
1804 *
1805 * \sa SDL_GL_DeleteContext
1806 * \sa SDL_GL_MakeCurrent
1807 */
1808extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window);
1809
1810/**
1811 * Set up an OpenGL context for rendering into an OpenGL window.
1812 *
1813 * The context must have been created with a compatible window.
1814 *
1815 * \param window the window to associate with the context
1816 * \param context the OpenGL context to associate with the window
1817 * \returns 0 on success or a negative error code on failure; call
1818 * SDL_GetError() for more information.
1819 *
1820 * \since This function is available since SDL 3.0.0.
1821 *
1822 * \sa SDL_GL_CreateContext
1823 */
1824extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
1825
1826/**
1827 * Get the currently active OpenGL window.
1828 *
1829 * \returns the currently active OpenGL window on success or NULL on failure;
1830 * call SDL_GetError() for more information.
1831 *
1832 * \since This function is available since SDL 3.0.0.
1833 */
1834extern DECLSPEC SDL_Window *SDLCALL SDL_GL_GetCurrentWindow(void);
1835
1836/**
1837 * Get the currently active OpenGL context.
1838 *
1839 * \returns the currently active OpenGL context or NULL on failure; call
1840 * SDL_GetError() for more information.
1841 *
1842 * \since This function is available since SDL 3.0.0.
1843 *
1844 * \sa SDL_GL_MakeCurrent
1845 */
1846extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
1847
1848/**
1849 * Get the currently active EGL display.
1850 *
1851 * \returns the currently active EGL display or NULL on failure; call
1852 * SDL_GetError() for more information.
1853 *
1854 * \since This function is available since SDL 3.0.0.
1855 */
1856extern DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentEGLDisplay(void);
1857
1858/**
1859 * Get the currently active EGL config.
1860 *
1861 * \returns the currently active EGL config or NULL on failure; call
1862 * SDL_GetError() for more information.
1863 *
1864 * \since This function is available since SDL 3.0.0.
1865 */
1866extern DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentEGLConfig(void);
1867
1868/**
1869 * Get the EGL surface associated with the window.
1870 *
1871 * \returns the EGLSurface pointer associated with the window, or NULL on
1872 * failure.
1873 *
1874 * \since This function is available since SDL 3.0.0.
1875 */
1877
1878/**
1879 * Sets the callbacks for defining custom EGLAttrib arrays for EGL
1880 * initialization.
1881 *
1882 * Each callback should return a pointer to an EGL attribute array terminated
1883 * with EGL_NONE. Callbacks may return NULL pointers to signal an error, which
1884 * will cause the SDL_CreateWindow process to fail gracefully.
1885 *
1886 * The arrays returned by each callback will be appended to the existing
1887 * attribute arrays defined by SDL.
1888 *
1889 * NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes.
1890 *
1891 * \param platformAttribCallback Callback for attributes to pass to
1892 * eglGetPlatformDisplay.
1893 * \param surfaceAttribCallback Callback for attributes to pass to
1894 * eglCreateSurface.
1895 * \param contextAttribCallback Callback for attributes to pass to
1896 * eglCreateContext.
1897 *
1898 * \since This function is available since SDL 3.0.0.
1899 */
1900extern DECLSPEC void SDLCALL SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback,
1901 SDL_EGLIntArrayCallback surfaceAttribCallback,
1902 SDL_EGLIntArrayCallback contextAttribCallback);
1903
1904/**
1905 * Set the swap interval for the current OpenGL context.
1906 *
1907 * Some systems allow specifying -1 for the interval, to enable adaptive
1908 * vsync. Adaptive vsync works the same as vsync, but if you've already missed
1909 * the vertical retrace for a given frame, it swaps buffers immediately, which
1910 * might be less jarring for the user during occasional framerate drops. If an
1911 * application requests adaptive vsync and the system does not support it,
1912 * this function will fail and return -1. In such a case, you should probably
1913 * retry the call with 1 for the interval.
1914 *
1915 * Adaptive vsync is implemented for some glX drivers with
1916 * GLX_EXT_swap_control_tear, and for some Windows drivers with
1917 * WGL_EXT_swap_control_tear.
1918 *
1919 * Read more on the Khronos wiki:
1920 * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
1921 *
1922 * \param interval 0 for immediate updates, 1 for updates synchronized with
1923 * the vertical retrace, -1 for adaptive vsync
1924 * \returns 0 on success or -1 if setting the swap interval is not supported;
1925 * call SDL_GetError() for more information.
1926 *
1927 * \since This function is available since SDL 3.0.0.
1928 *
1929 * \sa SDL_GL_GetSwapInterval
1930 */
1931extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
1932
1933/**
1934 * Get the swap interval for the current OpenGL context.
1935 *
1936 * If the system can't determine the swap interval, or there isn't a valid
1937 * current context, this function will set *interval to 0 as a safe default.
1938 *
1939 * \param interval Output interval value. 0 if there is no vertical retrace
1940 * synchronization, 1 if the buffer swap is synchronized with
1941 * the vertical retrace, and -1 if late swaps happen
1942 * immediately instead of waiting for the next retrace
1943 * \returns 0 on success or -1 error. call SDL_GetError() for more
1944 * information.
1945 *
1946 * \since This function is available since SDL 3.0.0.
1947 *
1948 * \sa SDL_GL_SetSwapInterval
1949 */
1950extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(int *interval);
1951
1952/**
1953 * Update a window with OpenGL rendering.
1954 *
1955 * This is used with double-buffered OpenGL contexts, which are the default.
1956 *
1957 * On macOS, make sure you bind 0 to the draw framebuffer before swapping the
1958 * window, otherwise nothing will happen. If you aren't using
1959 * glBindFramebuffer(), this is the default and you won't have to do anything
1960 * extra.
1961 *
1962 * \param window the window to change
1963 * \returns 0 on success or a negative error code on failure; call
1964 * SDL_GetError() for more information.
1965 *
1966 * \since This function is available since SDL 3.0.0.
1967 */
1968extern DECLSPEC int SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
1969
1970/**
1971 * Delete an OpenGL context.
1972 *
1973 * \param context the OpenGL context to be deleted
1974 * \returns 0 on success or a negative error code on failure; call
1975 * SDL_GetError() for more information.
1976 *
1977 * \since This function is available since SDL 3.0.0.
1978 *
1979 * \sa SDL_GL_CreateContext
1980 */
1981extern DECLSPEC int SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
1982
1983/* @} *//* OpenGL support functions */
1984
1985
1986/* Ends C function definitions when using C++ */
1987#ifdef __cplusplus
1988}
1989#endif
1990#include <SDL3/SDL_close_code.h>
1991
1992#endif /* SDL_video_h_ */
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1564
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1967
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
GLenum mode
GLuint index
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLint left
GLsizeiptr size
GLuint const GLchar * name
GLbitfield flags
GLsizei const GLchar *const * path
GLint GLint bottom
GLsizei const GLfloat * value
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
SDL_bool
Definition: SDL_stdinc.h:130
void(* SDL_FunctionPointer)(void)
Definition: SDL_stdinc.h:775
uint32_t Uint32
Definition: SDL_stdinc.h:171
int SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed)
void SDL_DisableScreenSaver(void)
SDL_HitTestResult
Definition: SDL_video.h:1472
@ SDL_HITTEST_DRAGGABLE
Definition: SDL_video.h:1474
@ SDL_HITTEST_RESIZE_LEFT
Definition: SDL_video.h:1482
@ SDL_HITTEST_RESIZE_TOP
Definition: SDL_video.h:1476
@ SDL_HITTEST_RESIZE_TOPRIGHT
Definition: SDL_video.h:1477
@ SDL_HITTEST_NORMAL
Definition: SDL_video.h:1473
@ SDL_HITTEST_RESIZE_BOTTOM
Definition: SDL_video.h:1480
@ SDL_HITTEST_RESIZE_BOTTOMRIGHT
Definition: SDL_video.h:1479
@ SDL_HITTEST_RESIZE_BOTTOMLEFT
Definition: SDL_video.h:1481
@ SDL_HITTEST_RESIZE_RIGHT
Definition: SDL_video.h:1478
@ SDL_HITTEST_RESIZE_TOPLEFT
Definition: SDL_video.h:1475
SDL_DisplayID SDL_GetDisplayForPoint(const SDL_Point *point)
const SDL_DisplayMode ** SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count)
int SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window)
int SDL_UpdateWindowSurface(SDL_Window *window)
SDL_EGLAttrib *(* SDL_EGLAttribArrayCallback)(void)
EGL attribute initialization callback types.
Definition: SDL_video.h:193
int SDL_RaiseWindow(SDL_Window *window)
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:179
SDL_bool SDL_ScreenSaverEnabled(void)
SDL_Surface * SDL_GetWindowSurface(SDL_Window *window)
const char * SDL_GetDisplayName(SDL_DisplayID displayID)
Uint32 SDL_GetWindowFlags(SDL_Window *window)
SDL_bool SDL_GL_ExtensionSupported(const char *extension)
int SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect)
void SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback, SDL_EGLIntArrayCallback surfaceAttribCallback, SDL_EGLIntArrayCallback contextAttribCallback)
int SDL_ShowWindow(SDL_Window *window)
int SDL_GL_SetSwapInterval(int interval)
void * SDL_GetWindowData(SDL_Window *window, const char *name)
void * SDL_EGLDisplay
Opaque EGL types.
Definition: SDL_video.h:184
int SDL_GL_GetSwapInterval(int *interval)
const char * SDL_GetWindowTitle(SDL_Window *window)
SDL_HitTestResult(* SDL_HitTest)(SDL_Window *win, const SDL_Point *area, void *data)
Definition: SDL_video.h:1495
SDL_GLattr
OpenGL configuration attributes.
Definition: SDL_video.h:200
@ SDL_GL_EGL_PLATFORM
Definition: SDL_video.h:228
@ SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
Definition: SDL_video.h:223
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR
Definition: SDL_video.h:224
@ SDL_GL_DOUBLEBUFFER
Definition: SDL_video.h:206
@ SDL_GL_STENCIL_SIZE
Definition: SDL_video.h:208
@ SDL_GL_CONTEXT_MAJOR_VERSION
Definition: SDL_video.h:218
@ SDL_GL_CONTEXT_RESET_NOTIFICATION
Definition: SDL_video.h:225
@ SDL_GL_ACCUM_ALPHA_SIZE
Definition: SDL_video.h:212
@ SDL_GL_MULTISAMPLESAMPLES
Definition: SDL_video.h:215
@ SDL_GL_CONTEXT_MINOR_VERSION
Definition: SDL_video.h:219
@ SDL_GL_FLOATBUFFERS
Definition: SDL_video.h:227
@ SDL_GL_STEREO
Definition: SDL_video.h:213
@ SDL_GL_MULTISAMPLEBUFFERS
Definition: SDL_video.h:214
@ SDL_GL_ACCUM_GREEN_SIZE
Definition: SDL_video.h:210
@ SDL_GL_BLUE_SIZE
Definition: SDL_video.h:203
@ SDL_GL_SHARE_WITH_CURRENT_CONTEXT
Definition: SDL_video.h:222
@ SDL_GL_RETAINED_BACKING
Definition: SDL_video.h:217
@ SDL_GL_RED_SIZE
Definition: SDL_video.h:201
@ SDL_GL_ALPHA_SIZE
Definition: SDL_video.h:204
@ SDL_GL_BUFFER_SIZE
Definition: SDL_video.h:205
@ SDL_GL_ACCELERATED_VISUAL
Definition: SDL_video.h:216
@ SDL_GL_ACCUM_BLUE_SIZE
Definition: SDL_video.h:211
@ SDL_GL_DEPTH_SIZE
Definition: SDL_video.h:207
@ SDL_GL_ACCUM_RED_SIZE
Definition: SDL_video.h:209
@ SDL_GL_CONTEXT_FLAGS
Definition: SDL_video.h:220
@ SDL_GL_CONTEXT_PROFILE_MASK
Definition: SDL_video.h:221
@ SDL_GL_CONTEXT_NO_ERROR
Definition: SDL_video.h:226
@ SDL_GL_GREEN_SIZE
Definition: SDL_video.h:202
Uint32 SDL_GetWindowPixelFormat(SDL_Window *window)
void SDL_GL_ResetAttributes(void)
SDL_FlashOperation
Window flash operation.
Definition: SDL_video.h:170
@ SDL_FLASH_UNTIL_FOCUSED
Definition: SDL_video.h:173
@ SDL_FLASH_BRIEFLY
Definition: SDL_video.h:172
@ SDL_FLASH_CANCEL
Definition: SDL_video.h:171
SDL_EGLint *(* SDL_EGLIntArrayCallback)(void)
Definition: SDL_video.h:194
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:43
int SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable)
int SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h)
SDL_DisplayID SDL_GetDisplayForRect(const SDL_Rect *rect)
intptr_t SDL_EGLAttrib
Definition: SDL_video.h:187
int SDL_GetDisplayPhysicalDPI(SDL_DisplayID displayID, float *ddpi, float *hdpi, float *vdpi)
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)
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)
SDL_EGLDisplay SDL_EGL_GetCurrentEGLDisplay(void)
int SDL_SetWindowTitle(SDL_Window *window, const char *title)
int SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered)
struct SDL_Window SDL_Window
The type used to identify a window.
Definition: SDL_video.h:101
SDL_WindowID SDL_GetWindowID(SDL_Window *window)
SDL_DisplayID SDL_GetPrimaryDisplay(void)
int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect)
SDL_GLContext SDL_GL_CreateContext(SDL_Window *window)
const char * SDL_GetCurrentVideoDriver(void)
void * SDL_EGLConfig
Definition: SDL_video.h:185
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)
const SDL_DisplayMode * SDL_GetDesktopDisplayMode(SDL_DisplayID displayID)
Uint32 SDL_WindowID
Definition: SDL_video.h:44
int SDL_GetWindowPosition(SDL_Window *window, int *x, int *y)
int SDL_MinimizeWindow(SDL_Window *window)
SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
int SDL_EGLint
Definition: SDL_video.h:188
void SDL_EnableScreenSaver(void)
SDL_bool SDL_GetWindowGrab(SDL_Window *window)
SDL_FunctionPointer SDL_EGL_GetProcAddress(const char *proc)
const SDL_DisplayMode * SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate)
SDL_FunctionPointer SDL_GL_GetProcAddress(const char *proc)
int SDL_SetWindowSize(SDL_Window *window, int w, int h)
int SDL_SetWindowInputFocus(SDL_Window *window)
SDL_EGLConfig SDL_EGL_GetCurrentEGLConfig(void)
SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
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:247
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE
Definition: SDL_video.h:248
@ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH
Definition: SDL_video.h:249
int SDL_GetNumVideoDrivers(void)
SDL_Window * SDL_GL_GetCurrentWindow(void)
void * SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata)
int SDL_MaximizeWindow(SDL_Window *window)
SDL_EGLSurface SDL_EGL_GetWindowEGLSurface(SDL_Window *window)
int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context)
int SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h)
SDL_WindowFlags
The flags on a window.
Definition: SDL_video.h:109
@ SDL_WINDOW_FOREIGN
Definition: SDL_video.h:122
@ SDL_WINDOW_TOOLTIP
Definition: SDL_video.h:128
@ SDL_WINDOW_ALWAYS_ON_TOP
Definition: SDL_video.h:125
@ SDL_WINDOW_SKIP_TASKBAR
Definition: SDL_video.h:126
@ SDL_WINDOW_MOUSE_CAPTURE
Definition: SDL_video.h:124
@ SDL_WINDOW_VULKAN
Definition: SDL_video.h:131
@ SDL_WINDOW_OPENGL
Definition: SDL_video.h:111
@ SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:116
@ SDL_WINDOW_UTILITY
Definition: SDL_video.h:127
@ SDL_WINDOW_MOUSE_FOCUS
Definition: SDL_video.h:120
@ SDL_WINDOW_RESIZABLE
Definition: SDL_video.h:115
@ SDL_WINDOW_KEYBOARD_GRABBED
Definition: SDL_video.h:130
@ SDL_WINDOW_FULLSCREEN
Definition: SDL_video.h:110
@ SDL_WINDOW_MAXIMIZED
Definition: SDL_video.h:117
@ SDL_WINDOW_METAL
Definition: SDL_video.h:132
@ SDL_WINDOW_HIDDEN
Definition: SDL_video.h:113
@ SDL_WINDOW_MOUSE_GRABBED
Definition: SDL_video.h:118
@ SDL_WINDOW_POPUP_MENU
Definition: SDL_video.h:129
@ SDL_WINDOW_BORDERLESS
Definition: SDL_video.h:114
@ SDL_WINDOW_INPUT_FOCUS
Definition: SDL_video.h:119
int SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode)
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)
void * SDL_EGLSurface
Definition: SDL_video.h:186
SDL_GLcontextFlag
Definition: SDL_video.h:239
@ SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG
Definition: SDL_video.h:241
@ SDL_GL_CONTEXT_RESET_ISOLATION_FLAG
Definition: SDL_video.h:243
@ SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG
Definition: SDL_video.h:242
@ SDL_GL_CONTEXT_DEBUG_FLAG
Definition: SDL_video.h:240
int SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data)
int SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h)
const SDL_DisplayMode * SDL_GetWindowFullscreenMode(SDL_Window *window)
const SDL_DisplayMode * SDL_GetCurrentDisplayMode(SDL_DisplayID displayID)
int SDL_GL_SwapWindow(SDL_Window *window)
SDL_Window * SDL_CreateWindowFrom(const void *data)
int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
int SDL_SetWindowPosition(SDL_Window *window, int x, int y)
int SDL_GL_DeleteContext(SDL_GLContext context)
SDL_GLprofile
Definition: SDL_video.h:232
@ SDL_GL_CONTEXT_PROFILE_COMPATIBILITY
Definition: SDL_video.h:234
@ SDL_GL_CONTEXT_PROFILE_ES
Definition: SDL_video.h:235
@ SDL_GL_CONTEXT_PROFILE_CORE
Definition: SDL_video.h:233
SDL_DisplayOrientation SDL_GetDisplayOrientation(SDL_DisplayID displayID)
int SDL_GL_LoadLibrary(const char *path)
int SDL_DestroyWindow(SDL_Window *window)
int SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen)
int SDL_GetWindowSize(SDL_Window *window, int *w, int *h)
int SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed)
SDL_DisplayOrientation
Display orientation.
Definition: SDL_video.h:158
@ SDL_ORIENTATION_LANDSCAPE
Definition: SDL_video.h:160
@ SDL_ORIENTATION_PORTRAIT
Definition: SDL_video.h:162
@ SDL_ORIENTATION_PORTRAIT_FLIPPED
Definition: SDL_video.h:163
@ SDL_ORIENTATION_LANDSCAPE_FLIPPED
Definition: SDL_video.h:161
@ SDL_ORIENTATION_UNKNOWN
Definition: SDL_video.h:159
SDL_GLContextResetNotification
Definition: SDL_video.h:253
@ SDL_GL_CONTEXT_RESET_NO_NOTIFICATION
Definition: SDL_video.h:254
@ SDL_GL_CONTEXT_RESET_LOSE_CONTEXT
Definition: SDL_video.h:255
int SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity)
The structure that defines a display mode.
Definition: SDL_video.h:56
float display_scale
Definition: SDL_video.h:63
void * driverdata
Definition: SDL_video.h:65
SDL_DisplayID displayID
Definition: SDL_video.h:57
Uint32 format
Definition: SDL_video.h:58
float refresh_rate
Definition: SDL_video.h:64
A collection of pixels used in software blitting.
Definition: SDL_surface.h:73