SDL_video.h 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447
  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. * If the window is currently in the fullscreen state, this request is
  584. * asynchronous on some windowing systems and the new mode dimensions may not
  585. * be applied immediately upon the return of this function. If an immediate
  586. * change is required, call SDL_SyncWindow() to block until the changes have
  587. * taken effect.
  588. *
  589. * When the new mode takes effect, an SDL_EVENT_WINDOW_RESIZED and/or an
  590. * SDL_EVENT_WINDOOW_PIXEL_SIZE_CHANGED event will be emitted with the new
  591. * mode dimensions.
  592. *
  593. * \param window the window to affect
  594. * \param mode a pointer to the display mode to use, which can be NULL for
  595. * desktop mode, or one of the fullscreen modes returned by
  596. * SDL_GetFullscreenDisplayModes().
  597. * \returns 0 on success or a negative error code on failure; call
  598. * SDL_GetError() for more information.
  599. *
  600. * \since This function is available since SDL 3.0.0.
  601. *
  602. * \sa SDL_GetWindowFullscreenMode
  603. * \sa SDL_SetWindowFullscreen
  604. * \sa SDL_SyncWindow
  605. */
  606. extern DECLSPEC int SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode);
  607. /**
  608. * Query the display mode to use when a window is visible at fullscreen.
  609. *
  610. * \param window the window to query
  611. * \returns a pointer to the fullscreen mode to use or NULL for desktop mode
  612. *
  613. * \since This function is available since SDL 3.0.0.
  614. *
  615. * \sa SDL_SetWindowFullscreenMode
  616. * \sa SDL_SetWindowFullscreen
  617. */
  618. extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetWindowFullscreenMode(SDL_Window *window);
  619. /**
  620. * Get the raw ICC profile data for the screen the window is currently on.
  621. *
  622. * Data returned should be freed with SDL_free.
  623. *
  624. * \param window the window to query
  625. * \param size the size of the ICC profile
  626. * \returns the raw ICC profile data on success or NULL on failure; call
  627. * SDL_GetError() for more information.
  628. *
  629. * \since This function is available since SDL 3.0.0.
  630. */
  631. extern DECLSPEC void *SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size);
  632. /**
  633. * Get the pixel format associated with the window.
  634. *
  635. * \param window the window to query
  636. * \returns the pixel format of the window on success or
  637. * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more
  638. * information.
  639. *
  640. * \since This function is available since SDL 3.0.0.
  641. */
  642. extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
  643. /**
  644. * Create a window with the specified dimensions and flags.
  645. *
  646. * `flags` may be any of the following OR'd together:
  647. *
  648. * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution
  649. * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context
  650. * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance
  651. * - `SDL_WINDOW_METAL`: window usable with a Metal instance
  652. * - `SDL_WINDOW_HIDDEN`: window is not visible
  653. * - `SDL_WINDOW_BORDERLESS`: no window decoration
  654. * - `SDL_WINDOW_RESIZABLE`: window can be resized
  655. * - `SDL_WINDOW_MINIMIZED`: window is minimized
  656. * - `SDL_WINDOW_MAXIMIZED`: window is maximized
  657. * - `SDL_WINDOW_MOUSE_GRABBED`: window has grabbed mouse focus
  658. *
  659. * The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set.
  660. *
  661. * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
  662. * property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
  663. *
  664. * The window pixel size may differ from its window coordinate size if the
  665. * window is on a high pixel density display. Use SDL_GetWindowSize() to query
  666. * the client area's size in window coordinates, and
  667. * SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to query the
  668. * drawable size in pixels. Note that the drawable size can vary after the
  669. * window is created and should be queried again if you get an
  670. * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event.
  671. *
  672. * If the window is created with any of the SDL_WINDOW_OPENGL or
  673. * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
  674. * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the
  675. * corresponding UnloadLibrary function is called by SDL_DestroyWindow().
  676. *
  677. * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
  678. * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail.
  679. *
  680. * If SDL_WINDOW_METAL is specified on an OS that does not support Metal,
  681. * SDL_CreateWindow() will fail.
  682. *
  683. * On non-Apple devices, SDL requires you to either not link to the Vulkan
  684. * loader or link to a dynamic library version. This limitation may be removed
  685. * in a future version of SDL.
  686. *
  687. * \param title the title of the window, in UTF-8 encoding
  688. * \param w the width of the window
  689. * \param h the height of the window
  690. * \param flags 0, or one or more SDL_WindowFlags OR'd together
  691. * \returns the window that was created or NULL on failure; call
  692. * SDL_GetError() for more information.
  693. *
  694. * \since This function is available since SDL 3.0.0.
  695. *
  696. * \sa SDL_CreatePopupWindow
  697. * \sa SDL_CreateWindowWithProperties
  698. * \sa SDL_DestroyWindow
  699. */
  700. extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int w, int h, Uint32 flags);
  701. /**
  702. * Create a child popup window of the specified parent window.
  703. *
  704. * 'flags' **must** contain exactly one of the following: -
  705. * 'SDL_WINDOW_TOOLTIP': The popup window is a tooltip and will not pass any
  706. * input events. - 'SDL_WINDOW_POPUP_MENU': The popup window is a popup menu.
  707. * The topmost popup menu will implicitly gain the keyboard focus.
  708. *
  709. * The following flags are not relevant to popup window creation and will be
  710. * ignored:
  711. *
  712. * - 'SDL_WINDOW_MINIMIZED'
  713. * - 'SDL_WINDOW_MAXIMIZED'
  714. * - 'SDL_WINDOW_FULLSCREEN'
  715. * - 'SDL_WINDOW_BORDERLESS'
  716. *
  717. * The parent parameter **must** be non-null and a valid window. The parent of
  718. * a popup window can be either a regular, toplevel window, or another popup
  719. * window.
  720. *
  721. * Popup windows cannot be minimized, maximized, made fullscreen, raised,
  722. * flash, be made a modal window, be the parent of a modal window, or grab the
  723. * mouse and/or keyboard. Attempts to do so will fail.
  724. *
  725. * Popup windows implicitly do not have a border/decorations and do not appear
  726. * on the taskbar/dock or in lists of windows such as alt-tab menus.
  727. *
  728. * If a parent window is hidden, any child popup windows will be recursively
  729. * hidden as well. Child popup windows not explicitly hidden will be restored
  730. * when the parent is shown.
  731. *
  732. * If the parent window is destroyed, any child popup windows will be
  733. * recursively destroyed as well.
  734. *
  735. * \param parent the parent of the window, must not be NULL
  736. * \param offset_x the x position of the popup window relative to the origin
  737. * of the parent
  738. * \param offset_y the y position of the popup window relative to the origin
  739. * of the parent window
  740. * \param w the width of the window
  741. * \param h the height of the window
  742. * \param flags SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP MENU, and zero or more
  743. * additional SDL_WindowFlags OR'd together.
  744. * \returns the window that was created or NULL on failure; call
  745. * SDL_GetError() for more information.
  746. *
  747. * \since This function is available since SDL 3.0.0.
  748. *
  749. * \sa SDL_CreateWindow
  750. * \sa SDL_CreateWindowWithProperties
  751. * \sa SDL_DestroyWindow
  752. * \sa SDL_GetWindowParent
  753. */
  754. extern DECLSPEC SDL_Window *SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, Uint32 flags);
  755. /**
  756. * Create a window with the specified properties.
  757. *
  758. * These are the supported properties:
  759. *
  760. * - "always-on-top" (boolean) - true if the window should be always on top
  761. * - "borderless" (boolean) - true if the window has no window decoration
  762. * - "focusable" (boolean) - true if the window should accept keyboard input
  763. * (defaults true)
  764. * - "fullscreen" (boolean) - true if the window should start in fullscreen
  765. * mode at desktop resolution
  766. * - "height" (number) - the height of the window
  767. * - "hidden" (boolean) - true if the window should start hidden
  768. * - "high-pixel-density" (boolean) - true if the window uses a high pixel
  769. * density buffer if possible
  770. * - "maximized" (boolean) - true if the window should start maximized
  771. * - "menu" (boolean) - true if the window is a popup menu
  772. * - "metal" (string) - true if the window will be used with Metal rendering
  773. * - "minimized" (boolean) - true if the window should start minimized
  774. * - "mouse-grabbed" (boolean) - true if the window starts with grabbed mouse
  775. * focus
  776. * - "opengl" (boolean) - true if the window will be used with OpenGL
  777. * rendering
  778. * - "parent" (pointer) - an SDL_Window that will be the parent of this
  779. * window, required for windows with the "toolip" and "menu" properties
  780. * - "resizable" (boolean) - true if the window should be resizable
  781. * - "title" (string) - the title of the window, in UTF-8 encoding
  782. * - "transparent" (string) - true if the window show transparent in the areas
  783. * with alpha of 0
  784. * - "tooltip" (boolean) - true if the window is a tooltip
  785. * - "utility" (boolean) - true if the window is a utility window, not showing
  786. * in the task bar and window list
  787. * - "vulkan" (string) - true if the window will be used with Vulkan rendering
  788. * - "width" (number) - the width of the window
  789. * - "x" (number) - the x position of the window, or `SDL_WINDOWPOS_CENTERED`,
  790. * defaults to `SDL_WINDOWPOS_UNDEFINED`. This is relative to the parent for
  791. * windows with the "parent" property set.
  792. * - "y" (number) - the y position of the window, or `SDL_WINDOWPOS_CENTERED`,
  793. * defaults to `SDL_WINDOWPOS_UNDEFINED`. This is relative to the parent for
  794. * windows with the "parent" property set.
  795. *
  796. * On macOS:
  797. *
  798. * - "cocoa.window" (pointer) - the (__unsafe_unretained) NSWindow associated
  799. * with the window, if you want to wrap an existing window.
  800. * - "cocoa.view" (pointer) - the (__unsafe_unretained) NSView associated with
  801. * the window, defaults to [window contentView]
  802. *
  803. * On Windows:
  804. *
  805. * - "win32.hwnd" (pointer) - the HWND associated with the window, if you want
  806. * to wrap an existing window.
  807. * - "win32.pixel_format_hwnd" (pointer) - optional, another window to share
  808. * pixel format with, useful for OpenGL windows
  809. *
  810. * On X11:
  811. *
  812. * - "x11.window" (number) - the X11 Window associated with the window, if you
  813. * want to wrap an existing window.
  814. *
  815. * The SDL_Window is implicitly shown if the "hidden" property is not set.
  816. *
  817. * Windows with the "tooltip" and "menu" properties are popup windows and have
  818. * the behaviors and guidelines outlined in `SDL_CreatePopupWindow()`.
  819. *
  820. * \param props the properties to use
  821. * \returns the window that was created or NULL on failure; call
  822. * SDL_GetError() for more information.
  823. *
  824. * \since This function is available since SDL 3.0.0.
  825. *
  826. * \sa SDL_CreateWindow
  827. * \sa SDL_DestroyWindow
  828. */
  829. extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowWithProperties(SDL_PropertiesID props);
  830. /**
  831. * Get the numeric ID of a window.
  832. *
  833. * The numeric ID is what SDL_WindowEvent references, and is necessary to map
  834. * these events to specific SDL_Window objects.
  835. *
  836. * \param window the window to query
  837. * \returns the ID of the window on success or 0 on failure; call
  838. * SDL_GetError() for more information.
  839. *
  840. * \since This function is available since SDL 3.0.0.
  841. *
  842. * \sa SDL_GetWindowFromID
  843. */
  844. extern DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window);
  845. /**
  846. * Get a window from a stored ID.
  847. *
  848. * The numeric ID is what SDL_WindowEvent references, and is necessary to map
  849. * these events to specific SDL_Window objects.
  850. *
  851. * \param id the ID of the window
  852. * \returns the window associated with `id` or NULL if it doesn't exist; call
  853. * SDL_GetError() for more information.
  854. *
  855. * \since This function is available since SDL 3.0.0.
  856. *
  857. * \sa SDL_GetWindowID
  858. */
  859. extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowFromID(SDL_WindowID id);
  860. /**
  861. * Get parent of a window.
  862. *
  863. * \param window the window to query
  864. * \returns the parent of the window on success or NULL if the window has no
  865. * parent.
  866. *
  867. * \since This function is available since SDL 3.0.0.
  868. *
  869. * \sa SDL_CreatePopupWindow
  870. */
  871. extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowParent(SDL_Window *window);
  872. /**
  873. * Get the properties associated with a window.
  874. *
  875. * The following read-only properties are provided by SDL:
  876. *
  877. * On Android:
  878. *
  879. * ```
  880. * "SDL.window.android.window" (pointer) - the ANativeWindow associated with the window
  881. * "SDL.window.android.surface" (pointer) - the EGLSurface associated with the window
  882. * ```
  883. *
  884. * On iOS:
  885. *
  886. * ```
  887. * "SDL.window.uikit.window" (pointer) - the (__unsafe_unretained) UIWindow associated with the window
  888. * "SDL.window.uikit.metal_view_tag" (number) - the NSInteger tag assocated with metal views on the window
  889. * ```
  890. *
  891. * On KMS/DRM:
  892. *
  893. * ```
  894. * "SDL.window.kmsdrm.dev_index" (number) - the device index associated with the window (e.g. the X in /dev/dri/cardX)
  895. * "SDL.window.kmsdrm.drm_fd" (number) - the DRM FD associated with the window
  896. * "SDL.window.kmsdrm.gbm_dev" (pointer) - the GBM device associated with the window
  897. * ```
  898. *
  899. * On macOS:
  900. *
  901. * ```
  902. * "SDL.window.cocoa.window" (pointer) - the (__unsafe_unretained) NSWindow associated with the window
  903. * "SDL.window.cocoa.metal_view_tag" (number) - the NSInteger tag assocated with metal views on the window
  904. * ```
  905. *
  906. * On Vivante:
  907. *
  908. * ```
  909. * "SDL.window.vivante.display" (pointer) - the EGLNativeDisplayType associated with the window
  910. * "SDL.window.vivante.window" (pointer) - the EGLNativeWindowType associated with the window
  911. * "SDL.window.vivante.surface" (pointer) - the EGLSurface associated with the window
  912. * ```
  913. *
  914. * On UWP:
  915. *
  916. * ```
  917. * "SDL.window.winrt.window" (pointer) - the IInspectable CoreWindow associated with the window
  918. * ```
  919. *
  920. * On Windows:
  921. *
  922. * ```
  923. * "SDL.window.win32.hwnd" (pointer) - the HWND associated with the window
  924. * "SDL.window.win32.hdc" (pointer) - the HDC associated with the window
  925. * "SDL.window.win32.instance" (pointer) - the HINSTANCE associated with the window
  926. * ```
  927. *
  928. * On Wayland:
  929. *
  930. * ```
  931. * "SDL.window.wayland.registry" (pointer) - the wl_registry associated with the window
  932. * "SDL.window.wayland.display" (pointer) - the wl_display associated with the window
  933. * "SDL.window.wayland.surface" (pointer) - the wl_surface associated with the window
  934. * "SDL.window.wayland.egl_window" (pointer) - the wl_egl_window associated with the window
  935. * "SDL.window.wayland.xdg_surface" (pointer) - the xdg_surface associated with the window
  936. * "SDL.window.wayland.xdg_toplevel" (pointer) - the xdg_toplevel role associated with the window
  937. * "SDL.window.wayland.xdg_popup" (pointer) - the xdg_popup role associated with the window
  938. * "SDL.window.wayland.xdg_positioner" (pointer) - the xdg_positioner associated with the window, in popup mode
  939. * ```
  940. *
  941. * Note: The xdg_* window objects do not internally persist across window
  942. * show/hide calls. They will be null if the window is hidden and must be
  943. * queried each time it is shown.
  944. *
  945. * On X11:
  946. *
  947. * ```
  948. * "SDL.window.x11.display" (pointer) - the X11 Display associated with the window
  949. * "SDL.window.x11.screen" (number) - the screen number associated with the window
  950. * "SDL.window.x11.window" (number) - the X11 Window associated with the window
  951. * ```
  952. *
  953. * \param window the window to query
  954. * \returns a valid property ID on success or 0 on failure; call
  955. * SDL_GetError() for more information.
  956. *
  957. * \since This function is available since SDL 3.0.0.
  958. *
  959. * \sa SDL_GetProperty
  960. * \sa SDL_SetProperty
  961. */
  962. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window *window);
  963. /**
  964. * Get the window flags.
  965. *
  966. * \param window the window to query
  967. * \returns a mask of the SDL_WindowFlags associated with `window`
  968. *
  969. * \since This function is available since SDL 3.0.0.
  970. *
  971. * \sa SDL_CreateWindow
  972. * \sa SDL_HideWindow
  973. * \sa SDL_MaximizeWindow
  974. * \sa SDL_MinimizeWindow
  975. * \sa SDL_SetWindowFullscreen
  976. * \sa SDL_SetWindowGrab
  977. * \sa SDL_ShowWindow
  978. */
  979. extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window *window);
  980. /**
  981. * Set the title of a window.
  982. *
  983. * This string is expected to be in UTF-8 encoding.
  984. *
  985. * \param window the window to change
  986. * \param title the desired window title in UTF-8 format
  987. * \returns 0 on success or a negative error code on failure; call
  988. * SDL_GetError() for more information.
  989. *
  990. * \since This function is available since SDL 3.0.0.
  991. *
  992. * \sa SDL_GetWindowTitle
  993. */
  994. extern DECLSPEC int SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
  995. /**
  996. * Get the title of a window.
  997. *
  998. * \param window the window to query
  999. * \returns the title of the window in UTF-8 format or "" if there is no
  1000. * title.
  1001. *
  1002. * \since This function is available since SDL 3.0.0.
  1003. *
  1004. * \sa SDL_SetWindowTitle
  1005. */
  1006. extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window *window);
  1007. /**
  1008. * Set the icon for a window.
  1009. *
  1010. * \param window the window to change
  1011. * \param icon an SDL_Surface structure containing the icon for the window
  1012. * \returns 0 on success or a negative error code on failure; call
  1013. * SDL_GetError() for more information.
  1014. *
  1015. * \since This function is available since SDL 3.0.0.
  1016. */
  1017. extern DECLSPEC int SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
  1018. /**
  1019. * Request that the window's position be set.
  1020. *
  1021. * If, at the time of this request, the window is in a fixed-size state such
  1022. * as maximized, this request may be deferred until the window returns to a
  1023. * resizable state.
  1024. *
  1025. * This can be used to reposition fullscreen-desktop windows onto a different
  1026. * display, however, exclusive fullscreen windows are locked to a specific
  1027. * display and can only be repositioned programmatically via
  1028. * SDL_SetWindowFullscreenMode().
  1029. *
  1030. * On some windowing systems this request is asynchronous and the new
  1031. * coordinates may not have have been applied immediately upon the return of
  1032. * this function. If an immediate change is required, call SDL_SyncWindow() to
  1033. * block until the changes have taken effect.
  1034. *
  1035. * When the window position changes, an SDL_EVENT_WINDOW_MOVED event will be
  1036. * emitted with the window's new coordinates. Note that the new coordinates
  1037. * may not match the exact coordinates requested, as some windowing systems
  1038. * can restrict the position of the window in certain scenarios (e.g.
  1039. * constraining the position so the window is always within desktop bounds).
  1040. * Additionally, as this is just a request, it can be denied by the windowing
  1041. * system.
  1042. *
  1043. * \param window the window to reposition
  1044. * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
  1045. * `SDL_WINDOWPOS_UNDEFINED`
  1046. * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
  1047. * `SDL_WINDOWPOS_UNDEFINED`
  1048. * \returns 0 on success or a negative error code on failure; call
  1049. * SDL_GetError() for more information.
  1050. *
  1051. * \since This function is available since SDL 3.0.0.
  1052. *
  1053. * \sa SDL_GetWindowPosition
  1054. * \sa SDL_SyncWindow
  1055. */
  1056. extern DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
  1057. /**
  1058. * Get the position of a window.
  1059. *
  1060. * This is the current position of the window as last reported by the
  1061. * windowing system.
  1062. *
  1063. * If you do not need the value for one of the positions a NULL may be passed
  1064. * in the `x` or `y` parameter.
  1065. *
  1066. * \param window the window to query
  1067. * \param x a pointer filled in with the x position of the window, may be NULL
  1068. * \param y a pointer filled in with the y position of the window, may be NULL
  1069. * \returns 0 on success or a negative error code on failure; call
  1070. * SDL_GetError() for more information.
  1071. *
  1072. * \since This function is available since SDL 3.0.0.
  1073. *
  1074. * \sa SDL_SetWindowPosition
  1075. */
  1076. extern DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
  1077. /**
  1078. * Request that the size of a window's client area be set.
  1079. *
  1080. * NULL can safely be passed as the `w` or `h` parameter if the width or
  1081. * height value is not desired.
  1082. *
  1083. * If, at the time of this request, the window in a fixed-size state, such as
  1084. * maximized or fullscreen, the request will be deferred until the window
  1085. * exits this state and becomes resizable again.
  1086. *
  1087. * To change the fullscreen mode of a window, use
  1088. * SDL_SetWindowFullscreenMode()
  1089. *
  1090. * On some windowing systems, this request is asynchronous and the new window
  1091. * size may not have have been applied immediately upon the return of this
  1092. * function. If an immediate change is required, call SDL_SyncWindow() to
  1093. * block until the changes have taken effect.
  1094. *
  1095. * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be
  1096. * emitted with the new window dimensions. Note that the new dimensions may
  1097. * not match the exact size requested, as some windowing systems can restrict
  1098. * the window size in certain scenarios (e.g. constraining the size of the
  1099. * content area to remain within the usable desktop bounds). Additionally, as
  1100. * this is just a request, it can be denied by the windowing system.
  1101. *
  1102. * \param window the window to change
  1103. * \param w the width of the window, must be > 0
  1104. * \param h the height of the window, must be > 0
  1105. * \returns 0 on success or a negative error code on failure; call
  1106. * SDL_GetError() for more information.
  1107. *
  1108. * \since This function is available since SDL 3.0.0.
  1109. *
  1110. * \sa SDL_GetWindowSize
  1111. * \sa SDL_SetWindowFullscreenMode
  1112. * \sa SDL_SyncWindow
  1113. */
  1114. extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
  1115. /**
  1116. * Get the size of a window's client area.
  1117. *
  1118. * NULL can safely be passed as the `w` or `h` parameter if the width or
  1119. * height value is not desired.
  1120. *
  1121. * The window pixel size may differ from its window coordinate size if the
  1122. * window is on a high pixel density display. Use SDL_GetWindowSizeInPixels()
  1123. * or SDL_GetRenderOutputSize() to get the real client area size in pixels.
  1124. *
  1125. * \param window the window to query the width and height from
  1126. * \param w a pointer filled in with the width of the window, may be NULL
  1127. * \param h a pointer filled in with the height of the window, may be NULL
  1128. * \returns 0 on success or a negative error code on failure; call
  1129. * SDL_GetError() for more information.
  1130. *
  1131. * \since This function is available since SDL 3.0.0.
  1132. *
  1133. * \sa SDL_GetRenderOutputSize
  1134. * \sa SDL_GetWindowSizeInPixels
  1135. * \sa SDL_SetWindowSize
  1136. */
  1137. extern DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
  1138. /**
  1139. * Get the size of a window's borders (decorations) around the client area.
  1140. *
  1141. * Note: If this function fails (returns -1), the size values will be
  1142. * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the
  1143. * window in question was borderless.
  1144. *
  1145. * Note: This function may fail on systems where the window has not yet been
  1146. * decorated by the display server (for example, immediately after calling
  1147. * SDL_CreateWindow). It is recommended that you wait at least until the
  1148. * window has been presented and composited, so that the window system has a
  1149. * chance to decorate the window and provide the border dimensions to SDL.
  1150. *
  1151. * This function also returns -1 if getting the information is not supported.
  1152. *
  1153. * \param window the window to query the size values of the border
  1154. * (decorations) from
  1155. * \param top pointer to variable for storing the size of the top border; NULL
  1156. * is permitted
  1157. * \param left pointer to variable for storing the size of the left border;
  1158. * NULL is permitted
  1159. * \param bottom pointer to variable for storing the size of the bottom
  1160. * border; NULL is permitted
  1161. * \param right pointer to variable for storing the size of the right border;
  1162. * NULL is permitted
  1163. * \returns 0 on success or a negative error code on failure; call
  1164. * SDL_GetError() for more information.
  1165. *
  1166. * \since This function is available since SDL 3.0.0.
  1167. *
  1168. * \sa SDL_GetWindowSize
  1169. */
  1170. extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
  1171. /**
  1172. * Get the size of a window's client area, in pixels.
  1173. *
  1174. * \param window the window from which the drawable size should be queried
  1175. * \param w a pointer to variable for storing the width in pixels, may be NULL
  1176. * \param h a pointer to variable for storing the height in pixels, may be
  1177. * NULL
  1178. * \returns 0 on success or a negative error code on failure; call
  1179. * SDL_GetError() for more information.
  1180. *
  1181. * \since This function is available since SDL 3.0.0.
  1182. *
  1183. * \sa SDL_CreateWindow
  1184. * \sa SDL_GetWindowSize
  1185. */
  1186. extern DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
  1187. /**
  1188. * Set the minimum size of a window's client area.
  1189. *
  1190. * \param window the window to change
  1191. * \param min_w the minimum width of the window, or 0 for no limit
  1192. * \param min_h the minimum height of the window, or 0 for no limit
  1193. * \returns 0 on success or a negative error code on failure; call
  1194. * SDL_GetError() for more information.
  1195. *
  1196. * \since This function is available since SDL 3.0.0.
  1197. *
  1198. * \sa SDL_GetWindowMinimumSize
  1199. * \sa SDL_SetWindowMaximumSize
  1200. */
  1201. extern DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
  1202. /**
  1203. * Get the minimum size of a window's client area.
  1204. *
  1205. * \param window the window to query
  1206. * \param w a pointer filled in with the minimum width of the window, may be
  1207. * NULL
  1208. * \param h a pointer filled in with the minimum height of the window, may be
  1209. * NULL
  1210. * \returns 0 on success or a negative error code on failure; call
  1211. * SDL_GetError() for more information.
  1212. *
  1213. * \since This function is available since SDL 3.0.0.
  1214. *
  1215. * \sa SDL_GetWindowMaximumSize
  1216. * \sa SDL_SetWindowMinimumSize
  1217. */
  1218. extern DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
  1219. /**
  1220. * Set the maximum size of a window's client area.
  1221. *
  1222. * \param window the window to change
  1223. * \param max_w the maximum width of the window, or 0 for no limit
  1224. * \param max_h the maximum height of the window, or 0 for no limit
  1225. * \returns 0 on success or a negative error code on failure; call
  1226. * SDL_GetError() for more information.
  1227. *
  1228. * \since This function is available since SDL 3.0.0.
  1229. *
  1230. * \sa SDL_GetWindowMaximumSize
  1231. * \sa SDL_SetWindowMinimumSize
  1232. */
  1233. extern DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
  1234. /**
  1235. * Get the maximum size of a window's client area.
  1236. *
  1237. * \param window the window to query
  1238. * \param w a pointer filled in with the maximum width of the window, may be
  1239. * NULL
  1240. * \param h a pointer filled in with the maximum height of the window, may be
  1241. * NULL
  1242. * \returns 0 on success or a negative error code on failure; call
  1243. * SDL_GetError() for more information.
  1244. *
  1245. * \since This function is available since SDL 3.0.0.
  1246. *
  1247. * \sa SDL_GetWindowMinimumSize
  1248. * \sa SDL_SetWindowMaximumSize
  1249. */
  1250. extern DECLSPEC int SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
  1251. /**
  1252. * Set the border state of a window.
  1253. *
  1254. * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add
  1255. * or remove the border from the actual window. This is a no-op if the
  1256. * window's border already matches the requested state.
  1257. *
  1258. * You can't change the border state of a fullscreen window.
  1259. *
  1260. * \param window the window of which to change the border state
  1261. * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border
  1262. * \returns 0 on success or a negative error code on failure; call
  1263. * SDL_GetError() for more information.
  1264. *
  1265. * \since This function is available since SDL 3.0.0.
  1266. *
  1267. * \sa SDL_GetWindowFlags
  1268. */
  1269. extern DECLSPEC int SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
  1270. /**
  1271. * Set the user-resizable state of a window.
  1272. *
  1273. * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and
  1274. * allow/disallow user resizing of the window. This is a no-op if the window's
  1275. * resizable state already matches the requested state.
  1276. *
  1277. * You can't change the resizable state of a fullscreen window.
  1278. *
  1279. * \param window the window of which to change the resizable state
  1280. * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow
  1281. * \returns 0 on success or a negative error code on failure; call
  1282. * SDL_GetError() for more information.
  1283. *
  1284. * \since This function is available since SDL 3.0.0.
  1285. *
  1286. * \sa SDL_GetWindowFlags
  1287. */
  1288. extern DECLSPEC int SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
  1289. /**
  1290. * Set the window to always be above the others.
  1291. *
  1292. * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This
  1293. * will bring the window to the front and keep the window above the rest.
  1294. *
  1295. * \param window The window of which to change the always on top state
  1296. * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
  1297. * disable
  1298. * \returns 0 on success or a negative error code on failure; call
  1299. * SDL_GetError() for more information.
  1300. *
  1301. * \since This function is available since SDL 3.0.0.
  1302. *
  1303. * \sa SDL_GetWindowFlags
  1304. */
  1305. extern DECLSPEC int SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
  1306. /**
  1307. * Show a window.
  1308. *
  1309. * \param window the window to show
  1310. * \returns 0 on success or a negative error code on failure; call
  1311. * SDL_GetError() for more information.
  1312. *
  1313. * \since This function is available since SDL 3.0.0.
  1314. *
  1315. * \sa SDL_HideWindow
  1316. * \sa SDL_RaiseWindow
  1317. */
  1318. extern DECLSPEC int SDLCALL SDL_ShowWindow(SDL_Window *window);
  1319. /**
  1320. * Hide a window.
  1321. *
  1322. * \param window the window to hide
  1323. * \returns 0 on success or a negative error code on failure; call
  1324. * SDL_GetError() for more information.
  1325. *
  1326. * \since This function is available since SDL 3.0.0.
  1327. *
  1328. * \sa SDL_ShowWindow
  1329. */
  1330. extern DECLSPEC int SDLCALL SDL_HideWindow(SDL_Window *window);
  1331. /**
  1332. * Raise a window above other windows and set the input focus.
  1333. *
  1334. * \param window the window to raise
  1335. * \returns 0 on success or a negative error code on failure; call
  1336. * SDL_GetError() for more information.
  1337. *
  1338. * \since This function is available since SDL 3.0.0.
  1339. */
  1340. extern DECLSPEC int SDLCALL SDL_RaiseWindow(SDL_Window *window);
  1341. /**
  1342. * Request that the window be made as large as possible.
  1343. *
  1344. * Non-resizable windows can't be maximized. The window must have the
  1345. * SDL_WINDOW_RESIZABLE flag set, or this will have no effect.
  1346. *
  1347. * On some windowing systems this request is asynchronous and the new window
  1348. * state may not have have been applied immediately upon the return of this
  1349. * function. If an immediate change is required, call SDL_SyncWindow() to
  1350. * block until the changes have taken effect.
  1351. *
  1352. * When the window state changes, an SDL_EVENT_WINDOW_MAXIMIZED event will be
  1353. * emitted. Note that, as this is just a request, the windowing system can
  1354. * deny the state change.
  1355. *
  1356. * When maximizing a window, whether the constraints set via
  1357. * SDL_SetWindowMaximumSize() are honored depends on the policy of the window
  1358. * manager. Win32 and macOS enforce the constraints when maximizing, while X11
  1359. * and Wayland window managers may vary.
  1360. *
  1361. * \param window the window to maximize
  1362. * \returns 0 on success or a negative error code on failure; call
  1363. * SDL_GetError() for more information.
  1364. *
  1365. * \since This function is available since SDL 3.0.0.
  1366. *
  1367. * \sa SDL_MinimizeWindow
  1368. * \sa SDL_RestoreWindow
  1369. * \sa SDL_SyncWindow
  1370. */
  1371. extern DECLSPEC int SDLCALL SDL_MaximizeWindow(SDL_Window *window);
  1372. /**
  1373. * Request that the window be minimized to an iconic representation.
  1374. *
  1375. * On some windowing systems this request is asynchronous and the new window
  1376. * state may not have have been applied immediately upon the return of this
  1377. * function. If an immediate change is required, call SDL_SyncWindow() to
  1378. * block until the changes have taken effect.
  1379. *
  1380. * When the window state changes, an SDL_EVENT_WINDOW_MINIMIZED event will be
  1381. * emitted. Note that, as this is just a request, the windowing system can
  1382. * deny the state change.
  1383. *
  1384. * \param window the window to minimize
  1385. * \returns 0 on success or a negative error code on failure; call
  1386. * SDL_GetError() for more information.
  1387. *
  1388. * \since This function is available since SDL 3.0.0.
  1389. *
  1390. * \sa SDL_MaximizeWindow
  1391. * \sa SDL_RestoreWindow
  1392. * \sa SDL_SyncWindow
  1393. */
  1394. extern DECLSPEC int SDLCALL SDL_MinimizeWindow(SDL_Window *window);
  1395. /**
  1396. * Request that the size and position of a minimized or maximized window be
  1397. * restored.
  1398. *
  1399. * On some windowing systems this request is asynchronous and the new window
  1400. * state may not have have been applied immediately upon the return of this
  1401. * function. If an immediate change is required, call SDL_SyncWindow() to
  1402. * block until the changes have taken effect.
  1403. *
  1404. * When the window state changes, an SDL_EVENT_WINDOW_RESTORED event will be
  1405. * emitted. Note that, as this is just a request, the windowing system can
  1406. * deny the state change.
  1407. *
  1408. * \param window the window to restore
  1409. * \returns 0 on success or a negative error code on failure; call
  1410. * SDL_GetError() for more information.
  1411. *
  1412. * \since This function is available since SDL 3.0.0.
  1413. *
  1414. * \sa SDL_MaximizeWindow
  1415. * \sa SDL_MinimizeWindow
  1416. * \sa SDL_SyncWindow
  1417. */
  1418. extern DECLSPEC int SDLCALL SDL_RestoreWindow(SDL_Window *window);
  1419. /**
  1420. * Request that the window's fullscreen state be changed.
  1421. *
  1422. * By default a window in fullscreen state uses fullscreen desktop mode, but a
  1423. * specific display mode can be set using SDL_SetWindowFullscreenMode().
  1424. *
  1425. * On some windowing systems this request is asynchronous and the new
  1426. * fullscreen state may not have have been applied immediately upon the return
  1427. * of this function. If an immediate change is required, call SDL_SyncWindow()
  1428. * to block until the changes have taken effect.
  1429. *
  1430. * When the window state changes, an SDL_EVENT_WINDOW_ENTER_FULLSCREEN or
  1431. * SDL_EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this
  1432. * is just a request, it can be denied by the windowing system.
  1433. *
  1434. * \param window the window to change
  1435. * \param fullscreen SDL_TRUE for fullscreen mode, SDL_FALSE for windowed mode
  1436. * \returns 0 on success or a negative error code on failure; call
  1437. * SDL_GetError() for more information.
  1438. *
  1439. * \since This function is available since SDL 3.0.0.
  1440. *
  1441. * \sa SDL_GetWindowFullscreenMode
  1442. * \sa SDL_SetWindowFullscreenMode
  1443. * \sa SDL_SyncWindow
  1444. */
  1445. extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen);
  1446. /**
  1447. * Block until any pending window state is finalized.
  1448. *
  1449. * On asynchronous windowing systems, this acts as a synchronization barrier
  1450. * for pending window state. It will attempt to wait until any pending window
  1451. * state has been applied and is guaranteed to return within finite time. Note
  1452. * that for how long it can potentially block depends on the underlying window
  1453. * system, as window state changes may involve somewhat lengthy animations
  1454. * that must complete before the window is in its final requested state.
  1455. *
  1456. * On windowing systems where changes are immediate, this does nothing.
  1457. *
  1458. * \param window the window for which to wait for the pending state to be
  1459. * applied
  1460. * \returns 0 on success, a positive value if the operation timed out before
  1461. * the window was in the requested state, or a negative error code on
  1462. * failure; call SDL_GetError() for more information.
  1463. *
  1464. * \since This function is available since SDL 3.0.0.
  1465. *
  1466. * \sa SDL_SetWindowSize
  1467. * \sa SDL_SetWindowPosition
  1468. * \sa SDL_SetWindowFullscreen
  1469. * \sa SDL_MinimizeWindow
  1470. * \sa SDL_MaximizeWindow
  1471. * \sa SDL_RestoreWindow
  1472. */
  1473. extern DECLSPEC int SDLCALL SDL_SyncWindow(SDL_Window *window);
  1474. /**
  1475. * Return whether the window has a surface associated with it.
  1476. *
  1477. * \param window the window to query
  1478. * \returns SDL_TRUE if there is a surface associated with the window, or
  1479. * SDL_FALSE otherwise.
  1480. *
  1481. * \since This function is available since SDL 3.0.0.
  1482. *
  1483. * \sa SDL_GetWindowSurface
  1484. */
  1485. extern DECLSPEC SDL_bool SDLCALL SDL_HasWindowSurface(SDL_Window *window);
  1486. /**
  1487. * Get the SDL surface associated with the window.
  1488. *
  1489. * A new surface will be created with the optimal format for the window, if
  1490. * necessary. This surface will be freed when the window is destroyed. Do not
  1491. * free this surface.
  1492. *
  1493. * This surface will be invalidated if the window is resized. After resizing a
  1494. * window this function must be called again to return a valid surface.
  1495. *
  1496. * You may not combine this with 3D or the rendering API on this window.
  1497. *
  1498. * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`.
  1499. *
  1500. * \param window the window to query
  1501. * \returns the surface associated with the window, or NULL on failure; call
  1502. * SDL_GetError() for more information.
  1503. *
  1504. * \since This function is available since SDL 3.0.0.
  1505. *
  1506. * \sa SDL_DestroyWindowSurface
  1507. * \sa SDL_HasWindowSurface
  1508. * \sa SDL_UpdateWindowSurface
  1509. * \sa SDL_UpdateWindowSurfaceRects
  1510. */
  1511. extern DECLSPEC SDL_Surface *SDLCALL SDL_GetWindowSurface(SDL_Window *window);
  1512. /**
  1513. * Copy the window surface to the screen.
  1514. *
  1515. * This is the function you use to reflect any changes to the surface on the
  1516. * screen.
  1517. *
  1518. * This function is equivalent to the SDL 1.2 API SDL_Flip().
  1519. *
  1520. * \param window the window to update
  1521. * \returns 0 on success or a negative error code on failure; call
  1522. * SDL_GetError() for more information.
  1523. *
  1524. * \since This function is available since SDL 3.0.0.
  1525. *
  1526. * \sa SDL_GetWindowSurface
  1527. * \sa SDL_UpdateWindowSurfaceRects
  1528. */
  1529. extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
  1530. /**
  1531. * Copy areas of the window surface to the screen.
  1532. *
  1533. * This is the function you use to reflect changes to portions of the surface
  1534. * on the screen.
  1535. *
  1536. * This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
  1537. *
  1538. * \param window the window to update
  1539. * \param rects an array of SDL_Rect structures representing areas of the
  1540. * surface to copy, in pixels
  1541. * \param numrects the number of rectangles
  1542. * \returns 0 on success or a negative error code on failure; call
  1543. * SDL_GetError() for more information.
  1544. *
  1545. * \since This function is available since SDL 3.0.0.
  1546. *
  1547. * \sa SDL_GetWindowSurface
  1548. * \sa SDL_UpdateWindowSurface
  1549. */
  1550. extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
  1551. /**
  1552. * Destroy the surface associated with the window.
  1553. *
  1554. * \param window the window to update
  1555. * \returns 0 on success or a negative error code on failure; call
  1556. * SDL_GetError() for more information.
  1557. *
  1558. * \since This function is available since SDL 3.0.0.
  1559. *
  1560. * \sa SDL_GetWindowSurface
  1561. * \sa SDL_HasWindowSurface
  1562. */
  1563. extern DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
  1564. /**
  1565. * Set a window's input grab mode.
  1566. *
  1567. * When input is grabbed, the mouse is confined to the window. This function
  1568. * will also grab the keyboard if `SDL_HINT_GRAB_KEYBOARD` is set. To grab the
  1569. * keyboard without also grabbing the mouse, use SDL_SetWindowKeyboardGrab().
  1570. *
  1571. * If the caller enables a grab while another window is currently grabbed, the
  1572. * other window loses its grab in favor of the caller's window.
  1573. *
  1574. * \param window the window for which the input grab mode should be set
  1575. * \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input
  1576. * \returns 0 on success or a negative error code on failure; call
  1577. * SDL_GetError() for more information.
  1578. *
  1579. * \since This function is available since SDL 3.0.0.
  1580. *
  1581. * \sa SDL_GetGrabbedWindow
  1582. * \sa SDL_GetWindowGrab
  1583. */
  1584. extern DECLSPEC int SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
  1585. /**
  1586. * Set a window's keyboard grab mode.
  1587. *
  1588. * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or
  1589. * the Meta/Super key. Note that not all system keyboard shortcuts can be
  1590. * captured by applications (one example is Ctrl+Alt+Del on Windows).
  1591. *
  1592. * This is primarily intended for specialized applications such as VNC clients
  1593. * or VM frontends. Normal games should not use keyboard grab.
  1594. *
  1595. * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the
  1596. * window is full-screen to ensure the user is not trapped in your
  1597. * application. If you have a custom keyboard shortcut to exit fullscreen
  1598. * mode, you may suppress this behavior with
  1599. * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`.
  1600. *
  1601. * If the caller enables a grab while another window is currently grabbed, the
  1602. * other window loses its grab in favor of the caller's window.
  1603. *
  1604. * \param window The window for which the keyboard grab mode should be set.
  1605. * \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
  1606. * \returns 0 on success or a negative error code on failure; call
  1607. * SDL_GetError() for more information.
  1608. *
  1609. * \since This function is available since SDL 3.0.0.
  1610. *
  1611. * \sa SDL_GetWindowKeyboardGrab
  1612. * \sa SDL_SetWindowMouseGrab
  1613. * \sa SDL_SetWindowGrab
  1614. */
  1615. extern DECLSPEC int SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
  1616. /**
  1617. * Set a window's mouse grab mode.
  1618. *
  1619. * Mouse grab confines the mouse cursor to the window.
  1620. *
  1621. * \param window The window for which the mouse grab mode should be set.
  1622. * \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release.
  1623. * \returns 0 on success or a negative error code on failure; call
  1624. * SDL_GetError() for more information.
  1625. *
  1626. * \since This function is available since SDL 3.0.0.
  1627. *
  1628. * \sa SDL_GetWindowMouseGrab
  1629. * \sa SDL_SetWindowKeyboardGrab
  1630. * \sa SDL_SetWindowGrab
  1631. */
  1632. extern DECLSPEC int SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
  1633. /**
  1634. * Get a window's input grab mode.
  1635. *
  1636. * \param window the window to query
  1637. * \returns SDL_TRUE if input is grabbed, SDL_FALSE otherwise.
  1638. *
  1639. * \since This function is available since SDL 3.0.0.
  1640. *
  1641. * \sa SDL_SetWindowGrab
  1642. */
  1643. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window *window);
  1644. /**
  1645. * Get a window's keyboard grab mode.
  1646. *
  1647. * \param window the window to query
  1648. * \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise.
  1649. *
  1650. * \since This function is available since SDL 3.0.0.
  1651. *
  1652. * \sa SDL_SetWindowKeyboardGrab
  1653. * \sa SDL_GetWindowGrab
  1654. */
  1655. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window *window);
  1656. /**
  1657. * Get a window's mouse grab mode.
  1658. *
  1659. * \param window the window to query
  1660. * \returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise.
  1661. *
  1662. * \since This function is available since SDL 3.0.0.
  1663. *
  1664. * \sa SDL_SetWindowKeyboardGrab
  1665. * \sa SDL_GetWindowGrab
  1666. */
  1667. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window *window);
  1668. /**
  1669. * Get the window that currently has an input grab enabled.
  1670. *
  1671. * \returns the window if input is grabbed or NULL otherwise.
  1672. *
  1673. * \since This function is available since SDL 3.0.0.
  1674. *
  1675. * \sa SDL_GetWindowGrab
  1676. * \sa SDL_SetWindowGrab
  1677. */
  1678. extern DECLSPEC SDL_Window *SDLCALL SDL_GetGrabbedWindow(void);
  1679. /**
  1680. * Confines the cursor to the specified area of a window.
  1681. *
  1682. * Note that this does NOT grab the cursor, it only defines the area a cursor
  1683. * is restricted to when the window has mouse focus.
  1684. *
  1685. * \param window The window that will be associated with the barrier.
  1686. * \param rect A rectangle area in window-relative coordinates. If NULL the
  1687. * barrier for the specified window will be destroyed.
  1688. * \returns 0 on success or a negative error code on failure; call
  1689. * SDL_GetError() for more information.
  1690. *
  1691. * \since This function is available since SDL 3.0.0.
  1692. *
  1693. * \sa SDL_GetWindowMouseRect
  1694. * \sa SDL_SetWindowMouseGrab
  1695. */
  1696. extern DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
  1697. /**
  1698. * Get the mouse confinement rectangle of a window.
  1699. *
  1700. * \param window The window to query
  1701. * \returns A pointer to the mouse confinement rectangle of a window, or NULL
  1702. * if there isn't one.
  1703. *
  1704. * \since This function is available since SDL 3.0.0.
  1705. *
  1706. * \sa SDL_SetWindowMouseRect
  1707. */
  1708. extern DECLSPEC const SDL_Rect *SDLCALL SDL_GetWindowMouseRect(SDL_Window *window);
  1709. /**
  1710. * Set the opacity for a window.
  1711. *
  1712. * The parameter `opacity` will be clamped internally between 0.0f
  1713. * (transparent) and 1.0f (opaque).
  1714. *
  1715. * This function also returns -1 if setting the opacity isn't supported.
  1716. *
  1717. * \param window the window which will be made transparent or opaque
  1718. * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque)
  1719. * \returns 0 on success or a negative error code on failure; call
  1720. * SDL_GetError() for more information.
  1721. *
  1722. * \since This function is available since SDL 3.0.0.
  1723. *
  1724. * \sa SDL_GetWindowOpacity
  1725. */
  1726. extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity);
  1727. /**
  1728. * Get the opacity of a window.
  1729. *
  1730. * If transparency isn't supported on this platform, opacity will be reported
  1731. * as 1.0f without error.
  1732. *
  1733. * The parameter `opacity` is ignored if it is NULL.
  1734. *
  1735. * This function also returns -1 if an invalid window was provided.
  1736. *
  1737. * \param window the window to get the current opacity value from
  1738. * \param out_opacity the float filled in (0.0f - transparent, 1.0f - opaque)
  1739. * \returns 0 on success or a negative error code on failure; call
  1740. * SDL_GetError() for more information.
  1741. *
  1742. * \since This function is available since SDL 3.0.0.
  1743. *
  1744. * \sa SDL_SetWindowOpacity
  1745. */
  1746. extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity);
  1747. /**
  1748. * Set the window as a modal for another window.
  1749. *
  1750. * \param modal_window the window that should be set modal
  1751. * \param parent_window the parent window for the modal window
  1752. * \returns 0 on success or a negative error code on failure; call
  1753. * SDL_GetError() for more information.
  1754. *
  1755. * \since This function is available since SDL 3.0.0.
  1756. */
  1757. extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window);
  1758. /**
  1759. * Explicitly set input focus to the window.
  1760. *
  1761. * You almost certainly want SDL_RaiseWindow() instead of this function. Use
  1762. * this with caution, as you might give focus to a window that is completely
  1763. * obscured by other windows.
  1764. *
  1765. * \param window the window that should get the input focus
  1766. * \returns 0 on success or a negative error code on failure; call
  1767. * SDL_GetError() for more information.
  1768. *
  1769. * \since This function is available since SDL 3.0.0.
  1770. *
  1771. * \sa SDL_RaiseWindow
  1772. */
  1773. extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window *window);
  1774. /**
  1775. * Set whether the window may have input focus.
  1776. *
  1777. * \param window the window to set focusable state
  1778. * \param focusable SDL_TRUE to allow input focus, SDL_FALSE to not allow
  1779. * input focus
  1780. * \returns 0 on success or a negative error code on failure; call
  1781. * SDL_GetError() for more information.
  1782. *
  1783. * \since This function is available since SDL 3.0.0.
  1784. */
  1785. extern DECLSPEC int SDLCALL SDL_SetWindowFocusable(SDL_Window *window, SDL_bool focusable);
  1786. /**
  1787. * Display the system-level window menu.
  1788. *
  1789. * This default window menu is provided by the system and on some platforms
  1790. * provides functionality for setting or changing privileged state on the
  1791. * window, such as moving it between workspaces or displays, or toggling the
  1792. * always-on-top property.
  1793. *
  1794. * On platforms or desktops where this is unsupported, this function does
  1795. * nothing.
  1796. *
  1797. * \param window the window for which the menu will be displayed
  1798. * \param x the x coordinate of the menu, relative to the origin (top-left) of
  1799. * the client area
  1800. * \param y the y coordinate of the menu, relative to the origin (top-left) of
  1801. * the client area
  1802. * \returns 0 on success or a negative error code on failure; call
  1803. * SDL_GetError() for more information.
  1804. *
  1805. * \since This function is available since SDL 3.0.0.
  1806. */
  1807. extern DECLSPEC int SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
  1808. /**
  1809. * Possible return values from the SDL_HitTest callback.
  1810. *
  1811. * \sa SDL_HitTest
  1812. */
  1813. typedef enum
  1814. {
  1815. SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */
  1816. SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */
  1817. SDL_HITTEST_RESIZE_TOPLEFT,
  1818. SDL_HITTEST_RESIZE_TOP,
  1819. SDL_HITTEST_RESIZE_TOPRIGHT,
  1820. SDL_HITTEST_RESIZE_RIGHT,
  1821. SDL_HITTEST_RESIZE_BOTTOMRIGHT,
  1822. SDL_HITTEST_RESIZE_BOTTOM,
  1823. SDL_HITTEST_RESIZE_BOTTOMLEFT,
  1824. SDL_HITTEST_RESIZE_LEFT
  1825. } SDL_HitTestResult;
  1826. /**
  1827. * Callback used for hit-testing.
  1828. *
  1829. * \param win the SDL_Window where hit-testing was set on
  1830. * \param area an SDL_Point which should be hit-tested
  1831. * \param data what was passed as `callback_data` to SDL_SetWindowHitTest()
  1832. * \returns an SDL_HitTestResult value.
  1833. *
  1834. * \sa SDL_SetWindowHitTest
  1835. */
  1836. typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win,
  1837. const SDL_Point *area,
  1838. void *data);
  1839. /**
  1840. * Provide a callback that decides if a window region has special properties.
  1841. *
  1842. * Normally windows are dragged and resized by decorations provided by the
  1843. * system window manager (a title bar, borders, etc), but for some apps, it
  1844. * makes sense to drag them from somewhere else inside the window itself; for
  1845. * example, one might have a borderless window that wants to be draggable from
  1846. * any part, or simulate its own title bar, etc.
  1847. *
  1848. * This function lets the app provide a callback that designates pieces of a
  1849. * given window as special. This callback is run during event processing if we
  1850. * need to tell the OS to treat a region of the window specially; the use of
  1851. * this callback is known as "hit testing."
  1852. *
  1853. * Mouse input may not be delivered to your application if it is within a
  1854. * special area; the OS will often apply that input to moving the window or
  1855. * resizing the window and not deliver it to the application.
  1856. *
  1857. * Specifying NULL for a callback disables hit-testing. Hit-testing is
  1858. * disabled by default.
  1859. *
  1860. * Platforms that don't support this functionality will return -1
  1861. * unconditionally, even if you're attempting to disable hit-testing.
  1862. *
  1863. * Your callback may fire at any time, and its firing does not indicate any
  1864. * specific behavior (for example, on Windows, this certainly might fire when
  1865. * the OS is deciding whether to drag your window, but it fires for lots of
  1866. * other reasons, too, some unrelated to anything you probably care about _and
  1867. * when the mouse isn't actually at the location it is testing_). Since this
  1868. * can fire at any time, you should try to keep your callback efficient,
  1869. * devoid of allocations, etc.
  1870. *
  1871. * \param window the window to set hit-testing on
  1872. * \param callback the function to call when doing a hit-test
  1873. * \param callback_data an app-defined void pointer passed to **callback**
  1874. * \returns 0 on success or a negative error code on failure; call
  1875. * SDL_GetError() for more information.
  1876. *
  1877. * \since This function is available since SDL 3.0.0.
  1878. */
  1879. extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
  1880. /**
  1881. * Request a window to demand attention from the user.
  1882. *
  1883. * \param window the window to be flashed
  1884. * \param operation the flash operation
  1885. * \returns 0 on success or a negative error code on failure; call
  1886. * SDL_GetError() for more information.
  1887. *
  1888. * \since This function is available since SDL 3.0.0.
  1889. */
  1890. extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
  1891. /**
  1892. * Destroy a window.
  1893. *
  1894. * If `window` is NULL, this function will return immediately after setting
  1895. * the SDL error message to "Invalid window". See SDL_GetError().
  1896. *
  1897. * \param window the window to destroy
  1898. *
  1899. * \since This function is available since SDL 3.0.0.
  1900. *
  1901. * \sa SDL_CreatePopupWindow
  1902. * \sa SDL_CreateWindow
  1903. * \sa SDL_CreateWindowWithProperties
  1904. */
  1905. extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
  1906. /**
  1907. * Check whether the screensaver is currently enabled.
  1908. *
  1909. * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2
  1910. * the screensaver was enabled by default.
  1911. *
  1912. * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`.
  1913. *
  1914. * \returns SDL_TRUE if the screensaver is enabled, SDL_FALSE if it is
  1915. * disabled.
  1916. *
  1917. * \since This function is available since SDL 3.0.0.
  1918. *
  1919. * \sa SDL_DisableScreenSaver
  1920. * \sa SDL_EnableScreenSaver
  1921. */
  1922. extern DECLSPEC SDL_bool SDLCALL SDL_ScreenSaverEnabled(void);
  1923. /**
  1924. * Allow the screen to be blanked by a screen saver.
  1925. *
  1926. * \returns 0 on success or a negative error code on failure; call
  1927. * SDL_GetError() for more information.
  1928. *
  1929. * \since This function is available since SDL 3.0.0.
  1930. *
  1931. * \sa SDL_DisableScreenSaver
  1932. * \sa SDL_ScreenSaverEnabled
  1933. */
  1934. extern DECLSPEC int SDLCALL SDL_EnableScreenSaver(void);
  1935. /**
  1936. * Prevent the screen from being blanked by a screen saver.
  1937. *
  1938. * If you disable the screensaver, it is automatically re-enabled when SDL
  1939. * quits.
  1940. *
  1941. * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2
  1942. * the screensaver was enabled by default.
  1943. *
  1944. * \returns 0 on success or a negative error code on failure; call
  1945. * SDL_GetError() for more information.
  1946. *
  1947. * \since This function is available since SDL 3.0.0.
  1948. *
  1949. * \sa SDL_EnableScreenSaver
  1950. * \sa SDL_ScreenSaverEnabled
  1951. */
  1952. extern DECLSPEC int SDLCALL SDL_DisableScreenSaver(void);
  1953. /**
  1954. * \name OpenGL support functions
  1955. */
  1956. /* @{ */
  1957. /**
  1958. * Dynamically load an OpenGL library.
  1959. *
  1960. * This should be done after initializing the video driver, but before
  1961. * creating any OpenGL windows. If no OpenGL library is loaded, the default
  1962. * library will be loaded upon creation of the first OpenGL window.
  1963. *
  1964. * If you do this, you need to retrieve all of the GL functions used in your
  1965. * program from the dynamic library using SDL_GL_GetProcAddress().
  1966. *
  1967. * \param path the platform dependent OpenGL library name, or NULL to open the
  1968. * default OpenGL library
  1969. * \returns 0 on success or a negative error code on failure; call
  1970. * SDL_GetError() for more information.
  1971. *
  1972. * \since This function is available since SDL 3.0.0.
  1973. *
  1974. * \sa SDL_GL_GetProcAddress
  1975. * \sa SDL_GL_UnloadLibrary
  1976. */
  1977. extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
  1978. /**
  1979. * Get an OpenGL function by name.
  1980. *
  1981. * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all
  1982. * GL functions must be retrieved this way. Usually this is used to retrieve
  1983. * function pointers to OpenGL extensions.
  1984. *
  1985. * There are some quirks to looking up OpenGL functions that require some
  1986. * extra care from the application. If you code carefully, you can handle
  1987. * these quirks without any platform-specific code, though:
  1988. *
  1989. * - On Windows, function pointers are specific to the current GL context;
  1990. * this means you need to have created a GL context and made it current
  1991. * before calling SDL_GL_GetProcAddress(). If you recreate your context or
  1992. * create a second context, you should assume that any existing function
  1993. * pointers aren't valid to use with it. This is (currently) a
  1994. * Windows-specific limitation, and in practice lots of drivers don't suffer
  1995. * this limitation, but it is still the way the wgl API is documented to
  1996. * work and you should expect crashes if you don't respect it. Store a copy
  1997. * of the function pointers that comes and goes with context lifespan.
  1998. * - On X11, function pointers returned by this function are valid for any
  1999. * context, and can even be looked up before a context is created at all.
  2000. * This means that, for at least some common OpenGL implementations, if you
  2001. * look up a function that doesn't exist, you'll get a non-NULL result that
  2002. * is _NOT_ safe to call. You must always make sure the function is actually
  2003. * available for a given GL context before calling it, by checking for the
  2004. * existence of the appropriate extension with SDL_GL_ExtensionSupported(),
  2005. * or verifying that the version of OpenGL you're using offers the function
  2006. * as core functionality.
  2007. * - Some OpenGL drivers, on all platforms, *will* return NULL if a function
  2008. * isn't supported, but you can't count on this behavior. Check for
  2009. * extensions you use, and if you get a NULL anyway, act as if that
  2010. * extension wasn't available. This is probably a bug in the driver, but you
  2011. * can code defensively for this scenario anyhow.
  2012. * - Just because you're on Linux/Unix, don't assume you'll be using X11.
  2013. * Next-gen display servers are waiting to replace it, and may or may not
  2014. * make the same promises about function pointers.
  2015. * - OpenGL function pointers must be declared `APIENTRY` as in the example
  2016. * code. This will ensure the proper calling convention is followed on
  2017. * platforms where this matters (Win32) thereby avoiding stack corruption.
  2018. *
  2019. * \param proc the name of an OpenGL function
  2020. * \returns a pointer to the named OpenGL function. The returned pointer
  2021. * should be cast to the appropriate function signature.
  2022. *
  2023. * \since This function is available since SDL 3.0.0.
  2024. *
  2025. * \sa SDL_GL_ExtensionSupported
  2026. * \sa SDL_GL_LoadLibrary
  2027. * \sa SDL_GL_UnloadLibrary
  2028. */
  2029. extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc);
  2030. /**
  2031. * Get an EGL library function by name.
  2032. *
  2033. * If an EGL library is loaded, this function allows applications to get entry
  2034. * points for EGL functions. This is useful to provide to an EGL API and
  2035. * extension loader.
  2036. *
  2037. * \param proc the name of an EGL function
  2038. * \returns a pointer to the named EGL function. The returned pointer should
  2039. * be cast to the appropriate function signature.
  2040. *
  2041. * \since This function is available since SDL 3.0.0.
  2042. *
  2043. * \sa SDL_GL_GetCurrentEGLDisplay
  2044. */
  2045. extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
  2046. /**
  2047. * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
  2048. *
  2049. * \since This function is available since SDL 3.0.0.
  2050. *
  2051. * \sa SDL_GL_LoadLibrary
  2052. */
  2053. extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
  2054. /**
  2055. * Check if an OpenGL extension is supported for the current context.
  2056. *
  2057. * This function operates on the current GL context; you must have created a
  2058. * context and it must be current before calling this function. Do not assume
  2059. * that all contexts you create will have the same set of extensions
  2060. * available, or that recreating an existing context will offer the same
  2061. * extensions again.
  2062. *
  2063. * While it's probably not a massive overhead, this function is not an O(1)
  2064. * operation. Check the extensions you care about after creating the GL
  2065. * context and save that information somewhere instead of calling the function
  2066. * every time you need to know.
  2067. *
  2068. * \param extension the name of the extension to check
  2069. * \returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise.
  2070. *
  2071. * \since This function is available since SDL 3.0.0.
  2072. */
  2073. extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension);
  2074. /**
  2075. * Reset all previously set OpenGL context attributes to their default values.
  2076. *
  2077. * \since This function is available since SDL 3.0.0.
  2078. *
  2079. * \sa SDL_GL_GetAttribute
  2080. * \sa SDL_GL_SetAttribute
  2081. */
  2082. extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
  2083. /**
  2084. * Set an OpenGL window attribute before window creation.
  2085. *
  2086. * This function sets the OpenGL attribute `attr` to `value`. The requested
  2087. * attributes should be set before creating an OpenGL window. You should use
  2088. * SDL_GL_GetAttribute() to check the values after creating the OpenGL
  2089. * context, since the values obtained can differ from the requested ones.
  2090. *
  2091. * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to set
  2092. * \param value the desired value for the attribute
  2093. * \returns 0 on success or a negative error code on failure; call
  2094. * SDL_GetError() for more information.
  2095. *
  2096. * \since This function is available since SDL 3.0.0.
  2097. *
  2098. * \sa SDL_GL_GetAttribute
  2099. * \sa SDL_GL_ResetAttributes
  2100. */
  2101. extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
  2102. /**
  2103. * Get the actual value for an attribute from the current context.
  2104. *
  2105. * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to get
  2106. * \param value a pointer filled in with the current value of `attr`
  2107. * \returns 0 on success or a negative error code on failure; call
  2108. * SDL_GetError() for more information.
  2109. *
  2110. * \since This function is available since SDL 3.0.0.
  2111. *
  2112. * \sa SDL_GL_ResetAttributes
  2113. * \sa SDL_GL_SetAttribute
  2114. */
  2115. extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
  2116. /**
  2117. * Create an OpenGL context for an OpenGL window, and make it current.
  2118. *
  2119. * Windows users new to OpenGL should note that, for historical reasons, GL
  2120. * functions added after OpenGL version 1.1 are not available by default.
  2121. * Those functions must be loaded at run-time, either with an OpenGL
  2122. * extension-handling library or with SDL_GL_GetProcAddress() and its related
  2123. * functions.
  2124. *
  2125. * SDL_GLContext is an alias for `void *`. It's opaque to the application.
  2126. *
  2127. * \param window the window to associate with the context
  2128. * \returns the OpenGL context associated with `window` or NULL on error; call
  2129. * SDL_GetError() for more details.
  2130. *
  2131. * \since This function is available since SDL 3.0.0.
  2132. *
  2133. * \sa SDL_GL_DeleteContext
  2134. * \sa SDL_GL_MakeCurrent
  2135. */
  2136. extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window);
  2137. /**
  2138. * Set up an OpenGL context for rendering into an OpenGL window.
  2139. *
  2140. * The context must have been created with a compatible window.
  2141. *
  2142. * \param window the window to associate with the context
  2143. * \param context the OpenGL context to associate with the window
  2144. * \returns 0 on success or a negative error code on failure; call
  2145. * SDL_GetError() for more information.
  2146. *
  2147. * \since This function is available since SDL 3.0.0.
  2148. *
  2149. * \sa SDL_GL_CreateContext
  2150. */
  2151. extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
  2152. /**
  2153. * Get the currently active OpenGL window.
  2154. *
  2155. * \returns the currently active OpenGL window on success or NULL on failure;
  2156. * call SDL_GetError() for more information.
  2157. *
  2158. * \since This function is available since SDL 3.0.0.
  2159. */
  2160. extern DECLSPEC SDL_Window *SDLCALL SDL_GL_GetCurrentWindow(void);
  2161. /**
  2162. * Get the currently active OpenGL context.
  2163. *
  2164. * \returns the currently active OpenGL context or NULL on failure; call
  2165. * SDL_GetError() for more information.
  2166. *
  2167. * \since This function is available since SDL 3.0.0.
  2168. *
  2169. * \sa SDL_GL_MakeCurrent
  2170. */
  2171. extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
  2172. /**
  2173. * Get the currently active EGL display.
  2174. *
  2175. * \returns the currently active EGL display or NULL on failure; call
  2176. * SDL_GetError() for more information.
  2177. *
  2178. * \since This function is available since SDL 3.0.0.
  2179. */
  2180. extern DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentEGLDisplay(void);
  2181. /**
  2182. * Get the currently active EGL config.
  2183. *
  2184. * \returns the currently active EGL config or NULL on failure; call
  2185. * SDL_GetError() for more information.
  2186. *
  2187. * \since This function is available since SDL 3.0.0.
  2188. */
  2189. extern DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentEGLConfig(void);
  2190. /**
  2191. * Get the EGL surface associated with the window.
  2192. *
  2193. * \param window the window to query
  2194. * \returns the EGLSurface pointer associated with the window, or NULL on
  2195. * failure.
  2196. *
  2197. * \since This function is available since SDL 3.0.0.
  2198. */
  2199. extern DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowEGLSurface(SDL_Window *window);
  2200. /**
  2201. * Sets the callbacks for defining custom EGLAttrib arrays for EGL
  2202. * initialization.
  2203. *
  2204. * Each callback should return a pointer to an EGL attribute array terminated
  2205. * with EGL_NONE. Callbacks may return NULL pointers to signal an error, which
  2206. * will cause the SDL_CreateWindow process to fail gracefully.
  2207. *
  2208. * The arrays returned by each callback will be appended to the existing
  2209. * attribute arrays defined by SDL.
  2210. *
  2211. * NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes.
  2212. *
  2213. * \param platformAttribCallback Callback for attributes to pass to
  2214. * eglGetPlatformDisplay.
  2215. * \param surfaceAttribCallback Callback for attributes to pass to
  2216. * eglCreateSurface.
  2217. * \param contextAttribCallback Callback for attributes to pass to
  2218. * eglCreateContext.
  2219. *
  2220. * \since This function is available since SDL 3.0.0.
  2221. */
  2222. extern DECLSPEC void SDLCALL SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback,
  2223. SDL_EGLIntArrayCallback surfaceAttribCallback,
  2224. SDL_EGLIntArrayCallback contextAttribCallback);
  2225. /**
  2226. * Set the swap interval for the current OpenGL context.
  2227. *
  2228. * Some systems allow specifying -1 for the interval, to enable adaptive
  2229. * vsync. Adaptive vsync works the same as vsync, but if you've already missed
  2230. * the vertical retrace for a given frame, it swaps buffers immediately, which
  2231. * might be less jarring for the user during occasional framerate drops. If an
  2232. * application requests adaptive vsync and the system does not support it,
  2233. * this function will fail and return -1. In such a case, you should probably
  2234. * retry the call with 1 for the interval.
  2235. *
  2236. * Adaptive vsync is implemented for some glX drivers with
  2237. * GLX_EXT_swap_control_tear, and for some Windows drivers with
  2238. * WGL_EXT_swap_control_tear.
  2239. *
  2240. * Read more on the Khronos wiki:
  2241. * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
  2242. *
  2243. * \param interval 0 for immediate updates, 1 for updates synchronized with
  2244. * the vertical retrace, -1 for adaptive vsync
  2245. * \returns 0 on success or a negative error code on failure; call
  2246. * SDL_GetError() for more information.
  2247. *
  2248. * \since This function is available since SDL 3.0.0.
  2249. *
  2250. * \sa SDL_GL_GetSwapInterval
  2251. */
  2252. extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
  2253. /**
  2254. * Get the swap interval for the current OpenGL context.
  2255. *
  2256. * If the system can't determine the swap interval, or there isn't a valid
  2257. * current context, this function will set *interval to 0 as a safe default.
  2258. *
  2259. * \param interval Output interval value. 0 if there is no vertical retrace
  2260. * synchronization, 1 if the buffer swap is synchronized with
  2261. * the vertical retrace, and -1 if late swaps happen
  2262. * immediately instead of waiting for the next retrace
  2263. * \returns 0 on success or a negative error code on failure; call
  2264. * SDL_GetError() for more information.
  2265. *
  2266. * \since This function is available since SDL 3.0.0.
  2267. *
  2268. * \sa SDL_GL_SetSwapInterval
  2269. */
  2270. extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(int *interval);
  2271. /**
  2272. * Update a window with OpenGL rendering.
  2273. *
  2274. * This is used with double-buffered OpenGL contexts, which are the default.
  2275. *
  2276. * On macOS, make sure you bind 0 to the draw framebuffer before swapping the
  2277. * window, otherwise nothing will happen. If you aren't using
  2278. * glBindFramebuffer(), this is the default and you won't have to do anything
  2279. * extra.
  2280. *
  2281. * \param window the window to change
  2282. * \returns 0 on success or a negative error code on failure; call
  2283. * SDL_GetError() for more information.
  2284. *
  2285. * \since This function is available since SDL 3.0.0.
  2286. */
  2287. extern DECLSPEC int SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
  2288. /**
  2289. * Delete an OpenGL context.
  2290. *
  2291. * \param context the OpenGL context to be deleted
  2292. * \returns 0 on success or a negative error code on failure; call
  2293. * SDL_GetError() for more information.
  2294. *
  2295. * \since This function is available since SDL 3.0.0.
  2296. *
  2297. * \sa SDL_GL_CreateContext
  2298. */
  2299. extern DECLSPEC int SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
  2300. /* @} *//* OpenGL support functions */
  2301. /* Ends C function definitions when using C++ */
  2302. #ifdef __cplusplus
  2303. }
  2304. #endif
  2305. #include <SDL3/SDL_close_code.h>
  2306. #endif /* SDL_video_h_ */