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