🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2178 lines
79 KiB

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