SDL_video.h 101 KB

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