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