SDL_video.h 82 KB

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