SDL_video.h 101 KB

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