SDL_video.h 70 KB

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