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