1
0

SDL_video.h 140 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * # CategoryVideo
  20. *
  21. * SDL's video subsystem is largely interested in abstracting window
  22. * management from the underlying operating system. You can create windows,
  23. * manage them in various ways, set them fullscreen, and get events when
  24. * interesting things happen with them, such as the mouse or keyboard
  25. * interacting with a window.
  26. *
  27. * The video subsystem is also interested in abstracting away some
  28. * platform-specific differences in OpenGL: context creation, swapping
  29. * buffers, etc. This may be crucial to your app, but also you are not
  30. * required to use OpenGL at all. In fact, SDL can provide rendering to those
  31. * windows as well, either with an easy-to-use
  32. * [2D API](https://wiki.libsdl.org/SDL3/CategoryRender)
  33. * or with a more-powerful
  34. * [GPU API](https://wiki.libsdl.org/SDL3/CategoryGPU)
  35. * . Of course, it can simply get out of your way and give you the window
  36. * handles you need to use Vulkan, Direct3D, Metal, or whatever else you like
  37. * directly, too.
  38. *
  39. * The video subsystem covers a lot of functionality, out of necessity, so it
  40. * is worth perusing the list of functions just to see what's available, but
  41. * most apps can get by with simply creating a window and listening for
  42. * events, so start with SDL_CreateWindow() and SDL_PollEvent().
  43. */
  44. #ifndef SDL_video_h_
  45. #define SDL_video_h_
  46. #include <SDL3/SDL_stdinc.h>
  47. #include <SDL3/SDL_error.h>
  48. #include <SDL3/SDL_pixels.h>
  49. #include <SDL3/SDL_properties.h>
  50. #include <SDL3/SDL_rect.h>
  51. #include <SDL3/SDL_surface.h>
  52. #include <SDL3/SDL_begin_code.h>
  53. /* Set up for C function definitions, even when using C++ */
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. /**
  58. * This is a unique ID for a display for the time it is connected to the
  59. * system, and is never reused for the lifetime of the application.
  60. *
  61. * If the display is disconnected and reconnected, it will get a new ID.
  62. *
  63. * The value 0 is an invalid ID.
  64. *
  65. * \since This datatype is available since SDL 3.2.0.
  66. */
  67. typedef Uint32 SDL_DisplayID;
  68. /**
  69. * This is a unique ID for a window.
  70. *
  71. * The value 0 is an invalid ID.
  72. *
  73. * \since This datatype is available since SDL 3.2.0.
  74. */
  75. typedef Uint32 SDL_WindowID;
  76. /* Global video properties... */
  77. /**
  78. * The pointer to the global `wl_display` object used by the Wayland video
  79. * backend.
  80. *
  81. * Can be set before the video subsystem is initialized to import an external
  82. * `wl_display` object from an application or toolkit for use in SDL, or read
  83. * after initialization to export the `wl_display` used by the Wayland video
  84. * backend. Setting this property after the video subsystem has been
  85. * initialized has no effect, and reading it when the video subsystem is
  86. * uninitialized will either return the user provided value, if one was set
  87. * prior to initialization, or NULL. See docs/README-wayland.md for more
  88. * information.
  89. *
  90. * \since This macro is available since SDL 3.2.0.
  91. */
  92. #define SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER "SDL.video.wayland.wl_display"
  93. /**
  94. * System theme.
  95. *
  96. * \since This enum is available since SDL 3.2.0.
  97. */
  98. typedef enum SDL_SystemTheme
  99. {
  100. SDL_SYSTEM_THEME_UNKNOWN, /**< Unknown system theme */
  101. SDL_SYSTEM_THEME_LIGHT, /**< Light colored system theme */
  102. SDL_SYSTEM_THEME_DARK /**< Dark colored system theme */
  103. } SDL_SystemTheme;
  104. /**
  105. * Internal display mode data.
  106. *
  107. * This lives as a field in SDL_DisplayMode, as opaque data.
  108. *
  109. * \since This struct is available since SDL 3.2.0.
  110. *
  111. * \sa SDL_DisplayMode
  112. */
  113. typedef struct SDL_DisplayModeData SDL_DisplayModeData;
  114. /**
  115. * The structure that defines a display mode.
  116. *
  117. * \since This struct is available since SDL 3.2.0.
  118. *
  119. * \sa SDL_GetFullscreenDisplayModes
  120. * \sa SDL_GetDesktopDisplayMode
  121. * \sa SDL_GetCurrentDisplayMode
  122. * \sa SDL_SetWindowFullscreenMode
  123. * \sa SDL_GetWindowFullscreenMode
  124. */
  125. typedef struct SDL_DisplayMode
  126. {
  127. SDL_DisplayID displayID; /**< the display this mode is associated with */
  128. SDL_PixelFormat format; /**< pixel format */
  129. int w; /**< width */
  130. int h; /**< height */
  131. float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */
  132. float refresh_rate; /**< refresh rate (or 0.0f for unspecified) */
  133. int refresh_rate_numerator; /**< precise refresh rate numerator (or 0 for unspecified) */
  134. int refresh_rate_denominator; /**< precise refresh rate denominator */
  135. SDL_DisplayModeData *internal; /**< Private */
  136. } SDL_DisplayMode;
  137. /**
  138. * Display orientation values; the way a display is rotated.
  139. *
  140. * \since This enum is available since SDL 3.2.0.
  141. */
  142. typedef enum SDL_DisplayOrientation
  143. {
  144. SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */
  145. SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */
  146. SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */
  147. SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */
  148. SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */
  149. } SDL_DisplayOrientation;
  150. /**
  151. * The struct used as an opaque handle to a window.
  152. *
  153. * \since This struct is available since SDL 3.2.0.
  154. *
  155. * \sa SDL_CreateWindow
  156. */
  157. typedef struct SDL_Window SDL_Window;
  158. /**
  159. * The flags on a window.
  160. *
  161. * These cover a lot of true/false, or on/off, window state. Some of it is
  162. * immutable after being set through SDL_CreateWindow(), some of it can be
  163. * changed on existing windows by the app, and some of it might be altered by
  164. * the user or system outside of the app's control.
  165. *
  166. * When creating windows with `SDL_WINDOW_RESIZABLE`, SDL will constrain
  167. * resizable windows to the dimensions recommended by the compositor to fit it
  168. * within the usable desktop space, although some compositors will do this
  169. * automatically without intervention as well. Use `SDL_SetWindowResizable`
  170. * after creation instead if you wish to create a window with a specific size.
  171. *
  172. * \since This datatype is available since SDL 3.2.0.
  173. *
  174. * \sa SDL_GetWindowFlags
  175. */
  176. typedef Uint64 SDL_WindowFlags;
  177. #define SDL_WINDOW_FULLSCREEN SDL_UINT64_C(0x0000000000000001) /**< window is in fullscreen mode */
  178. #define SDL_WINDOW_OPENGL SDL_UINT64_C(0x0000000000000002) /**< window usable with OpenGL context */
  179. #define SDL_WINDOW_OCCLUDED SDL_UINT64_C(0x0000000000000004) /**< window is occluded */
  180. #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 */
  181. #define SDL_WINDOW_BORDERLESS SDL_UINT64_C(0x0000000000000010) /**< no window decoration */
  182. #define SDL_WINDOW_RESIZABLE SDL_UINT64_C(0x0000000000000020) /**< window can be resized */
  183. #define SDL_WINDOW_MINIMIZED SDL_UINT64_C(0x0000000000000040) /**< window is minimized */
  184. #define SDL_WINDOW_MAXIMIZED SDL_UINT64_C(0x0000000000000080) /**< window is maximized */
  185. #define SDL_WINDOW_MOUSE_GRABBED SDL_UINT64_C(0x0000000000000100) /**< window has grabbed mouse input */
  186. #define SDL_WINDOW_INPUT_FOCUS SDL_UINT64_C(0x0000000000000200) /**< window has input focus */
  187. #define SDL_WINDOW_MOUSE_FOCUS SDL_UINT64_C(0x0000000000000400) /**< window has mouse focus */
  188. #define SDL_WINDOW_EXTERNAL SDL_UINT64_C(0x0000000000000800) /**< window not created by SDL */
  189. #define SDL_WINDOW_MODAL SDL_UINT64_C(0x0000000000001000) /**< window is modal */
  190. #define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */
  191. #define SDL_WINDOW_MOUSE_CAPTURE SDL_UINT64_C(0x0000000000004000) /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
  192. #define SDL_WINDOW_MOUSE_RELATIVE_MODE SDL_UINT64_C(0x0000000000008000) /**< window has relative mode enabled */
  193. #define SDL_WINDOW_ALWAYS_ON_TOP SDL_UINT64_C(0x0000000000010000) /**< window should always be above others */
  194. #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 */
  195. #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 */
  196. #define SDL_WINDOW_POPUP_MENU SDL_UINT64_C(0x0000000000080000) /**< window should be treated as a popup menu, requires a parent window */
  197. #define SDL_WINDOW_KEYBOARD_GRABBED SDL_UINT64_C(0x0000000000100000) /**< window has grabbed keyboard input */
  198. #define SDL_WINDOW_FILL_DOCUMENT SDL_UINT64_C(0x0000000000200000) /**< window is in fill-document mode (Emscripten only), since SDL 3.4.0 */
  199. #define SDL_WINDOW_VULKAN SDL_UINT64_C(0x0000000010000000) /**< window usable for Vulkan surface */
  200. #define SDL_WINDOW_METAL SDL_UINT64_C(0x0000000020000000) /**< window usable for Metal view */
  201. #define SDL_WINDOW_TRANSPARENT SDL_UINT64_C(0x0000000040000000) /**< window with transparent buffer */
  202. #define SDL_WINDOW_NOT_FOCUSABLE SDL_UINT64_C(0x0000000080000000) /**< window should not be focusable */
  203. /**
  204. * A magic value used with SDL_WINDOWPOS_UNDEFINED.
  205. *
  206. * Generally this macro isn't used directly, but rather through
  207. * SDL_WINDOWPOS_UNDEFINED or SDL_WINDOWPOS_UNDEFINED_DISPLAY.
  208. *
  209. * \since This macro is available since SDL 3.2.0.
  210. *
  211. * \sa SDL_SetWindowPosition
  212. */
  213. #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
  214. /**
  215. * Used to indicate that you don't care what the window position is.
  216. *
  217. * If you _really_ don't care, SDL_WINDOWPOS_UNDEFINED is the same, but always
  218. * uses the primary display instead of specifying one.
  219. *
  220. * \param X the SDL_DisplayID of the display to use.
  221. *
  222. * \since This macro is available since SDL 3.2.0.
  223. *
  224. * \sa SDL_SetWindowPosition
  225. */
  226. #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
  227. /**
  228. * Used to indicate that you don't care what the window position/display is.
  229. *
  230. * This always uses the primary display.
  231. *
  232. * \since This macro is available since SDL 3.2.0.
  233. *
  234. * \sa SDL_SetWindowPosition
  235. */
  236. #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
  237. /**
  238. * A macro to test if the window position is marked as "undefined."
  239. *
  240. * \param X the window position value.
  241. *
  242. * \since This macro is available since SDL 3.2.0.
  243. *
  244. * \sa SDL_SetWindowPosition
  245. */
  246. #define SDL_WINDOWPOS_ISUNDEFINED(X) (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
  247. /**
  248. * A magic value used with SDL_WINDOWPOS_CENTERED.
  249. *
  250. * Generally this macro isn't used directly, but rather through
  251. * SDL_WINDOWPOS_CENTERED or SDL_WINDOWPOS_CENTERED_DISPLAY.
  252. *
  253. * \since This macro is available since SDL 3.2.0.
  254. *
  255. * \sa SDL_SetWindowPosition
  256. */
  257. #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
  258. /**
  259. * Used to indicate that the window position should be centered.
  260. *
  261. * SDL_WINDOWPOS_CENTERED is the same, but always uses the primary display
  262. * instead of specifying one.
  263. *
  264. * \param X the SDL_DisplayID of the display to use.
  265. *
  266. * \since This macro is available since SDL 3.2.0.
  267. *
  268. * \sa SDL_SetWindowPosition
  269. */
  270. #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
  271. /**
  272. * Used to indicate that the window position should be centered.
  273. *
  274. * This always uses the primary display.
  275. *
  276. * \since This macro is available since SDL 3.2.0.
  277. *
  278. * \sa SDL_SetWindowPosition
  279. */
  280. #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
  281. /**
  282. * A macro to test if the window position is marked as "centered."
  283. *
  284. * \param X the window position value.
  285. *
  286. * \since This macro is available since SDL 3.2.0.
  287. *
  288. * \sa SDL_GetWindowPosition
  289. */
  290. #define SDL_WINDOWPOS_ISCENTERED(X) \
  291. (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
  292. /**
  293. * Window flash operation.
  294. *
  295. * \since This enum is available since SDL 3.2.0.
  296. */
  297. typedef enum SDL_FlashOperation
  298. {
  299. SDL_FLASH_CANCEL, /**< Cancel any window flash state */
  300. SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */
  301. SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */
  302. } SDL_FlashOperation;
  303. /**
  304. * Window progress state
  305. *
  306. * \since This enum is available since SDL 3.2.8.
  307. */
  308. typedef enum SDL_ProgressState
  309. {
  310. SDL_PROGRESS_STATE_INVALID = -1, /**< An invalid progress state indicating an error; check SDL_GetError() */
  311. SDL_PROGRESS_STATE_NONE, /**< No progress bar is shown */
  312. SDL_PROGRESS_STATE_INDETERMINATE, /**< The progress bar is shown in a indeterminate state */
  313. SDL_PROGRESS_STATE_NORMAL, /**< The progress bar is shown in a normal state */
  314. SDL_PROGRESS_STATE_PAUSED, /**< The progress bar is shown in a paused state */
  315. SDL_PROGRESS_STATE_ERROR /**< The progress bar is shown in a state indicating the application had an error */
  316. } SDL_ProgressState;
  317. /**
  318. * An opaque handle to an OpenGL context.
  319. *
  320. * \since This datatype is available since SDL 3.2.0.
  321. *
  322. * \sa SDL_GL_CreateContext
  323. * \sa SDL_GL_SetAttribute
  324. * \sa SDL_GL_MakeCurrent
  325. * \sa SDL_GL_DestroyContext
  326. */
  327. typedef struct SDL_GLContextState *SDL_GLContext;
  328. /**
  329. * Opaque type for an EGL display.
  330. *
  331. * \since This datatype is available since SDL 3.2.0.
  332. */
  333. typedef void *SDL_EGLDisplay;
  334. /**
  335. * Opaque type for an EGL config.
  336. *
  337. * \since This datatype is available since SDL 3.2.0.
  338. */
  339. typedef void *SDL_EGLConfig;
  340. /**
  341. * Opaque type for an EGL surface.
  342. *
  343. * \since This datatype is available since SDL 3.2.0.
  344. */
  345. typedef void *SDL_EGLSurface;
  346. /**
  347. * An EGL attribute, used when creating an EGL context.
  348. *
  349. * \since This datatype is available since SDL 3.2.0.
  350. */
  351. typedef intptr_t SDL_EGLAttrib;
  352. /**
  353. * An EGL integer attribute, used when creating an EGL surface.
  354. *
  355. * \since This datatype is available since SDL 3.2.0.
  356. */
  357. typedef int SDL_EGLint;
  358. /**
  359. * EGL platform attribute initialization callback.
  360. *
  361. * This is called when SDL is attempting to create an EGL context, to let the
  362. * app add extra attributes to its eglGetPlatformDisplay() call.
  363. *
  364. * The callback should return a pointer to an EGL attribute array terminated
  365. * with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow
  366. * process will fail gracefully.
  367. *
  368. * The returned pointer should be allocated with SDL_malloc() and will be
  369. * passed to SDL_free().
  370. *
  371. * The arrays returned by each callback will be appended to the existing
  372. * attribute arrays defined by SDL.
  373. *
  374. * \param userdata an app-controlled pointer that is passed to the callback.
  375. * \returns a newly-allocated array of attributes, terminated with `EGL_NONE`.
  376. *
  377. * \since This datatype is available since SDL 3.2.0.
  378. *
  379. * \sa SDL_EGL_SetAttributeCallbacks
  380. */
  381. typedef SDL_EGLAttrib *(SDLCALL *SDL_EGLAttribArrayCallback)(void *userdata);
  382. /**
  383. * EGL surface/context attribute initialization callback types.
  384. *
  385. * This is called when SDL is attempting to create an EGL surface, to let the
  386. * app add extra attributes to its eglCreateWindowSurface() or
  387. * eglCreateContext calls.
  388. *
  389. * For convenience, the EGLDisplay and EGLConfig to use are provided to the
  390. * callback.
  391. *
  392. * The callback should return a pointer to an EGL attribute array terminated
  393. * with `EGL_NONE`. If this function returns NULL, the SDL_CreateWindow
  394. * process will fail gracefully.
  395. *
  396. * The returned pointer should be allocated with SDL_malloc() and will be
  397. * passed to SDL_free().
  398. *
  399. * The arrays returned by each callback will be appended to the existing
  400. * attribute arrays defined by SDL.
  401. *
  402. * \param userdata an app-controlled pointer that is passed to the callback.
  403. * \param display the EGL display to be used.
  404. * \param config the EGL config to be used.
  405. * \returns a newly-allocated array of attributes, terminated with `EGL_NONE`.
  406. *
  407. * \since This datatype is available since SDL 3.2.0.
  408. *
  409. * \sa SDL_EGL_SetAttributeCallbacks
  410. */
  411. typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void *userdata, SDL_EGLDisplay display, SDL_EGLConfig config);
  412. /**
  413. * An enumeration of OpenGL configuration attributes.
  414. *
  415. * While you can set most OpenGL attributes normally, they must be known
  416. * before SDL creates the window that will be used with the OpenGL context.
  417. * These attributes are set and read with SDL_GL_SetAttribute() and
  418. * SDL_GL_GetAttribute().
  419. *
  420. * In some cases, these attributes are minimum requests; the GL does not
  421. * promise to give you exactly what you asked for. It's possible to ask for a
  422. * 16-bit depth buffer and get a 24-bit one instead, for example, or to ask
  423. * for no stencil buffer and still have one available. Context creation should
  424. * fail if the GL can't provide your requested attributes at a minimum, but
  425. * you should check to see exactly what you got.
  426. *
  427. * \since This enum is available since SDL 3.2.0.
  428. */
  429. typedef enum SDL_GLAttr
  430. {
  431. SDL_GL_RED_SIZE, /**< the minimum number of bits for the red channel of the color buffer; defaults to 8. */
  432. SDL_GL_GREEN_SIZE, /**< the minimum number of bits for the green channel of the color buffer; defaults to 8. */
  433. SDL_GL_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the color buffer; defaults to 8. */
  434. SDL_GL_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the color buffer; defaults to 8. */
  435. SDL_GL_BUFFER_SIZE, /**< the minimum number of bits for frame buffer size; defaults to 0. */
  436. SDL_GL_DOUBLEBUFFER, /**< whether the output is single or double buffered; defaults to double buffering on. */
  437. SDL_GL_DEPTH_SIZE, /**< the minimum number of bits in the depth buffer; defaults to 16. */
  438. SDL_GL_STENCIL_SIZE, /**< the minimum number of bits in the stencil buffer; defaults to 0. */
  439. SDL_GL_ACCUM_RED_SIZE, /**< the minimum number of bits for the red channel of the accumulation buffer; defaults to 0. */
  440. SDL_GL_ACCUM_GREEN_SIZE, /**< the minimum number of bits for the green channel of the accumulation buffer; defaults to 0. */
  441. SDL_GL_ACCUM_BLUE_SIZE, /**< the minimum number of bits for the blue channel of the accumulation buffer; defaults to 0. */
  442. SDL_GL_ACCUM_ALPHA_SIZE, /**< the minimum number of bits for the alpha channel of the accumulation buffer; defaults to 0. */
  443. SDL_GL_STEREO, /**< whether the output is stereo 3D; defaults to off. */
  444. SDL_GL_MULTISAMPLEBUFFERS, /**< the number of buffers used for multisample anti-aliasing; defaults to 0. */
  445. SDL_GL_MULTISAMPLESAMPLES, /**< the number of samples used around the current pixel used for multisample anti-aliasing. */
  446. SDL_GL_ACCELERATED_VISUAL, /**< set to 1 to require hardware acceleration, set to 0 to force software rendering; defaults to allow either. */
  447. SDL_GL_RETAINED_BACKING, /**< not used (deprecated). */
  448. SDL_GL_CONTEXT_MAJOR_VERSION, /**< OpenGL context major version. */
  449. SDL_GL_CONTEXT_MINOR_VERSION, /**< OpenGL context minor version. */
  450. SDL_GL_CONTEXT_FLAGS, /**< some combination of 0 or more of elements of the SDL_GLContextFlag enumeration; defaults to 0. */
  451. SDL_GL_CONTEXT_PROFILE_MASK, /**< type of GL context (Core, Compatibility, ES). See SDL_GLProfile; default value depends on platform. */
  452. SDL_GL_SHARE_WITH_CURRENT_CONTEXT, /**< OpenGL context sharing; defaults to 0. */
  453. SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, /**< requests sRGB capable visual; defaults to 0. */
  454. SDL_GL_CONTEXT_RELEASE_BEHAVIOR, /**< sets context the release behavior. See SDL_GLContextReleaseFlag; defaults to FLUSH. */
  455. SDL_GL_CONTEXT_RESET_NOTIFICATION, /**< set context reset notification. See SDL_GLContextResetNotification; defaults to NO_NOTIFICATION. */
  456. SDL_GL_CONTEXT_NO_ERROR,
  457. SDL_GL_FLOATBUFFERS,
  458. SDL_GL_EGL_PLATFORM
  459. } SDL_GLAttr;
  460. /**
  461. * Possible values to be set for the SDL_GL_CONTEXT_PROFILE_MASK attribute.
  462. *
  463. * \since This datatype is available since SDL 3.2.0.
  464. */
  465. typedef Uint32 SDL_GLProfile;
  466. #define SDL_GL_CONTEXT_PROFILE_CORE 0x0001 /**< OpenGL Core Profile context */
  467. #define SDL_GL_CONTEXT_PROFILE_COMPATIBILITY 0x0002 /**< OpenGL Compatibility Profile context */
  468. #define SDL_GL_CONTEXT_PROFILE_ES 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
  469. /**
  470. * Possible flags to be set for the SDL_GL_CONTEXT_FLAGS attribute.
  471. *
  472. * \since This datatype is available since SDL 3.2.0.
  473. */
  474. typedef Uint32 SDL_GLContextFlag;
  475. #define SDL_GL_CONTEXT_DEBUG_FLAG 0x0001
  476. #define SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG 0x0002
  477. #define SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG 0x0004
  478. #define SDL_GL_CONTEXT_RESET_ISOLATION_FLAG 0x0008
  479. /**
  480. * Possible values to be set for the SDL_GL_CONTEXT_RELEASE_BEHAVIOR
  481. * attribute.
  482. *
  483. * \since This datatype is available since SDL 3.2.0.
  484. */
  485. typedef Uint32 SDL_GLContextReleaseFlag;
  486. #define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE 0x0000
  487. #define SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x0001
  488. /**
  489. * Possible values to be set SDL_GL_CONTEXT_RESET_NOTIFICATION attribute.
  490. *
  491. * \since This datatype is available since SDL 3.2.0.
  492. */
  493. typedef Uint32 SDL_GLContextResetNotification;
  494. #define SDL_GL_CONTEXT_RESET_NO_NOTIFICATION 0x0000
  495. #define SDL_GL_CONTEXT_RESET_LOSE_CONTEXT 0x0001
  496. /* Function prototypes */
  497. /**
  498. * Get the number of video drivers compiled into SDL.
  499. *
  500. * \returns the number of built in video drivers.
  501. *
  502. * \threadsafety This function should only be called on the main thread.
  503. *
  504. * \since This function is available since SDL 3.2.0.
  505. *
  506. * \sa SDL_GetVideoDriver
  507. */
  508. extern SDL_DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
  509. /**
  510. * Get the name of a built in video driver.
  511. *
  512. * The video drivers are presented in the order in which they are normally
  513. * checked during initialization.
  514. *
  515. * The names of drivers are all simple, low-ASCII identifiers, like "cocoa",
  516. * "x11" or "windows". These never have Unicode characters, and are not meant
  517. * to be proper names.
  518. *
  519. * \param index the index of a video driver.
  520. * \returns the name of the video driver with the given **index**, or NULL if
  521. * index is out of bounds.
  522. *
  523. * \threadsafety This function should only be called on the main thread.
  524. *
  525. * \since This function is available since SDL 3.2.0.
  526. *
  527. * \sa SDL_GetNumVideoDrivers
  528. */
  529. extern SDL_DECLSPEC const char * SDLCALL SDL_GetVideoDriver(int index);
  530. /**
  531. * Get the name of the currently initialized video driver.
  532. *
  533. * The names of drivers are all simple, low-ASCII identifiers, like "cocoa",
  534. * "x11" or "windows". These never have Unicode characters, and are not meant
  535. * to be proper names.
  536. *
  537. * \returns the name of the current video driver or NULL if no driver has been
  538. * initialized.
  539. *
  540. * \threadsafety This function should only be called on the main thread.
  541. *
  542. * \since This function is available since SDL 3.2.0.
  543. *
  544. * \sa SDL_GetNumVideoDrivers
  545. * \sa SDL_GetVideoDriver
  546. */
  547. extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentVideoDriver(void);
  548. /**
  549. * Get the current system theme.
  550. *
  551. * \returns the current system theme, light, dark, or unknown.
  552. *
  553. * \threadsafety This function should only be called on the main thread.
  554. *
  555. * \since This function is available since SDL 3.2.0.
  556. */
  557. extern SDL_DECLSPEC SDL_SystemTheme SDLCALL SDL_GetSystemTheme(void);
  558. /**
  559. * Get a list of currently connected displays.
  560. *
  561. * \param count a pointer filled in with the number of displays returned, may
  562. * be NULL.
  563. * \returns a 0 terminated array of display instance IDs or NULL on failure;
  564. * call SDL_GetError() for more information. This should be freed
  565. * with SDL_free() when it is no longer needed.
  566. *
  567. * \threadsafety This function should only be called on the main thread.
  568. *
  569. * \since This function is available since SDL 3.2.0.
  570. */
  571. extern SDL_DECLSPEC SDL_DisplayID * SDLCALL SDL_GetDisplays(int *count);
  572. /**
  573. * Return the primary display.
  574. *
  575. * \returns the instance ID of the primary display on success or 0 on failure;
  576. * call SDL_GetError() for more information.
  577. *
  578. * \threadsafety This function should only be called on the main thread.
  579. *
  580. * \since This function is available since SDL 3.2.0.
  581. *
  582. * \sa SDL_GetDisplays
  583. */
  584. extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
  585. /**
  586. * Get the properties associated with a display.
  587. *
  588. * The following read-only properties are provided by SDL:
  589. *
  590. * - `SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN`: true if the display has HDR
  591. * headroom above the SDR white point. This is for informational and
  592. * diagnostic purposes only, as not all platforms provide this information
  593. * at the display level.
  594. *
  595. * On KMS/DRM:
  596. *
  597. * - `SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER`: the "panel
  598. * orientation" property for the display in degrees of clockwise rotation.
  599. * Note that this is provided only as a hint, and the application is
  600. * responsible for any coordinate transformations needed to conform to the
  601. * requested display orientation.
  602. *
  603. * On Wayland:
  604. *
  605. * - `SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER`: the wl_output associated
  606. * with the display
  607. *
  608. * On Windows:
  609. *
  610. * - `SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER`: the monitor handle
  611. * (HMONITOR) associated with the display
  612. *
  613. * \param displayID the instance ID of the display to query.
  614. * \returns a valid property ID on success or 0 on failure; call
  615. * SDL_GetError() for more information.
  616. *
  617. * \threadsafety This function should only be called on the main thread.
  618. *
  619. * \since This function is available since SDL 3.2.0.
  620. */
  621. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID);
  622. #define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
  623. #define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
  624. #define SDL_PROP_DISPLAY_WAYLAND_WL_OUTPUT_POINTER "SDL.display.wayland.wl_output"
  625. #define SDL_PROP_DISPLAY_WINDOWS_HMONITOR_POINTER "SDL.display.windows.hmonitor"
  626. /**
  627. * Get the name of a display in UTF-8 encoding.
  628. *
  629. * \param displayID the instance ID of the display to query.
  630. * \returns the name of a display or NULL on failure; call SDL_GetError() for
  631. * more information.
  632. *
  633. * \threadsafety This function should only be called on the main thread.
  634. *
  635. * \since This function is available since SDL 3.2.0.
  636. *
  637. * \sa SDL_GetDisplays
  638. */
  639. extern SDL_DECLSPEC const char * SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
  640. /**
  641. * Get the desktop area represented by a display.
  642. *
  643. * The primary display is often located at (0,0), but may be placed at a
  644. * different location depending on monitor layout.
  645. *
  646. * \param displayID the instance ID of the display to query.
  647. * \param rect the SDL_Rect structure filled in with the display bounds.
  648. * \returns true on success or false on failure; call SDL_GetError() for more
  649. * information.
  650. *
  651. * \threadsafety This function should only be called on the main thread.
  652. *
  653. * \since This function is available since SDL 3.2.0.
  654. *
  655. * \sa SDL_GetDisplayUsableBounds
  656. * \sa SDL_GetDisplays
  657. */
  658. extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
  659. /**
  660. * Get the usable desktop area represented by a display, in screen
  661. * coordinates.
  662. *
  663. * This is the same area as SDL_GetDisplayBounds() reports, but with portions
  664. * reserved by the system removed. For example, on Apple's macOS, this
  665. * subtracts the area occupied by the menu bar and dock.
  666. *
  667. * Setting a window to be fullscreen generally bypasses these unusable areas,
  668. * so these are good guidelines for the maximum space available to a
  669. * non-fullscreen window.
  670. *
  671. * \param displayID the instance ID of the display to query.
  672. * \param rect the SDL_Rect structure filled in with the display bounds.
  673. * \returns true on success or false on failure; call SDL_GetError() for more
  674. * information.
  675. *
  676. * \threadsafety This function should only be called on the main thread.
  677. *
  678. * \since This function is available since SDL 3.2.0.
  679. *
  680. * \sa SDL_GetDisplayBounds
  681. * \sa SDL_GetDisplays
  682. */
  683. extern SDL_DECLSPEC bool SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
  684. /**
  685. * Get the orientation of a display when it is unrotated.
  686. *
  687. * \param displayID the instance ID of the display to query.
  688. * \returns the SDL_DisplayOrientation enum value of the display, or
  689. * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
  690. *
  691. * \threadsafety This function should only be called on the main thread.
  692. *
  693. * \since This function is available since SDL 3.2.0.
  694. *
  695. * \sa SDL_GetDisplays
  696. */
  697. extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetNaturalDisplayOrientation(SDL_DisplayID displayID);
  698. /**
  699. * Get the orientation of a display.
  700. *
  701. * \param displayID the instance ID of the display to query.
  702. * \returns the SDL_DisplayOrientation enum value of the display, or
  703. * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
  704. *
  705. * \threadsafety This function should only be called on the main thread.
  706. *
  707. * \since This function is available since SDL 3.2.0.
  708. *
  709. * \sa SDL_GetDisplays
  710. */
  711. extern SDL_DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID);
  712. /**
  713. * Get the content scale of a display.
  714. *
  715. * The content scale is the expected scale for content based on the DPI
  716. * settings of the display. For example, a 4K display might have a 2.0 (200%)
  717. * display scale, which means that the user expects UI elements to be twice as
  718. * big on this display, to aid in readability.
  719. *
  720. * After window creation, SDL_GetWindowDisplayScale() should be used to query
  721. * the content scale factor for individual windows instead of querying the
  722. * display for a window and calling this function, as the per-window content
  723. * scale factor may differ from the base value of the display it is on,
  724. * particularly on high-DPI and/or multi-monitor desktop configurations.
  725. *
  726. * \param displayID the instance ID of the display to query.
  727. * \returns the content scale of the display, or 0.0f on failure; call
  728. * SDL_GetError() for more information.
  729. *
  730. * \threadsafety This function should only be called on the main thread.
  731. *
  732. * \since This function is available since SDL 3.2.0.
  733. *
  734. * \sa SDL_GetWindowDisplayScale
  735. * \sa SDL_GetDisplays
  736. */
  737. extern SDL_DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displayID);
  738. /**
  739. * Get a list of fullscreen display modes available on a display.
  740. *
  741. * The display modes are sorted in this priority:
  742. *
  743. * - w -> largest to smallest
  744. * - h -> largest to smallest
  745. * - bits per pixel -> more colors to fewer colors
  746. * - packed pixel layout -> largest to smallest
  747. * - refresh rate -> highest to lowest
  748. * - pixel density -> lowest to highest
  749. *
  750. * \param displayID the instance ID of the display to query.
  751. * \param count a pointer filled in with the number of display modes returned,
  752. * may be NULL.
  753. * \returns a NULL terminated array of display mode pointers or NULL on
  754. * failure; call SDL_GetError() for more information. This is a
  755. * single allocation that should be freed with SDL_free() when it is
  756. * no longer needed.
  757. *
  758. * \threadsafety This function should only be called on the main thread.
  759. *
  760. * \since This function is available since SDL 3.2.0.
  761. *
  762. * \sa SDL_GetDisplays
  763. */
  764. extern SDL_DECLSPEC SDL_DisplayMode ** SDLCALL SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count);
  765. /**
  766. * Get the closest match to the requested display mode.
  767. *
  768. * The available display modes are scanned and `closest` is filled in with the
  769. * closest mode matching the requested mode and returned. The mode format and
  770. * refresh rate default to the desktop mode if they are set to 0. The modes
  771. * are scanned with size being first priority, format being second priority,
  772. * and finally checking the refresh rate. If all the available modes are too
  773. * small, then false is returned.
  774. *
  775. * \param displayID the instance ID of the display to query.
  776. * \param w the width in pixels of the desired display mode.
  777. * \param h the height in pixels of the desired display mode.
  778. * \param refresh_rate the refresh rate of the desired display mode, or 0.0f
  779. * for the desktop refresh rate.
  780. * \param include_high_density_modes boolean to include high density modes in
  781. * the search.
  782. * \param closest a pointer filled in with the closest display mode equal to
  783. * or larger than the desired mode.
  784. * \returns true on success or false on failure; call SDL_GetError() for more
  785. * information.
  786. *
  787. * \threadsafety This function should only be called on the main thread.
  788. *
  789. * \since This function is available since SDL 3.2.0.
  790. *
  791. * \sa SDL_GetDisplays
  792. * \sa SDL_GetFullscreenDisplayModes
  793. */
  794. extern SDL_DECLSPEC bool SDLCALL SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *closest);
  795. /**
  796. * Get information about the desktop's display mode.
  797. *
  798. * There's a difference between this function and SDL_GetCurrentDisplayMode()
  799. * when SDL runs fullscreen and has changed the resolution. In that case this
  800. * function will return the previous native display mode, and not the current
  801. * display mode.
  802. *
  803. * \param displayID the instance ID of the display to query.
  804. * \returns a pointer to the desktop display mode or NULL on failure; call
  805. * SDL_GetError() for more information.
  806. *
  807. * \threadsafety This function should only be called on the main thread.
  808. *
  809. * \since This function is available since SDL 3.2.0.
  810. *
  811. * \sa SDL_GetCurrentDisplayMode
  812. * \sa SDL_GetDisplays
  813. */
  814. extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID);
  815. /**
  816. * Get information about the current display mode.
  817. *
  818. * There's a difference between this function and SDL_GetDesktopDisplayMode()
  819. * when SDL runs fullscreen and has changed the resolution. In that case this
  820. * function will return the current display mode, and not the previous native
  821. * display mode.
  822. *
  823. * \param displayID the instance ID of the display to query.
  824. * \returns a pointer to the desktop display mode or NULL on failure; call
  825. * SDL_GetError() for more information.
  826. *
  827. * \threadsafety This function should only be called on the main thread.
  828. *
  829. * \since This function is available since SDL 3.2.0.
  830. *
  831. * \sa SDL_GetDesktopDisplayMode
  832. * \sa SDL_GetDisplays
  833. */
  834. extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID);
  835. /**
  836. * Get the display containing a point.
  837. *
  838. * \param point the point to query.
  839. * \returns the instance ID of the display containing the point or 0 on
  840. * failure; call SDL_GetError() for more information.
  841. *
  842. * \threadsafety This function should only be called on the main thread.
  843. *
  844. * \since This function is available since SDL 3.2.0.
  845. *
  846. * \sa SDL_GetDisplayBounds
  847. * \sa SDL_GetDisplays
  848. */
  849. extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
  850. /**
  851. * Get the display primarily containing a rect.
  852. *
  853. * \param rect the rect to query.
  854. * \returns the instance ID of the display entirely containing the rect or
  855. * closest to the center of the rect on success or 0 on failure; call
  856. * SDL_GetError() for more information.
  857. *
  858. * \threadsafety This function should only be called on the main thread.
  859. *
  860. * \since This function is available since SDL 3.2.0.
  861. *
  862. * \sa SDL_GetDisplayBounds
  863. * \sa SDL_GetDisplays
  864. */
  865. extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
  866. /**
  867. * Get the display associated with a window.
  868. *
  869. * \param window the window to query.
  870. * \returns the instance ID of the display containing the center of the window
  871. * on success or 0 on failure; call SDL_GetError() for more
  872. * information.
  873. *
  874. * \threadsafety This function should only be called on the main thread.
  875. *
  876. * \since This function is available since SDL 3.2.0.
  877. *
  878. * \sa SDL_GetDisplayBounds
  879. * \sa SDL_GetDisplays
  880. */
  881. extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
  882. /**
  883. * Get the pixel density of a window.
  884. *
  885. * This is a ratio of pixel size to window size. For example, if the window is
  886. * 1920x1080 and it has a high density back buffer of 3840x2160 pixels, it
  887. * would have a pixel density of 2.0.
  888. *
  889. * \param window the window to query.
  890. * \returns the pixel density or 0.0f on failure; call SDL_GetError() for more
  891. * information.
  892. *
  893. * \threadsafety This function should only be called on the main thread.
  894. *
  895. * \since This function is available since SDL 3.2.0.
  896. *
  897. * \sa SDL_GetWindowDisplayScale
  898. */
  899. extern SDL_DECLSPEC float SDLCALL SDL_GetWindowPixelDensity(SDL_Window *window);
  900. /**
  901. * Get the content display scale relative to a window's pixel size.
  902. *
  903. * This is a combination of the window pixel density and the display content
  904. * scale, and is the expected scale for displaying content in this window. For
  905. * example, if a 3840x2160 window had a display scale of 2.0, the user expects
  906. * the content to take twice as many pixels and be the same physical size as
  907. * if it were being displayed in a 1920x1080 window with a display scale of
  908. * 1.0.
  909. *
  910. * Conceptually this value corresponds to the scale display setting, and is
  911. * updated when that setting is changed, or the window moves to a display with
  912. * a different scale setting.
  913. *
  914. * \param window the window to query.
  915. * \returns the display scale, or 0.0f on failure; call SDL_GetError() for
  916. * more information.
  917. *
  918. * \threadsafety This function should only be called on the main thread.
  919. *
  920. * \since This function is available since SDL 3.2.0.
  921. */
  922. extern SDL_DECLSPEC float SDLCALL SDL_GetWindowDisplayScale(SDL_Window *window);
  923. /**
  924. * Set the display mode to use when a window is visible and fullscreen.
  925. *
  926. * This only affects the display mode used when the window is fullscreen. To
  927. * change the window size when the window is not fullscreen, use
  928. * SDL_SetWindowSize().
  929. *
  930. * If the window is currently in the fullscreen state, this request is
  931. * asynchronous on some windowing systems and the new mode dimensions may not
  932. * be applied immediately upon the return of this function. If an immediate
  933. * change is required, call SDL_SyncWindow() to block until the changes have
  934. * taken effect.
  935. *
  936. * When the new mode takes effect, an SDL_EVENT_WINDOW_RESIZED and/or an
  937. * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event will be emitted with the new mode
  938. * dimensions.
  939. *
  940. * \param window the window to affect.
  941. * \param mode a pointer to the display mode to use, which can be NULL for
  942. * borderless fullscreen desktop mode, or one of the fullscreen
  943. * modes returned by SDL_GetFullscreenDisplayModes() to set an
  944. * exclusive fullscreen mode.
  945. * \returns true on success or false on failure; call SDL_GetError() for more
  946. * information.
  947. *
  948. * \threadsafety This function should only be called on the main thread.
  949. *
  950. * \since This function is available since SDL 3.2.0.
  951. *
  952. * \sa SDL_GetWindowFullscreenMode
  953. * \sa SDL_SetWindowFullscreen
  954. * \sa SDL_SyncWindow
  955. */
  956. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode);
  957. /**
  958. * Query the display mode to use when a window is visible at fullscreen.
  959. *
  960. * \param window the window to query.
  961. * \returns a pointer to the exclusive fullscreen mode to use or NULL for
  962. * borderless fullscreen desktop mode.
  963. *
  964. * \threadsafety This function should only be called on the main thread.
  965. *
  966. * \since This function is available since SDL 3.2.0.
  967. *
  968. * \sa SDL_SetWindowFullscreenMode
  969. * \sa SDL_SetWindowFullscreen
  970. */
  971. extern SDL_DECLSPEC const SDL_DisplayMode * SDLCALL SDL_GetWindowFullscreenMode(SDL_Window *window);
  972. /**
  973. * Get the raw ICC profile data for the screen the window is currently on.
  974. *
  975. * \param window the window to query.
  976. * \param size the size of the ICC profile.
  977. * \returns the raw ICC profile data on success or NULL on failure; call
  978. * SDL_GetError() for more information. This should be freed with
  979. * SDL_free() when it is no longer needed.
  980. *
  981. * \threadsafety This function should only be called on the main thread.
  982. *
  983. * \since This function is available since SDL 3.2.0.
  984. */
  985. extern SDL_DECLSPEC void * SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size);
  986. /**
  987. * Get the pixel format associated with the window.
  988. *
  989. * \param window the window to query.
  990. * \returns the pixel format of the window on success or
  991. * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more
  992. * information.
  993. *
  994. * \threadsafety This function should only be called on the main thread.
  995. *
  996. * \since This function is available since SDL 3.2.0.
  997. */
  998. extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
  999. /**
  1000. * Get a list of valid windows.
  1001. *
  1002. * \param count a pointer filled in with the number of windows returned, may
  1003. * be NULL.
  1004. * \returns a NULL terminated array of SDL_Window pointers or NULL on failure;
  1005. * call SDL_GetError() for more information. This is a single
  1006. * allocation that should be freed with SDL_free() when it is no
  1007. * longer needed.
  1008. *
  1009. * \threadsafety This function should only be called on the main thread.
  1010. *
  1011. * \since This function is available since SDL 3.2.0.
  1012. */
  1013. extern SDL_DECLSPEC SDL_Window ** SDLCALL SDL_GetWindows(int *count);
  1014. /**
  1015. * Create a window with the specified dimensions and flags.
  1016. *
  1017. * The window size is a request and may be different than expected based on
  1018. * the desktop layout and window manager policies. Your application should be
  1019. * prepared to handle a window of any size.
  1020. *
  1021. * `flags` may be any of the following OR'd together:
  1022. *
  1023. * - `SDL_WINDOW_FULLSCREEN`: fullscreen window at desktop resolution
  1024. * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context
  1025. * - `SDL_WINDOW_HIDDEN`: window is not visible
  1026. * - `SDL_WINDOW_BORDERLESS`: no window decoration
  1027. * - `SDL_WINDOW_RESIZABLE`: window can be resized
  1028. * - `SDL_WINDOW_MINIMIZED`: window is minimized
  1029. * - `SDL_WINDOW_MAXIMIZED`: window is maximized
  1030. * - `SDL_WINDOW_MOUSE_GRABBED`: window has grabbed mouse focus
  1031. * - `SDL_WINDOW_INPUT_FOCUS`: window has input focus
  1032. * - `SDL_WINDOW_MOUSE_FOCUS`: window has mouse focus
  1033. * - `SDL_WINDOW_EXTERNAL`: window not created by SDL
  1034. * - `SDL_WINDOW_MODAL`: window is modal
  1035. * - `SDL_WINDOW_HIGH_PIXEL_DENSITY`: window uses high pixel density back
  1036. * buffer if possible
  1037. * - `SDL_WINDOW_MOUSE_CAPTURE`: window has mouse captured (unrelated to
  1038. * MOUSE_GRABBED)
  1039. * - `SDL_WINDOW_ALWAYS_ON_TOP`: window should always be above others
  1040. * - `SDL_WINDOW_UTILITY`: window should be treated as a utility window, not
  1041. * showing in the task bar and window list
  1042. * - `SDL_WINDOW_TOOLTIP`: window should be treated as a tooltip and does not
  1043. * get mouse or keyboard focus, requires a parent window
  1044. * - `SDL_WINDOW_POPUP_MENU`: window should be treated as a popup menu,
  1045. * requires a parent window
  1046. * - `SDL_WINDOW_KEYBOARD_GRABBED`: window has grabbed keyboard input
  1047. * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance
  1048. * - `SDL_WINDOW_METAL`: window usable with a Metal instance
  1049. * - `SDL_WINDOW_TRANSPARENT`: window with transparent buffer
  1050. * - `SDL_WINDOW_NOT_FOCUSABLE`: window should not be focusable
  1051. *
  1052. * The SDL_Window will be shown if SDL_WINDOW_HIDDEN is not set. If hidden at
  1053. * creation time, SDL_ShowWindow() can be used to show it later.
  1054. *
  1055. * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
  1056. * property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
  1057. *
  1058. * The window pixel size may differ from its window coordinate size if the
  1059. * window is on a high pixel density display. Use SDL_GetWindowSize() to query
  1060. * the client area's size in window coordinates, and
  1061. * SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to query the
  1062. * drawable size in pixels. Note that the drawable size can vary after the
  1063. * window is created and should be queried again if you get an
  1064. * SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event.
  1065. *
  1066. * If the window is created with any of the SDL_WINDOW_OPENGL or
  1067. * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
  1068. * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the
  1069. * corresponding UnloadLibrary function is called by SDL_DestroyWindow().
  1070. *
  1071. * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
  1072. * SDL_CreateWindow() will fail, because SDL_Vulkan_LoadLibrary() will fail.
  1073. *
  1074. * If SDL_WINDOW_METAL is specified on an OS that does not support Metal,
  1075. * SDL_CreateWindow() will fail.
  1076. *
  1077. * If you intend to use this window with an SDL_Renderer, you should use
  1078. * SDL_CreateWindowAndRenderer() instead of this function, to avoid window
  1079. * flicker.
  1080. *
  1081. * On non-Apple devices, SDL requires you to either not link to the Vulkan
  1082. * loader or link to a dynamic library version. This limitation may be removed
  1083. * in a future version of SDL.
  1084. *
  1085. * \param title the title of the window, in UTF-8 encoding.
  1086. * \param w the width of the window.
  1087. * \param h the height of the window.
  1088. * \param flags 0, or one or more SDL_WindowFlags OR'd together.
  1089. * \returns the window that was created or NULL on failure; call
  1090. * SDL_GetError() for more information.
  1091. *
  1092. * \threadsafety This function should only be called on the main thread.
  1093. *
  1094. * \since This function is available since SDL 3.2.0.
  1095. *
  1096. * \sa SDL_CreateWindowAndRenderer
  1097. * \sa SDL_CreatePopupWindow
  1098. * \sa SDL_CreateWindowWithProperties
  1099. * \sa SDL_DestroyWindow
  1100. */
  1101. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int w, int h, SDL_WindowFlags flags);
  1102. /**
  1103. * Create a child popup window of the specified parent window.
  1104. *
  1105. * The window size is a request and may be different than expected based on
  1106. * the desktop layout and window manager policies. Your application should be
  1107. * prepared to handle a window of any size.
  1108. *
  1109. * The flags parameter **must** contain at least one of the following:
  1110. *
  1111. * - `SDL_WINDOW_TOOLTIP`: The popup window is a tooltip and will not pass any
  1112. * input events.
  1113. * - `SDL_WINDOW_POPUP_MENU`: The popup window is a popup menu. The topmost
  1114. * popup menu will implicitly gain the keyboard focus.
  1115. *
  1116. * The following flags are not relevant to popup window creation and will be
  1117. * ignored:
  1118. *
  1119. * - `SDL_WINDOW_MINIMIZED`
  1120. * - `SDL_WINDOW_MAXIMIZED`
  1121. * - `SDL_WINDOW_FULLSCREEN`
  1122. * - `SDL_WINDOW_BORDERLESS`
  1123. *
  1124. * The following flags are incompatible with popup window creation and will
  1125. * cause it to fail:
  1126. *
  1127. * - `SDL_WINDOW_UTILITY`
  1128. * - `SDL_WINDOW_MODAL`
  1129. *
  1130. * The parent parameter **must** be non-null and a valid window. The parent of
  1131. * a popup window can be either a regular, toplevel window, or another popup
  1132. * window.
  1133. *
  1134. * Popup windows cannot be minimized, maximized, made fullscreen, raised,
  1135. * flash, be made a modal window, be the parent of a toplevel window, or grab
  1136. * the mouse and/or keyboard. Attempts to do so will fail.
  1137. *
  1138. * Popup windows implicitly do not have a border/decorations and do not appear
  1139. * on the taskbar/dock or in lists of windows such as alt-tab menus.
  1140. *
  1141. * By default, popup window positions will automatically be constrained to
  1142. * keep the entire window within display bounds. This can be overridden with
  1143. * the `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN` property.
  1144. *
  1145. * By default, popup menus will automatically grab keyboard focus from the
  1146. * parent when shown. This behavior can be overridden by setting the
  1147. * `SDL_WINDOW_NOT_FOCUSABLE` flag, setting the
  1148. * `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN` property to false, or toggling
  1149. * it after creation via the `SDL_SetWindowFocusable()` function.
  1150. *
  1151. * If a parent window is hidden or destroyed, any child popup windows will be
  1152. * recursively hidden or destroyed as well. Child popup windows not explicitly
  1153. * hidden will be restored when the parent is shown.
  1154. *
  1155. * \param parent the parent of the window, must not be NULL.
  1156. * \param offset_x the x position of the popup window relative to the origin
  1157. * of the parent.
  1158. * \param offset_y the y position of the popup window relative to the origin
  1159. * of the parent window.
  1160. * \param w the width of the window.
  1161. * \param h the height of the window.
  1162. * \param flags SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP_MENU, and zero or more
  1163. * additional SDL_WindowFlags OR'd together.
  1164. * \returns the window that was created or NULL on failure; call
  1165. * SDL_GetError() for more information.
  1166. *
  1167. * \threadsafety This function should only be called on the main thread.
  1168. *
  1169. * \since This function is available since SDL 3.2.0.
  1170. *
  1171. * \sa SDL_CreateWindow
  1172. * \sa SDL_CreateWindowWithProperties
  1173. * \sa SDL_DestroyWindow
  1174. * \sa SDL_GetWindowParent
  1175. */
  1176. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags);
  1177. /**
  1178. * Create a window with the specified properties.
  1179. *
  1180. * The window size is a request and may be different than expected based on
  1181. * the desktop layout and window manager policies. Your application should be
  1182. * prepared to handle a window of any size.
  1183. *
  1184. * These are the supported properties:
  1185. *
  1186. * - `SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN`: true if the window should
  1187. * be always on top
  1188. * - `SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN`: true if the window has no
  1189. * window decoration
  1190. * - `SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN`: true if the "tooltip"
  1191. * and "menu" window types should be automatically constrained to be
  1192. * entirely within display bounds (default), false if no constraints on the
  1193. * position are desired.
  1194. * - `SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN`: true if the
  1195. * window will be used with an externally managed graphics context.
  1196. * - `SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN`: true if the window should
  1197. * accept keyboard input (defaults true)
  1198. * - `SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN`: true if the window should
  1199. * start in fullscreen mode at desktop resolution
  1200. * - `SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER`: the height of the window
  1201. * - `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN`: true if the window should start
  1202. * hidden
  1203. * - `SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN`: true if the window
  1204. * uses a high pixel density buffer if possible
  1205. * - `SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN`: true if the window should
  1206. * start maximized
  1207. * - `SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN`: true if the window is a popup menu
  1208. * - `SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN`: true if the window will be used
  1209. * with Metal rendering
  1210. * - `SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN`: true if the window should
  1211. * start minimized
  1212. * - `SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN`: true if the window is modal to
  1213. * its parent
  1214. * - `SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN`: true if the window starts
  1215. * with grabbed mouse focus
  1216. * - `SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`: true if the window will be used
  1217. * with OpenGL rendering
  1218. * - `SDL_PROP_WINDOW_CREATE_PARENT_POINTER`: an SDL_Window that will be the
  1219. * parent of this window, required for windows with the "tooltip", "menu",
  1220. * and "modal" properties
  1221. * - `SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN`: true if the window should be
  1222. * resizable
  1223. * - `SDL_PROP_WINDOW_CREATE_TITLE_STRING`: the title of the window, in UTF-8
  1224. * encoding
  1225. * - `SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN`: true if the window show
  1226. * transparent in the areas with alpha of 0
  1227. * - `SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN`: true if the window is a tooltip
  1228. * - `SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN`: true if the window is a utility
  1229. * window, not showing in the task bar and window list
  1230. * - `SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN`: true if the window will be used
  1231. * with Vulkan rendering
  1232. * - `SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER`: the width of the window
  1233. * - `SDL_PROP_WINDOW_CREATE_X_NUMBER`: the x position of the window, or
  1234. * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is
  1235. * relative to the parent for windows with the "tooltip" or "menu" property
  1236. * set.
  1237. * - `SDL_PROP_WINDOW_CREATE_Y_NUMBER`: the y position of the window, or
  1238. * `SDL_WINDOWPOS_CENTERED`, defaults to `SDL_WINDOWPOS_UNDEFINED`. This is
  1239. * relative to the parent for windows with the "tooltip" or "menu" property
  1240. * set.
  1241. *
  1242. * These are additional supported properties on macOS:
  1243. *
  1244. * - `SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`: the
  1245. * `(__unsafe_unretained)` NSWindow associated with the window, if you want
  1246. * to wrap an existing window.
  1247. * - `SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER`: the `(__unsafe_unretained)`
  1248. * NSView associated with the window, defaults to `[window contentView]`
  1249. *
  1250. * These are additional supported properties on iOS, tvOS, and visionOS:
  1251. *
  1252. * - `SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER`: the `(__unsafe_unretained)`
  1253. * UIWindowScene associated with the window, defaults to the active window
  1254. * scene.
  1255. *
  1256. * These are additional supported properties on Wayland:
  1257. *
  1258. * - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if
  1259. * the application wants to use the Wayland surface for a custom role and
  1260. * does not want it attached to an XDG toplevel window. See
  1261. * [README-wayland](README-wayland) for more information on using custom
  1262. * surfaces.
  1263. * - `SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN` - true if the
  1264. * application wants an associated `wl_egl_window` object to be created and
  1265. * attached to the window, even if the window does not have the OpenGL
  1266. * property or `SDL_WINDOW_OPENGL` flag set.
  1267. * - `SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER` - the wl_surface
  1268. * associated with the window, if you want to wrap an existing window. See
  1269. * [README-wayland](README-wayland) for more information.
  1270. *
  1271. * These are additional supported properties on Windows:
  1272. *
  1273. * - `SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER`: the HWND associated with the
  1274. * window, if you want to wrap an existing window.
  1275. * - `SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER`: optional,
  1276. * another window to share pixel format with, useful for OpenGL windows
  1277. *
  1278. * These are additional supported properties with X11:
  1279. *
  1280. * - `SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER`: the X11 Window associated
  1281. * with the window, if you want to wrap an existing window.
  1282. *
  1283. * The window is implicitly shown if the "hidden" property is not set.
  1284. *
  1285. * These are additional supported properties with Emscripten:
  1286. *
  1287. * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING`: the id given to the
  1288. * canvas element. This should start with a '#' sign
  1289. * - `SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: override the
  1290. * binding element for keyboard inputs for this canvas. The variable can be
  1291. * one of:
  1292. * - "#window": the javascript window object (default)
  1293. * - "#document": the javascript document object
  1294. * - "#screen": the javascript window.screen object
  1295. * - "#canvas": the WebGL canvas element
  1296. * - "#none": Don't bind anything at all
  1297. * - any other string without a leading # sign applies to the element on the
  1298. * page with that ID. Windows with the "tooltip" and "menu" properties are
  1299. * popup windows and have the behaviors and guidelines outlined in
  1300. * SDL_CreatePopupWindow().
  1301. *
  1302. * These are additional supported properties with visionOS:
  1303. *
  1304. * - `SDL_PROP_WINDOW_CREATE_CURVATURE_FLOAT`: the curvature of the window on
  1305. * visionOS. Curved windows have square corners and additional controls for
  1306. * more immersive gaming. This can be -1 (disabled), which is the default, 0
  1307. * (no curve), or set to a specific curvature radius in millimeters. A
  1308. * common value for a gaming monitor is 1000.
  1309. *
  1310. * If this window is being created to be used with an SDL_Renderer, you should
  1311. * not add a graphics API specific property
  1312. * (`SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN`, etc), as SDL will handle that
  1313. * internally when it chooses a renderer. However, SDL might need to recreate
  1314. * your window at that point, which may cause the window to appear briefly,
  1315. * and then flicker as it is recreated. The correct approach to this is to
  1316. * create the window with the `SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN` property
  1317. * set to true, then create the renderer, then show the window with
  1318. * SDL_ShowWindow().
  1319. *
  1320. * \param props the properties to use.
  1321. * \returns the window that was created or NULL on failure; call
  1322. * SDL_GetError() for more information.
  1323. *
  1324. * \threadsafety This function should only be called on the main thread.
  1325. *
  1326. * \since This function is available since SDL 3.2.0.
  1327. *
  1328. * \sa SDL_CreateProperties
  1329. * \sa SDL_CreateWindow
  1330. * \sa SDL_DestroyWindow
  1331. */
  1332. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowWithProperties(SDL_PropertiesID props);
  1333. #define SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN "SDL.window.create.always_on_top"
  1334. #define SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN "SDL.window.create.borderless"
  1335. #define SDL_PROP_WINDOW_CREATE_CONSTRAIN_POPUP_BOOLEAN "SDL.window.create.constrain_popup"
  1336. #define SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN "SDL.window.create.focusable"
  1337. #define SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN "SDL.window.create.external_graphics_context"
  1338. #define SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER "SDL.window.create.flags"
  1339. #define SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN "SDL.window.create.fullscreen"
  1340. #define SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER "SDL.window.create.height"
  1341. #define SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN "SDL.window.create.hidden"
  1342. #define SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN "SDL.window.create.high_pixel_density"
  1343. #define SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN "SDL.window.create.maximized"
  1344. #define SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN "SDL.window.create.menu"
  1345. #define SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN "SDL.window.create.metal"
  1346. #define SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN "SDL.window.create.minimized"
  1347. #define SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN "SDL.window.create.modal"
  1348. #define SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN "SDL.window.create.mouse_grabbed"
  1349. #define SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN "SDL.window.create.opengl"
  1350. #define SDL_PROP_WINDOW_CREATE_PARENT_POINTER "SDL.window.create.parent"
  1351. #define SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN "SDL.window.create.resizable"
  1352. #define SDL_PROP_WINDOW_CREATE_TITLE_STRING "SDL.window.create.title"
  1353. #define SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN "SDL.window.create.transparent"
  1354. #define SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN "SDL.window.create.tooltip"
  1355. #define SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN "SDL.window.create.utility"
  1356. #define SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN "SDL.window.create.vulkan"
  1357. #define SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER "SDL.window.create.width"
  1358. #define SDL_PROP_WINDOW_CREATE_X_NUMBER "SDL.window.create.x"
  1359. #define SDL_PROP_WINDOW_CREATE_Y_NUMBER "SDL.window.create.y"
  1360. #define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "SDL.window.create.cocoa.window"
  1361. #define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "SDL.window.create.cocoa.view"
  1362. #define SDL_PROP_WINDOW_CREATE_WINDOWSCENE_POINTER "SDL.window.create.uikit.windowscene"
  1363. #define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "SDL.window.create.wayland.surface_role_custom"
  1364. #define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "SDL.window.create.wayland.create_egl_window"
  1365. #define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "SDL.window.create.wayland.wl_surface"
  1366. #define SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER "SDL.window.create.win32.hwnd"
  1367. #define SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER "SDL.window.create.win32.pixel_format_hwnd"
  1368. #define SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER "SDL.window.create.x11.window"
  1369. #define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.create.emscripten.canvas_id"
  1370. #define SDL_PROP_WINDOW_CREATE_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.create.emscripten.keyboard_element"
  1371. #define SDL_PROP_WINDOW_CREATE_CURVATURE_FLOAT "SDL.window.create.curvature"
  1372. /**
  1373. * Get the numeric ID of a window.
  1374. *
  1375. * The numeric ID is what SDL_WindowEvent references, and is necessary to map
  1376. * these events to specific SDL_Window objects.
  1377. *
  1378. * \param window the window to query.
  1379. * \returns the ID of the window on success or 0 on failure; call
  1380. * SDL_GetError() for more information.
  1381. *
  1382. * \threadsafety This function should only be called on the main thread.
  1383. *
  1384. * \since This function is available since SDL 3.2.0.
  1385. *
  1386. * \sa SDL_GetWindowFromID
  1387. */
  1388. extern SDL_DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window);
  1389. /**
  1390. * Get a window from a stored ID.
  1391. *
  1392. * The numeric ID is what SDL_WindowEvent references, and is necessary to map
  1393. * these events to specific SDL_Window objects.
  1394. *
  1395. * \param id the ID of the window.
  1396. * \returns the window associated with `id` or NULL if it doesn't exist; call
  1397. * SDL_GetError() for more information.
  1398. *
  1399. * \threadsafety This function should only be called on the main thread.
  1400. *
  1401. * \since This function is available since SDL 3.2.0.
  1402. *
  1403. * \sa SDL_GetWindowID
  1404. */
  1405. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(SDL_WindowID id);
  1406. /**
  1407. * Get parent of a window.
  1408. *
  1409. * \param window the window to query.
  1410. * \returns the parent of the window on success or NULL if the window has no
  1411. * parent.
  1412. *
  1413. * \threadsafety This function should only be called on the main thread.
  1414. *
  1415. * \since This function is available since SDL 3.2.0.
  1416. *
  1417. * \sa SDL_CreatePopupWindow
  1418. */
  1419. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetWindowParent(SDL_Window *window);
  1420. /**
  1421. * Get the properties associated with a window.
  1422. *
  1423. * The following read-only properties are provided by SDL:
  1424. *
  1425. * - `SDL_PROP_WINDOW_SHAPE_POINTER`: the surface associated with a shaped
  1426. * window
  1427. * - `SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN`: true if the window has HDR
  1428. * headroom above the SDR white point. This property can change dynamically
  1429. * when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
  1430. * - `SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT`: the value of SDR white in the
  1431. * SDL_COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the
  1432. * SDR white level in scRGB colorspace, and on Apple platforms this is
  1433. * always 1.0 for EDR content. This property can change dynamically when
  1434. * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
  1435. * - `SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT`: the additional high dynamic range
  1436. * that can be displayed, in terms of the SDR white point. When HDR is not
  1437. * enabled, this will be 1.0. This property can change dynamically when
  1438. * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
  1439. *
  1440. * On Android:
  1441. *
  1442. * - `SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER`: the ANativeWindow associated
  1443. * with the window
  1444. * - `SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER`: the EGLSurface associated with
  1445. * the window
  1446. *
  1447. * On iOS:
  1448. *
  1449. * - `SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER`: the `(__unsafe_unretained)`
  1450. * UIWindow associated with the window
  1451. * - `SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER`: the NSInteger tag
  1452. * associated with metal views on the window
  1453. * - `SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER`: the OpenGL view's
  1454. * framebuffer object. It must be bound when rendering to the screen using
  1455. * OpenGL.
  1456. * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER`: the OpenGL view's
  1457. * renderbuffer object. It must be bound when SDL_GL_SwapWindow is called.
  1458. * - `SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER`: the OpenGL
  1459. * view's resolve framebuffer, when MSAA is used.
  1460. *
  1461. * On KMS/DRM:
  1462. *
  1463. * - `SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER`: the device index associated
  1464. * with the window (e.g. the X in /dev/dri/cardX)
  1465. * - `SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER`: the DRM FD associated with the
  1466. * window
  1467. * - `SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER`: the GBM device associated
  1468. * with the window
  1469. *
  1470. * On macOS:
  1471. *
  1472. * - `SDL_PROP_WINDOW_COCOA_WINDOW_POINTER`: the `(__unsafe_unretained)`
  1473. * NSWindow associated with the window
  1474. * - `SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER`: the NSInteger tag
  1475. * associated with metal views on the window
  1476. *
  1477. * On OpenVR:
  1478. *
  1479. * - `SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER`: the OpenVR Overlay Handle ID
  1480. * for the associated overlay window.
  1481. *
  1482. * On QNX:
  1483. *
  1484. * - `SDL_PROP_WINDOW_QNX_WINDOW_POINTER`: the screen_window_t associated with
  1485. * the window.
  1486. * - `SDL_PROP_WINDOW_QNX_SURFACE_POINTER`: the EGLSurface associated with the
  1487. * window
  1488. *
  1489. * On Vivante:
  1490. *
  1491. * - `SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER`: the EGLNativeDisplayType
  1492. * associated with the window
  1493. * - `SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER`: the EGLNativeWindowType
  1494. * associated with the window
  1495. * - `SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER`: the EGLSurface associated with
  1496. * the window
  1497. *
  1498. * On Windows:
  1499. *
  1500. * - `SDL_PROP_WINDOW_WIN32_HWND_POINTER`: the HWND associated with the window
  1501. * - `SDL_PROP_WINDOW_WIN32_HDC_POINTER`: the HDC associated with the window
  1502. * - `SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER`: the HINSTANCE associated with
  1503. * the window
  1504. *
  1505. * On Wayland:
  1506. *
  1507. * Note: The `xdg_*` window objects do not internally persist across window
  1508. * show/hide calls. They will be null if the window is hidden and must be
  1509. * queried each time it is shown.
  1510. *
  1511. * - `SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER`: the wl_display associated with
  1512. * the window
  1513. * - `SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER`: the wl_surface associated with
  1514. * the window
  1515. * - `SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER`: the wp_viewport associated
  1516. * with the window
  1517. * - `SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER`: the wl_egl_window
  1518. * associated with the window
  1519. * - `SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER`: the xdg_surface associated
  1520. * with the window
  1521. * - `SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER`: the xdg_toplevel role
  1522. * associated with the window
  1523. * - 'SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING': the export
  1524. * handle associated with the window
  1525. * - `SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER`: the xdg_popup role
  1526. * associated with the window
  1527. * - `SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER`: the xdg_positioner
  1528. * associated with the window, in popup mode
  1529. *
  1530. * On X11:
  1531. *
  1532. * - `SDL_PROP_WINDOW_X11_DISPLAY_POINTER`: the X11 Display associated with
  1533. * the window
  1534. * - `SDL_PROP_WINDOW_X11_SCREEN_NUMBER`: the screen number associated with
  1535. * the window
  1536. * - `SDL_PROP_WINDOW_X11_WINDOW_NUMBER`: the X11 Window associated with the
  1537. * window
  1538. *
  1539. * On Emscripten:
  1540. *
  1541. * - `SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING`: the id the canvas element
  1542. * will have
  1543. * - `SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING`: the keyboard
  1544. * element that associates keyboard events to this window
  1545. *
  1546. * On visionOS:
  1547. *
  1548. * - `SDL_PROP_WINDOW_CURVATURE_FLOAT`: the curvature of the window in curved
  1549. * mode on visionOS. This value is updated dynamically when changed via the
  1550. * screen ornaments. This can be 0 (no curve), or a specific curvature
  1551. * radius in millimeters. A common value for a gaming monitor is 1000.
  1552. *
  1553. * \param window the window to query.
  1554. * \returns a valid property ID on success or 0 on failure; call
  1555. * SDL_GetError() for more information.
  1556. *
  1557. * \threadsafety This function should only be called on the main thread.
  1558. *
  1559. * \since This function is available since SDL 3.2.0.
  1560. */
  1561. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window *window);
  1562. #define SDL_PROP_WINDOW_SHAPE_POINTER "SDL.window.shape"
  1563. #define SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN "SDL.window.HDR_enabled"
  1564. #define SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT "SDL.window.SDR_white_level"
  1565. #define SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT "SDL.window.HDR_headroom"
  1566. #define SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER "SDL.window.android.window"
  1567. #define SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER "SDL.window.android.surface"
  1568. #define SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER "SDL.window.uikit.window"
  1569. #define SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER "SDL.window.uikit.metal_view_tag"
  1570. #define SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.framebuffer"
  1571. #define SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER "SDL.window.uikit.opengl.renderbuffer"
  1572. #define SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER "SDL.window.uikit.opengl.resolve_framebuffer"
  1573. #define SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER "SDL.window.kmsdrm.dev_index"
  1574. #define SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER "SDL.window.kmsdrm.drm_fd"
  1575. #define SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER "SDL.window.kmsdrm.gbm_dev"
  1576. #define SDL_PROP_WINDOW_COCOA_WINDOW_POINTER "SDL.window.cocoa.window"
  1577. #define SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER "SDL.window.cocoa.metal_view_tag"
  1578. #define SDL_PROP_WINDOW_OPENVR_OVERLAY_ID_NUMBER "SDL.window.openvr.overlay_id"
  1579. #define SDL_PROP_WINDOW_QNX_WINDOW_POINTER "SDL.window.qnx.window"
  1580. #define SDL_PROP_WINDOW_QNX_SURFACE_POINTER "SDL.window.qnx.surface"
  1581. #define SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER "SDL.window.vivante.display"
  1582. #define SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER "SDL.window.vivante.window"
  1583. #define SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER "SDL.window.vivante.surface"
  1584. #define SDL_PROP_WINDOW_WIN32_HWND_POINTER "SDL.window.win32.hwnd"
  1585. #define SDL_PROP_WINDOW_WIN32_HDC_POINTER "SDL.window.win32.hdc"
  1586. #define SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER "SDL.window.win32.instance"
  1587. #define SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER "SDL.window.wayland.display"
  1588. #define SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER "SDL.window.wayland.surface"
  1589. #define SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER "SDL.window.wayland.viewport"
  1590. #define SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER "SDL.window.wayland.egl_window"
  1591. #define SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER "SDL.window.wayland.xdg_surface"
  1592. #define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER "SDL.window.wayland.xdg_toplevel"
  1593. #define SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING "SDL.window.wayland.xdg_toplevel_export_handle"
  1594. #define SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER "SDL.window.wayland.xdg_popup"
  1595. #define SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER "SDL.window.wayland.xdg_positioner"
  1596. #define SDL_PROP_WINDOW_X11_DISPLAY_POINTER "SDL.window.x11.display"
  1597. #define SDL_PROP_WINDOW_X11_SCREEN_NUMBER "SDL.window.x11.screen"
  1598. #define SDL_PROP_WINDOW_X11_WINDOW_NUMBER "SDL.window.x11.window"
  1599. #define SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING "SDL.window.emscripten.canvas_id"
  1600. #define SDL_PROP_WINDOW_EMSCRIPTEN_KEYBOARD_ELEMENT_STRING "SDL.window.emscripten.keyboard_element"
  1601. #define SDL_PROP_WINDOW_CURVATURE_FLOAT "SDL.window.curvature"
  1602. /**
  1603. * Get the window flags.
  1604. *
  1605. * \param window the window to query.
  1606. * \returns a mask of the SDL_WindowFlags associated with `window`.
  1607. *
  1608. * \threadsafety This function should only be called on the main thread.
  1609. *
  1610. * \since This function is available since SDL 3.2.0.
  1611. *
  1612. * \sa SDL_CreateWindow
  1613. * \sa SDL_HideWindow
  1614. * \sa SDL_MaximizeWindow
  1615. * \sa SDL_MinimizeWindow
  1616. * \sa SDL_SetWindowFullscreen
  1617. * \sa SDL_SetWindowMouseGrab
  1618. * \sa SDL_SetWindowFillDocument
  1619. * \sa SDL_ShowWindow
  1620. */
  1621. extern SDL_DECLSPEC SDL_WindowFlags SDLCALL SDL_GetWindowFlags(SDL_Window *window);
  1622. /**
  1623. * Set the title of a window.
  1624. *
  1625. * This string is expected to be in UTF-8 encoding.
  1626. *
  1627. * \param window the window to change.
  1628. * \param title the desired window title in UTF-8 format.
  1629. * \returns true on success or false on failure; call SDL_GetError() for more
  1630. * information.
  1631. *
  1632. * \threadsafety This function should only be called on the main thread.
  1633. *
  1634. * \since This function is available since SDL 3.2.0.
  1635. *
  1636. * \sa SDL_GetWindowTitle
  1637. */
  1638. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
  1639. /**
  1640. * Get the title of a window.
  1641. *
  1642. * \param window the window to query.
  1643. * \returns the title of the window in UTF-8 format or "" if there is no
  1644. * title.
  1645. *
  1646. * \threadsafety This function should only be called on the main thread.
  1647. *
  1648. * \since This function is available since SDL 3.2.0.
  1649. *
  1650. * \sa SDL_SetWindowTitle
  1651. */
  1652. extern SDL_DECLSPEC const char * SDLCALL SDL_GetWindowTitle(SDL_Window *window);
  1653. /**
  1654. * Set the icon for a window.
  1655. *
  1656. * If this function is passed a surface with alternate representations added
  1657. * using SDL_AddSurfaceAlternateImage(), the surface will be interpreted as
  1658. * the content to be used for 100% display scale, and the alternate
  1659. * representations will be used for high DPI situations. For example, if the
  1660. * original surface is 32x32, then on a 2x macOS display or 200% display scale
  1661. * on Windows, a 64x64 version of the image will be used, if available. If a
  1662. * matching version of the image isn't available, the closest larger size
  1663. * image will be downscaled to the appropriate size and be used instead, if
  1664. * available. Otherwise, the closest smaller image will be upscaled and be
  1665. * used instead.
  1666. *
  1667. * \param window the window to change.
  1668. * \param icon an SDL_Surface structure containing the icon for the window.
  1669. * \returns true on success or false on failure; call SDL_GetError() for more
  1670. * information.
  1671. *
  1672. * \threadsafety This function should only be called on the main thread.
  1673. *
  1674. * \since This function is available since SDL 3.2.0.
  1675. *
  1676. * \sa SDL_AddSurfaceAlternateImage
  1677. */
  1678. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
  1679. /**
  1680. * Request that the window's position be set.
  1681. *
  1682. * If the window is in an exclusive fullscreen or maximized state, this
  1683. * request has no effect.
  1684. *
  1685. * This can be used to reposition fullscreen-desktop windows onto a different
  1686. * display, however, as exclusive fullscreen windows are locked to a specific
  1687. * display, they can only be repositioned programmatically via
  1688. * SDL_SetWindowFullscreenMode().
  1689. *
  1690. * On some windowing systems this request is asynchronous and the new
  1691. * coordinates may not have have been applied immediately upon the return of
  1692. * this function. If an immediate change is required, call SDL_SyncWindow() to
  1693. * block until the changes have taken effect.
  1694. *
  1695. * When the window position changes, an SDL_EVENT_WINDOW_MOVED event will be
  1696. * emitted with the window's new coordinates. Note that the new coordinates
  1697. * may not match the exact coordinates requested, as some windowing systems
  1698. * can restrict the position of the window in certain scenarios (e.g.
  1699. * constraining the position so the window is always within desktop bounds).
  1700. * Additionally, as this is just a request, it can be denied by the windowing
  1701. * system.
  1702. *
  1703. * \param window the window to reposition.
  1704. * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
  1705. * `SDL_WINDOWPOS_UNDEFINED`.
  1706. * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
  1707. * `SDL_WINDOWPOS_UNDEFINED`.
  1708. * \returns true on success or false on failure; call SDL_GetError() for more
  1709. * information.
  1710. *
  1711. * \threadsafety This function should only be called on the main thread.
  1712. *
  1713. * \since This function is available since SDL 3.2.0.
  1714. *
  1715. * \sa SDL_GetWindowPosition
  1716. * \sa SDL_SyncWindow
  1717. */
  1718. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
  1719. /**
  1720. * Get the position of a window.
  1721. *
  1722. * This is the current position of the window as last reported by the
  1723. * windowing system.
  1724. *
  1725. * If you do not need the value for one of the positions a NULL may be passed
  1726. * in the `x` or `y` parameter.
  1727. *
  1728. * \param window the window to query.
  1729. * \param x a pointer filled in with the x position of the window, may be
  1730. * NULL.
  1731. * \param y a pointer filled in with the y position of the window, may be
  1732. * NULL.
  1733. * \returns true on success or false on failure; call SDL_GetError() for more
  1734. * information.
  1735. *
  1736. * \threadsafety This function should only be called on the main thread.
  1737. *
  1738. * \since This function is available since SDL 3.2.0.
  1739. *
  1740. * \sa SDL_SetWindowPosition
  1741. */
  1742. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
  1743. /**
  1744. * Request that the size of a window's client area be set.
  1745. *
  1746. * If the window is in a fullscreen or maximized state, this request has no
  1747. * effect.
  1748. *
  1749. * To change the exclusive fullscreen mode of a window, use
  1750. * SDL_SetWindowFullscreenMode().
  1751. *
  1752. * On some windowing systems, this request is asynchronous and the new window
  1753. * size may not have have been applied immediately upon the return of this
  1754. * function. If an immediate change is required, call SDL_SyncWindow() to
  1755. * block until the changes have taken effect.
  1756. *
  1757. * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be
  1758. * emitted with the new window dimensions. Note that the new dimensions may
  1759. * not match the exact size requested, as some windowing systems can restrict
  1760. * the window size in certain scenarios (e.g. constraining the size of the
  1761. * content area to remain within the usable desktop bounds). Additionally, as
  1762. * this is just a request, it can be denied by the windowing system.
  1763. *
  1764. * \param window the window to change.
  1765. * \param w the width of the window, must be > 0.
  1766. * \param h the height of the window, must be > 0.
  1767. * \returns true on success or false on failure; call SDL_GetError() for more
  1768. * information.
  1769. *
  1770. * \threadsafety This function should only be called on the main thread.
  1771. *
  1772. * \since This function is available since SDL 3.2.0.
  1773. *
  1774. * \sa SDL_GetWindowSize
  1775. * \sa SDL_SetWindowFullscreenMode
  1776. * \sa SDL_SyncWindow
  1777. */
  1778. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
  1779. /**
  1780. * Get the size of a window's client area.
  1781. *
  1782. * The window pixel size may differ from its window coordinate size if the
  1783. * window is on a high pixel density display. Use SDL_GetWindowSizeInPixels()
  1784. * or SDL_GetRenderOutputSize() to get the real client area size in pixels.
  1785. *
  1786. * \param window the window to query the width and height from.
  1787. * \param w a pointer filled in with the width of the window, may be NULL.
  1788. * \param h a pointer filled in with the height of the window, may be NULL.
  1789. * \returns true on success or false on failure; call SDL_GetError() for more
  1790. * information.
  1791. *
  1792. * \threadsafety This function should only be called on the main thread.
  1793. *
  1794. * \since This function is available since SDL 3.2.0.
  1795. *
  1796. * \sa SDL_GetRenderOutputSize
  1797. * \sa SDL_GetWindowSizeInPixels
  1798. * \sa SDL_SetWindowSize
  1799. * \sa SDL_EVENT_WINDOW_RESIZED
  1800. */
  1801. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
  1802. /**
  1803. * Get the safe area for this window.
  1804. *
  1805. * Some devices have portions of the screen which are partially obscured or
  1806. * not interactive, possibly due to on-screen controls, curved edges, camera
  1807. * notches, TV overscan, etc. This function provides the area of the window
  1808. * which is safe to have interactable content. You should continue rendering
  1809. * into the rest of the window, but it should not contain visually important
  1810. * or interactable content.
  1811. *
  1812. * \param window the window to query.
  1813. * \param rect a pointer filled in with the client area that is safe for
  1814. * interactive content.
  1815. * \returns true on success or false on failure; call SDL_GetError() for more
  1816. * information.
  1817. *
  1818. * \threadsafety This function should only be called on the main thread.
  1819. *
  1820. * \since This function is available since SDL 3.2.0.
  1821. */
  1822. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect);
  1823. /**
  1824. * Request that the aspect ratio of a window's client area be set.
  1825. *
  1826. * The aspect ratio is the ratio of width divided by height, e.g. 2560x1600
  1827. * would be 1.6. Larger aspect ratios are wider and smaller aspect ratios are
  1828. * narrower.
  1829. *
  1830. * If, at the time of this request, the window in a fixed-size state, such as
  1831. * maximized or fullscreen, the request will be deferred until the window
  1832. * exits this state and becomes resizable again.
  1833. *
  1834. * On some windowing systems, this request is asynchronous and the new window
  1835. * aspect ratio may not have have been applied immediately upon the return of
  1836. * this function. If an immediate change is required, call SDL_SyncWindow() to
  1837. * block until the changes have taken effect.
  1838. *
  1839. * When the window size changes, an SDL_EVENT_WINDOW_RESIZED event will be
  1840. * emitted with the new window dimensions. Note that the new dimensions may
  1841. * not match the exact aspect ratio requested, as some windowing systems can
  1842. * restrict the window size in certain scenarios (e.g. constraining the size
  1843. * of the content area to remain within the usable desktop bounds).
  1844. * Additionally, as this is just a request, it can be denied by the windowing
  1845. * system.
  1846. *
  1847. * \param window the window to change.
  1848. * \param min_aspect the minimum aspect ratio of the window, or 0.0f for no
  1849. * limit.
  1850. * \param max_aspect the maximum aspect ratio of the window, or 0.0f for no
  1851. * limit.
  1852. * \returns true on success or false on failure; call SDL_GetError() for more
  1853. * information.
  1854. *
  1855. * \threadsafety This function should only be called on the main thread.
  1856. *
  1857. * \since This function is available since SDL 3.2.0.
  1858. *
  1859. * \sa SDL_GetWindowAspectRatio
  1860. * \sa SDL_SyncWindow
  1861. */
  1862. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect);
  1863. /**
  1864. * Get the aspect ratio of a window's client area.
  1865. *
  1866. * \param window the window to query the width and height from.
  1867. * \param min_aspect a pointer filled in with the minimum aspect ratio of the
  1868. * window, may be NULL.
  1869. * \param max_aspect a pointer filled in with the maximum aspect ratio of the
  1870. * window, may be NULL.
  1871. * \returns true on success or false on failure; call SDL_GetError() for more
  1872. * information.
  1873. *
  1874. * \threadsafety This function should only be called on the main thread.
  1875. *
  1876. * \since This function is available since SDL 3.2.0.
  1877. *
  1878. * \sa SDL_SetWindowAspectRatio
  1879. */
  1880. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect);
  1881. /**
  1882. * Get the size of a window's borders (decorations) around the client area.
  1883. *
  1884. * Note: If this function fails (returns false), the size values will be
  1885. * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the
  1886. * window in question was borderless.
  1887. *
  1888. * Note: This function may fail on systems where the window has not yet been
  1889. * decorated by the display server (for example, immediately after calling
  1890. * SDL_CreateWindow). It is recommended that you wait at least until the
  1891. * window has been presented and composited, so that the window system has a
  1892. * chance to decorate the window and provide the border dimensions to SDL.
  1893. *
  1894. * This function also returns false if getting the information is not
  1895. * supported.
  1896. *
  1897. * \param window the window to query the size values of the border
  1898. * (decorations) from.
  1899. * \param top pointer to variable for storing the size of the top border; NULL
  1900. * is permitted.
  1901. * \param left pointer to variable for storing the size of the left border;
  1902. * NULL is permitted.
  1903. * \param bottom pointer to variable for storing the size of the bottom
  1904. * border; NULL is permitted.
  1905. * \param right pointer to variable for storing the size of the right border;
  1906. * NULL is permitted.
  1907. * \returns true on success or false on failure; call SDL_GetError() for more
  1908. * information.
  1909. *
  1910. * \threadsafety This function should only be called on the main thread.
  1911. *
  1912. * \since This function is available since SDL 3.2.0.
  1913. *
  1914. * \sa SDL_GetWindowSize
  1915. */
  1916. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
  1917. /**
  1918. * Get the size of a window's client area, in pixels.
  1919. *
  1920. * \param window the window from which the drawable size should be queried.
  1921. * \param w a pointer to variable for storing the width in pixels, may be
  1922. * NULL.
  1923. * \param h a pointer to variable for storing the height in pixels, may be
  1924. * NULL.
  1925. * \returns true on success or false on failure; call SDL_GetError() for more
  1926. * information.
  1927. *
  1928. * \threadsafety This function should only be called on the main thread.
  1929. *
  1930. * \since This function is available since SDL 3.2.0.
  1931. *
  1932. * \sa SDL_CreateWindow
  1933. * \sa SDL_GetWindowSize
  1934. */
  1935. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
  1936. /**
  1937. * Set the minimum size of a window's client area.
  1938. *
  1939. * \param window the window to change.
  1940. * \param min_w the minimum width of the window, or 0 for no limit.
  1941. * \param min_h the minimum height of the window, or 0 for no limit.
  1942. * \returns true on success or false on failure; call SDL_GetError() for more
  1943. * information.
  1944. *
  1945. * \threadsafety This function should only be called on the main thread.
  1946. *
  1947. * \since This function is available since SDL 3.2.0.
  1948. *
  1949. * \sa SDL_GetWindowMinimumSize
  1950. * \sa SDL_SetWindowMaximumSize
  1951. */
  1952. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
  1953. /**
  1954. * Get the minimum size of a window's client area.
  1955. *
  1956. * \param window the window to query.
  1957. * \param w a pointer filled in with the minimum width of the window, may be
  1958. * NULL.
  1959. * \param h a pointer filled in with the minimum height of the window, may be
  1960. * NULL.
  1961. * \returns true on success or false on failure; call SDL_GetError() for more
  1962. * information.
  1963. *
  1964. * \threadsafety This function should only be called on the main thread.
  1965. *
  1966. * \since This function is available since SDL 3.2.0.
  1967. *
  1968. * \sa SDL_GetWindowMaximumSize
  1969. * \sa SDL_SetWindowMinimumSize
  1970. */
  1971. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
  1972. /**
  1973. * Set the maximum size of a window's client area.
  1974. *
  1975. * \param window the window to change.
  1976. * \param max_w the maximum width of the window, or 0 for no limit.
  1977. * \param max_h the maximum height of the window, or 0 for no limit.
  1978. * \returns true on success or false on failure; call SDL_GetError() for more
  1979. * information.
  1980. *
  1981. * \threadsafety This function should only be called on the main thread.
  1982. *
  1983. * \since This function is available since SDL 3.2.0.
  1984. *
  1985. * \sa SDL_GetWindowMaximumSize
  1986. * \sa SDL_SetWindowMinimumSize
  1987. */
  1988. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
  1989. /**
  1990. * Get the maximum size of a window's client area.
  1991. *
  1992. * \param window the window to query.
  1993. * \param w a pointer filled in with the maximum width of the window, may be
  1994. * NULL.
  1995. * \param h a pointer filled in with the maximum height of the window, may be
  1996. * NULL.
  1997. * \returns true on success or false on failure; call SDL_GetError() for more
  1998. * information.
  1999. *
  2000. * \threadsafety This function should only be called on the main thread.
  2001. *
  2002. * \since This function is available since SDL 3.2.0.
  2003. *
  2004. * \sa SDL_GetWindowMinimumSize
  2005. * \sa SDL_SetWindowMaximumSize
  2006. */
  2007. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
  2008. /**
  2009. * Set the border state of a window.
  2010. *
  2011. * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add
  2012. * or remove the border from the actual window. This is a no-op if the
  2013. * window's border already matches the requested state.
  2014. *
  2015. * You can't change the border state of a fullscreen window.
  2016. *
  2017. * \param window the window of which to change the border state.
  2018. * \param bordered false to remove border, true to add border.
  2019. * \returns true on success or false on failure; call SDL_GetError() for more
  2020. * information.
  2021. *
  2022. * \threadsafety This function should only be called on the main thread.
  2023. *
  2024. * \since This function is available since SDL 3.2.0.
  2025. *
  2026. * \sa SDL_GetWindowFlags
  2027. */
  2028. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowBordered(SDL_Window *window, bool bordered);
  2029. /**
  2030. * Set the user-resizable state of a window.
  2031. *
  2032. * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and
  2033. * allow/disallow user resizing of the window. This is a no-op if the window's
  2034. * resizable state already matches the requested state.
  2035. *
  2036. * You can't change the resizable state of a fullscreen window.
  2037. *
  2038. * \param window the window of which to change the resizable state.
  2039. * \param resizable true to allow resizing, false to disallow.
  2040. * \returns true on success or false on failure; call SDL_GetError() for more
  2041. * information.
  2042. *
  2043. * \threadsafety This function should only be called on the main thread.
  2044. *
  2045. * \since This function is available since SDL 3.2.0.
  2046. *
  2047. * \sa SDL_GetWindowFlags
  2048. */
  2049. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowResizable(SDL_Window *window, bool resizable);
  2050. /**
  2051. * Set the window to always be above the others.
  2052. *
  2053. * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This
  2054. * will bring the window to the front and keep the window above the rest.
  2055. *
  2056. * \param window the window of which to change the always on top state.
  2057. * \param on_top true to set the window always on top, false to disable.
  2058. * \returns true on success or false on failure; call SDL_GetError() for more
  2059. * information.
  2060. *
  2061. * \threadsafety This function should only be called on the main thread.
  2062. *
  2063. * \since This function is available since SDL 3.2.0.
  2064. *
  2065. * \sa SDL_GetWindowFlags
  2066. */
  2067. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, bool on_top);
  2068. /**
  2069. * Set the window to fill the current document space (Emscripten only).
  2070. *
  2071. * This will add or remove the window's `SDL_WINDOW_FILL_DOCUMENT` flag.
  2072. *
  2073. * Currently this flag only applies to the Emscripten target.
  2074. *
  2075. * When enabled, the canvas element fills the entire document. Resize events
  2076. * will be generated as the browser window is resized, as that will adjust the
  2077. * canvas size as well. The canvas will cover anything else on the page,
  2078. * including any controls provided by Emscripten in its generated HTML file
  2079. * (in fact, any elements on the page that aren't the canvas will be moved
  2080. * into a hidden `div` element).
  2081. *
  2082. * Often times this is desirable for a browser-based game, but it means
  2083. * several things that we expect of an SDL window on other platforms might not
  2084. * work as expected, such as minimum window sizes and aspect ratios.
  2085. *
  2086. * \param window the window of which to change the fill-document state.
  2087. * \param fill true to set the window to fill the document, false to disable.
  2088. * \returns true on success or false on failure; call SDL_GetError() for more
  2089. * information.
  2090. *
  2091. * \threadsafety This function should only be called on the main thread.
  2092. *
  2093. * \since This function is available since SDL 3.4.0.
  2094. *
  2095. * \sa SDL_GetWindowFlags
  2096. */
  2097. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFillDocument(SDL_Window *window, bool fill);
  2098. /**
  2099. * Show a window.
  2100. *
  2101. * \param window the window to show.
  2102. * \returns true on success or false on failure; call SDL_GetError() for more
  2103. * information.
  2104. *
  2105. * \threadsafety This function should only be called on the main thread.
  2106. *
  2107. * \since This function is available since SDL 3.2.0.
  2108. *
  2109. * \sa SDL_HideWindow
  2110. * \sa SDL_RaiseWindow
  2111. */
  2112. extern SDL_DECLSPEC bool SDLCALL SDL_ShowWindow(SDL_Window *window);
  2113. /**
  2114. * Hide a window.
  2115. *
  2116. * \param window the window to hide.
  2117. * \returns true on success or false on failure; call SDL_GetError() for more
  2118. * information.
  2119. *
  2120. * \threadsafety This function should only be called on the main thread.
  2121. *
  2122. * \since This function is available since SDL 3.2.0.
  2123. *
  2124. * \sa SDL_ShowWindow
  2125. * \sa SDL_WINDOW_HIDDEN
  2126. */
  2127. extern SDL_DECLSPEC bool SDLCALL SDL_HideWindow(SDL_Window *window);
  2128. /**
  2129. * Request that a window be raised above other windows and gain the input
  2130. * focus.
  2131. *
  2132. * The result of this request is subject to desktop window manager policy,
  2133. * particularly if raising the requested window would result in stealing focus
  2134. * from another application. If the window is successfully raised and gains
  2135. * input focus, an SDL_EVENT_WINDOW_FOCUS_GAINED event will be emitted, and
  2136. * the window will have the SDL_WINDOW_INPUT_FOCUS flag set.
  2137. *
  2138. * \param window the window to raise.
  2139. * \returns true on success or false on failure; call SDL_GetError() for more
  2140. * information.
  2141. *
  2142. * \threadsafety This function should only be called on the main thread.
  2143. *
  2144. * \since This function is available since SDL 3.2.0.
  2145. */
  2146. extern SDL_DECLSPEC bool SDLCALL SDL_RaiseWindow(SDL_Window *window);
  2147. /**
  2148. * Request that the window be made as large as possible.
  2149. *
  2150. * Non-resizable windows can't be maximized. The window must have the
  2151. * SDL_WINDOW_RESIZABLE flag set, or this will have no effect.
  2152. *
  2153. * On some windowing systems this request is asynchronous and the new window
  2154. * state may not have have been applied immediately upon the return of this
  2155. * function. If an immediate change is required, call SDL_SyncWindow() to
  2156. * block until the changes have taken effect.
  2157. *
  2158. * When the window state changes, an SDL_EVENT_WINDOW_MAXIMIZED event will be
  2159. * emitted. Note that, as this is just a request, the windowing system can
  2160. * deny the state change.
  2161. *
  2162. * When maximizing a window, whether the constraints set via
  2163. * SDL_SetWindowMaximumSize() are honored depends on the policy of the window
  2164. * manager. Win32 and macOS enforce the constraints when maximizing, while X11
  2165. * and Wayland window managers may vary.
  2166. *
  2167. * \param window the window to maximize.
  2168. * \returns true on success or false on failure; call SDL_GetError() for more
  2169. * information.
  2170. *
  2171. * \threadsafety This function should only be called on the main thread.
  2172. *
  2173. * \since This function is available since SDL 3.2.0.
  2174. *
  2175. * \sa SDL_MinimizeWindow
  2176. * \sa SDL_RestoreWindow
  2177. * \sa SDL_SyncWindow
  2178. */
  2179. extern SDL_DECLSPEC bool SDLCALL SDL_MaximizeWindow(SDL_Window *window);
  2180. /**
  2181. * Request that the window be minimized to an iconic representation.
  2182. *
  2183. * If the window is in a fullscreen state, this request has no direct effect.
  2184. * It may alter the state the window is returned to when leaving fullscreen.
  2185. *
  2186. * On some windowing systems this request is asynchronous and the new window
  2187. * state may not have been applied immediately upon the return of this
  2188. * function. If an immediate change is required, call SDL_SyncWindow() to
  2189. * block until the changes have taken effect.
  2190. *
  2191. * When the window state changes, an SDL_EVENT_WINDOW_MINIMIZED event will be
  2192. * emitted. Note that, as this is just a request, the windowing system can
  2193. * deny the state change.
  2194. *
  2195. * \param window the window to minimize.
  2196. * \returns true on success or false on failure; call SDL_GetError() for more
  2197. * information.
  2198. *
  2199. * \threadsafety This function should only be called on the main thread.
  2200. *
  2201. * \since This function is available since SDL 3.2.0.
  2202. *
  2203. * \sa SDL_MaximizeWindow
  2204. * \sa SDL_RestoreWindow
  2205. * \sa SDL_SyncWindow
  2206. */
  2207. extern SDL_DECLSPEC bool SDLCALL SDL_MinimizeWindow(SDL_Window *window);
  2208. /**
  2209. * Request that the size and position of a minimized or maximized window be
  2210. * restored.
  2211. *
  2212. * If the window is in a fullscreen state, this request has no direct effect.
  2213. * It may alter the state the window is returned to when leaving fullscreen.
  2214. *
  2215. * On some windowing systems this request is asynchronous and the new window
  2216. * state may not have have been applied immediately upon the return of this
  2217. * function. If an immediate change is required, call SDL_SyncWindow() to
  2218. * block until the changes have taken effect.
  2219. *
  2220. * When the window state changes, an SDL_EVENT_WINDOW_RESTORED event will be
  2221. * emitted. Note that, as this is just a request, the windowing system can
  2222. * deny the state change.
  2223. *
  2224. * \param window the window to restore.
  2225. * \returns true on success or false on failure; call SDL_GetError() for more
  2226. * information.
  2227. *
  2228. * \threadsafety This function should only be called on the main thread.
  2229. *
  2230. * \since This function is available since SDL 3.2.0.
  2231. *
  2232. * \sa SDL_MaximizeWindow
  2233. * \sa SDL_MinimizeWindow
  2234. * \sa SDL_SyncWindow
  2235. */
  2236. extern SDL_DECLSPEC bool SDLCALL SDL_RestoreWindow(SDL_Window *window);
  2237. /**
  2238. * Request that the window's fullscreen state be changed.
  2239. *
  2240. * By default a window in fullscreen state uses borderless fullscreen desktop
  2241. * mode, but a specific exclusive display mode can be set using
  2242. * SDL_SetWindowFullscreenMode().
  2243. *
  2244. * On some windowing systems this request is asynchronous and the new
  2245. * fullscreen state may not have have been applied immediately upon the return
  2246. * of this function. If an immediate change is required, call SDL_SyncWindow()
  2247. * to block until the changes have taken effect.
  2248. *
  2249. * When the window state changes, an SDL_EVENT_WINDOW_ENTER_FULLSCREEN or
  2250. * SDL_EVENT_WINDOW_LEAVE_FULLSCREEN event will be emitted. Note that, as this
  2251. * is just a request, it can be denied by the windowing system.
  2252. *
  2253. * \param window the window to change.
  2254. * \param fullscreen true for fullscreen mode, false for windowed mode.
  2255. * \returns true on success or false on failure; call SDL_GetError() for more
  2256. * information.
  2257. *
  2258. * \threadsafety This function should only be called on the main thread.
  2259. *
  2260. * \since This function is available since SDL 3.2.0.
  2261. *
  2262. * \sa SDL_GetWindowFullscreenMode
  2263. * \sa SDL_SetWindowFullscreenMode
  2264. * \sa SDL_SyncWindow
  2265. * \sa SDL_WINDOW_FULLSCREEN
  2266. */
  2267. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, bool fullscreen);
  2268. /**
  2269. * Block until any pending window state is finalized.
  2270. *
  2271. * On asynchronous windowing systems, this acts as a synchronization barrier
  2272. * for pending window state. It will attempt to wait until any pending window
  2273. * state has been applied and is guaranteed to return within finite time. Note
  2274. * that for how long it can potentially block depends on the underlying window
  2275. * system, as window state changes may involve somewhat lengthy animations
  2276. * that must complete before the window is in its final requested state.
  2277. *
  2278. * On windowing systems where changes are immediate, this does nothing.
  2279. *
  2280. * \param window the window for which to wait for the pending state to be
  2281. * applied.
  2282. * \returns true on success or false if the operation timed out before the
  2283. * window was in the requested state.
  2284. *
  2285. * \threadsafety This function should only be called on the main thread.
  2286. *
  2287. * \since This function is available since SDL 3.2.0.
  2288. *
  2289. * \sa SDL_SetWindowSize
  2290. * \sa SDL_SetWindowPosition
  2291. * \sa SDL_SetWindowFullscreen
  2292. * \sa SDL_MinimizeWindow
  2293. * \sa SDL_MaximizeWindow
  2294. * \sa SDL_RestoreWindow
  2295. * \sa SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS
  2296. */
  2297. extern SDL_DECLSPEC bool SDLCALL SDL_SyncWindow(SDL_Window *window);
  2298. /**
  2299. * Return whether the window has a surface associated with it.
  2300. *
  2301. * \param window the window to query.
  2302. * \returns true if there is a surface associated with the window, or false
  2303. * otherwise.
  2304. *
  2305. * \threadsafety This function should only be called on the main thread.
  2306. *
  2307. * \since This function is available since SDL 3.2.0.
  2308. *
  2309. * \sa SDL_GetWindowSurface
  2310. */
  2311. extern SDL_DECLSPEC bool SDLCALL SDL_WindowHasSurface(SDL_Window *window);
  2312. /**
  2313. * Get the SDL surface associated with the window.
  2314. *
  2315. * A new surface will be created with the optimal format for the window, if
  2316. * necessary. This surface will be freed when the window is destroyed. Do not
  2317. * free this surface.
  2318. *
  2319. * This surface will be invalidated if the window is resized. After resizing a
  2320. * window this function must be called again to return a valid surface.
  2321. *
  2322. * You may not combine this with 3D or the rendering API on this window.
  2323. *
  2324. * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`.
  2325. *
  2326. * \param window the window to query.
  2327. * \returns the surface associated with the window, or NULL on failure; call
  2328. * SDL_GetError() for more information.
  2329. *
  2330. * \threadsafety This function should only be called on the main thread.
  2331. *
  2332. * \since This function is available since SDL 3.2.0.
  2333. *
  2334. * \sa SDL_DestroyWindowSurface
  2335. * \sa SDL_WindowHasSurface
  2336. * \sa SDL_UpdateWindowSurface
  2337. * \sa SDL_UpdateWindowSurfaceRects
  2338. */
  2339. extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window *window);
  2340. /**
  2341. * Toggle VSync for the window surface.
  2342. *
  2343. * When a window surface is created, vsync defaults to
  2344. * SDL_WINDOW_SURFACE_VSYNC_DISABLED.
  2345. *
  2346. * The `vsync` parameter can be 1 to synchronize present with every vertical
  2347. * refresh, 2 to synchronize present with every second vertical refresh, etc.,
  2348. * SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync),
  2349. * or SDL_WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is
  2350. * supported by every driver, so you should check the return value to see
  2351. * whether the requested setting is supported.
  2352. *
  2353. * \param window the window.
  2354. * \param vsync the vertical refresh sync interval.
  2355. * \returns true on success or false on failure; call SDL_GetError() for more
  2356. * information.
  2357. *
  2358. * \threadsafety This function should only be called on the main thread.
  2359. *
  2360. * \since This function is available since SDL 3.2.0.
  2361. *
  2362. * \sa SDL_GetWindowSurfaceVSync
  2363. */
  2364. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync);
  2365. #define SDL_WINDOW_SURFACE_VSYNC_DISABLED 0
  2366. #define SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE (-1)
  2367. /**
  2368. * Get VSync for the window surface.
  2369. *
  2370. * \param window the window to query.
  2371. * \param vsync an int filled with the current vertical refresh sync interval.
  2372. * See SDL_SetWindowSurfaceVSync() for the meaning of the value.
  2373. * \returns true on success or false on failure; call SDL_GetError() for more
  2374. * information.
  2375. *
  2376. * \threadsafety This function should only be called on the main thread.
  2377. *
  2378. * \since This function is available since SDL 3.2.0.
  2379. *
  2380. * \sa SDL_SetWindowSurfaceVSync
  2381. */
  2382. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync);
  2383. /**
  2384. * Copy the window surface to the screen.
  2385. *
  2386. * This is the function you use to reflect any changes to the surface on the
  2387. * screen.
  2388. *
  2389. * This function is equivalent to the SDL 1.2 API SDL_Flip().
  2390. *
  2391. * \param window the window to update.
  2392. * \returns true on success or false on failure; call SDL_GetError() for more
  2393. * information.
  2394. *
  2395. * \threadsafety This function should only be called on the main thread.
  2396. *
  2397. * \since This function is available since SDL 3.2.0.
  2398. *
  2399. * \sa SDL_GetWindowSurface
  2400. * \sa SDL_UpdateWindowSurfaceRects
  2401. */
  2402. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
  2403. /**
  2404. * Copy areas of the window surface to the screen.
  2405. *
  2406. * This is the function you use to reflect changes to portions of the surface
  2407. * on the screen.
  2408. *
  2409. * This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
  2410. *
  2411. * Note that this function will update _at least_ the rectangles specified,
  2412. * but this is only intended as an optimization; in practice, this might
  2413. * update more of the screen (or all of the screen!), depending on what method
  2414. * SDL uses to send pixels to the system.
  2415. *
  2416. * \param window the window to update.
  2417. * \param rects an array of SDL_Rect structures representing areas of the
  2418. * surface to copy, in pixels.
  2419. * \param numrects the number of rectangles.
  2420. * \returns true on success or false on failure; call SDL_GetError() for more
  2421. * information.
  2422. *
  2423. * \threadsafety This function should only be called on the main thread.
  2424. *
  2425. * \since This function is available since SDL 3.2.0.
  2426. *
  2427. * \sa SDL_GetWindowSurface
  2428. * \sa SDL_UpdateWindowSurface
  2429. */
  2430. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
  2431. /**
  2432. * Destroy the surface associated with the window.
  2433. *
  2434. * \param window the window to update.
  2435. * \returns true on success or false on failure; call SDL_GetError() for more
  2436. * information.
  2437. *
  2438. * \threadsafety This function should only be called on the main thread.
  2439. *
  2440. * \since This function is available since SDL 3.2.0.
  2441. *
  2442. * \sa SDL_GetWindowSurface
  2443. * \sa SDL_WindowHasSurface
  2444. */
  2445. extern SDL_DECLSPEC bool SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
  2446. /**
  2447. * Set a window's keyboard grab mode.
  2448. *
  2449. * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or
  2450. * the Meta/Super key. Note that not all system keyboard shortcuts can be
  2451. * captured by applications (one example is Ctrl+Alt+Del on Windows).
  2452. *
  2453. * This is primarily intended for specialized applications such as VNC clients
  2454. * or VM frontends. Normal games should not use keyboard grab.
  2455. *
  2456. * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the
  2457. * window is full-screen to ensure the user is not trapped in your
  2458. * application. If you have a custom keyboard shortcut to exit fullscreen
  2459. * mode, you may suppress this behavior with
  2460. * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`.
  2461. *
  2462. * If the caller enables a grab while another window is currently grabbed, the
  2463. * other window loses its grab in favor of the caller's window.
  2464. *
  2465. * \param window the window for which the keyboard grab mode should be set.
  2466. * \param grabbed this is true to grab keyboard, and false to release.
  2467. * \returns true on success or false on failure; call SDL_GetError() for more
  2468. * information.
  2469. *
  2470. * \threadsafety This function should only be called on the main thread.
  2471. *
  2472. * \since This function is available since SDL 3.2.0.
  2473. *
  2474. * \sa SDL_GetWindowKeyboardGrab
  2475. * \sa SDL_SetWindowMouseGrab
  2476. */
  2477. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, bool grabbed);
  2478. /**
  2479. * Set a window's mouse grab mode.
  2480. *
  2481. * Mouse grab confines the mouse cursor to the window.
  2482. *
  2483. * \param window the window for which the mouse grab mode should be set.
  2484. * \param grabbed this is true to grab mouse, and false to release.
  2485. * \returns true on success or false on failure; call SDL_GetError() for more
  2486. * information.
  2487. *
  2488. * \threadsafety This function should only be called on the main thread.
  2489. *
  2490. * \since This function is available since SDL 3.2.0.
  2491. *
  2492. * \sa SDL_GetWindowMouseRect
  2493. * \sa SDL_SetWindowMouseRect
  2494. * \sa SDL_SetWindowKeyboardGrab
  2495. */
  2496. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed);
  2497. /**
  2498. * Get a window's keyboard grab mode.
  2499. *
  2500. * \param window the window to query.
  2501. * \returns true if keyboard is grabbed, and false otherwise.
  2502. *
  2503. * \threadsafety This function should only be called on the main thread.
  2504. *
  2505. * \since This function is available since SDL 3.2.0.
  2506. *
  2507. * \sa SDL_SetWindowKeyboardGrab
  2508. */
  2509. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window *window);
  2510. /**
  2511. * Get a window's mouse grab mode.
  2512. *
  2513. * \param window the window to query.
  2514. * \returns true if mouse is grabbed, and false otherwise.
  2515. *
  2516. * \threadsafety This function should only be called on the main thread.
  2517. *
  2518. * \since This function is available since SDL 3.2.0.
  2519. *
  2520. * \sa SDL_GetWindowMouseRect
  2521. * \sa SDL_SetWindowMouseRect
  2522. * \sa SDL_SetWindowMouseGrab
  2523. * \sa SDL_SetWindowKeyboardGrab
  2524. */
  2525. extern SDL_DECLSPEC bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window *window);
  2526. /**
  2527. * Get the window that currently has an input grab enabled.
  2528. *
  2529. * \returns the window if input is grabbed or NULL otherwise.
  2530. *
  2531. * \threadsafety This function should only be called on the main thread.
  2532. *
  2533. * \since This function is available since SDL 3.2.0.
  2534. *
  2535. * \sa SDL_SetWindowMouseGrab
  2536. * \sa SDL_SetWindowKeyboardGrab
  2537. */
  2538. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void);
  2539. /**
  2540. * Confines the cursor to the specified area of a window.
  2541. *
  2542. * Note that this does NOT grab the cursor, it only defines the area a cursor
  2543. * is restricted to when the window has mouse focus.
  2544. *
  2545. * \param window the window that will be associated with the barrier.
  2546. * \param rect a rectangle area in window-relative coordinates. If NULL the
  2547. * barrier for the specified window will be destroyed.
  2548. * \returns true on success or false on failure; call SDL_GetError() for more
  2549. * information.
  2550. *
  2551. * \threadsafety This function should only be called on the main thread.
  2552. *
  2553. * \since This function is available since SDL 3.2.0.
  2554. *
  2555. * \sa SDL_GetWindowMouseRect
  2556. * \sa SDL_GetWindowMouseGrab
  2557. * \sa SDL_SetWindowMouseGrab
  2558. */
  2559. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
  2560. /**
  2561. * Get the mouse confinement rectangle of a window.
  2562. *
  2563. * \param window the window to query.
  2564. * \returns a pointer to the mouse confinement rectangle of a window, or NULL
  2565. * if there isn't one.
  2566. *
  2567. * \threadsafety This function should only be called on the main thread.
  2568. *
  2569. * \since This function is available since SDL 3.2.0.
  2570. *
  2571. * \sa SDL_SetWindowMouseRect
  2572. * \sa SDL_GetWindowMouseGrab
  2573. * \sa SDL_SetWindowMouseGrab
  2574. */
  2575. extern SDL_DECLSPEC const SDL_Rect * SDLCALL SDL_GetWindowMouseRect(SDL_Window *window);
  2576. /**
  2577. * Set the opacity for a window.
  2578. *
  2579. * The parameter `opacity` will be clamped internally between 0.0f
  2580. * (transparent) and 1.0f (opaque).
  2581. *
  2582. * This function also returns false if setting the opacity isn't supported.
  2583. *
  2584. * \param window the window which will be made transparent or opaque.
  2585. * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque).
  2586. * \returns true on success or false on failure; call SDL_GetError() for more
  2587. * information.
  2588. *
  2589. * \threadsafety This function should only be called on the main thread.
  2590. *
  2591. * \since This function is available since SDL 3.2.0.
  2592. *
  2593. * \sa SDL_GetWindowOpacity
  2594. */
  2595. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity);
  2596. /**
  2597. * Get the opacity of a window.
  2598. *
  2599. * If transparency isn't supported on this platform, opacity will be returned
  2600. * as 1.0f without error.
  2601. *
  2602. * \param window the window to get the current opacity value from.
  2603. * \returns the opacity, (0.0f - transparent, 1.0f - opaque), or -1.0f on
  2604. * failure; call SDL_GetError() for more information.
  2605. *
  2606. * \threadsafety This function should only be called on the main thread.
  2607. *
  2608. * \since This function is available since SDL 3.2.0.
  2609. *
  2610. * \sa SDL_SetWindowOpacity
  2611. */
  2612. extern SDL_DECLSPEC float SDLCALL SDL_GetWindowOpacity(SDL_Window *window);
  2613. /**
  2614. * Set the window as a child of a parent window.
  2615. *
  2616. * If the window is already the child of an existing window, it will be
  2617. * reparented to the new owner. Setting the parent window to NULL unparents
  2618. * the window and removes child window status.
  2619. *
  2620. * If a parent window is hidden or destroyed, the operation will be
  2621. * recursively applied to child windows. Child windows hidden with the parent
  2622. * that did not have their hidden status explicitly set will be restored when
  2623. * the parent is shown.
  2624. *
  2625. * Attempting to set the parent of a window that is currently in the modal
  2626. * state will fail. Use SDL_SetWindowModal() to cancel the modal status before
  2627. * attempting to change the parent.
  2628. *
  2629. * Popup windows cannot change parents and attempts to do so will fail.
  2630. *
  2631. * Setting a parent window that is currently the sibling or descendent of the
  2632. * child window results in undefined behavior.
  2633. *
  2634. * \param window the window that should become the child of a parent.
  2635. * \param parent the new parent window for the child window.
  2636. * \returns true on success or false on failure; call SDL_GetError() for more
  2637. * information.
  2638. *
  2639. * \threadsafety This function should only be called on the main thread.
  2640. *
  2641. * \since This function is available since SDL 3.2.0.
  2642. *
  2643. * \sa SDL_SetWindowModal
  2644. */
  2645. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent);
  2646. /**
  2647. * Toggle the state of the window as modal.
  2648. *
  2649. * To enable modal status on a window, the window must currently be the child
  2650. * window of a parent, or toggling modal status on will fail.
  2651. *
  2652. * \param window the window on which to set the modal state.
  2653. * \param modal true to toggle modal status on, false to toggle it off.
  2654. * \returns true on success or false on failure; call SDL_GetError() for more
  2655. * information.
  2656. *
  2657. * \threadsafety This function should only be called on the main thread.
  2658. *
  2659. * \since This function is available since SDL 3.2.0.
  2660. *
  2661. * \sa SDL_SetWindowParent
  2662. * \sa SDL_WINDOW_MODAL
  2663. */
  2664. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowModal(SDL_Window *window, bool modal);
  2665. /**
  2666. * Set whether the window may have input focus.
  2667. *
  2668. * \param window the window to set focusable state.
  2669. * \param focusable true to allow input focus, false to not allow input focus.
  2670. * \returns true on success or false on failure; call SDL_GetError() for more
  2671. * information.
  2672. *
  2673. * \threadsafety This function should only be called on the main thread.
  2674. *
  2675. * \since This function is available since SDL 3.2.0.
  2676. */
  2677. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowFocusable(SDL_Window *window, bool focusable);
  2678. /**
  2679. * Display the system-level window menu.
  2680. *
  2681. * This default window menu is provided by the system and on some platforms
  2682. * provides functionality for setting or changing privileged state on the
  2683. * window, such as moving it between workspaces or displays, or toggling the
  2684. * always-on-top property.
  2685. *
  2686. * On platforms or desktops where this is unsupported, this function does
  2687. * nothing.
  2688. *
  2689. * \param window the window for which the menu will be displayed.
  2690. * \param x the x coordinate of the menu, relative to the origin (top-left) of
  2691. * the client area.
  2692. * \param y the y coordinate of the menu, relative to the origin (top-left) of
  2693. * the client area.
  2694. * \returns true on success or false on failure; call SDL_GetError() for more
  2695. * information.
  2696. *
  2697. * \threadsafety This function should only be called on the main thread.
  2698. *
  2699. * \since This function is available since SDL 3.2.0.
  2700. */
  2701. extern SDL_DECLSPEC bool SDLCALL SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
  2702. /**
  2703. * Possible return values from the SDL_HitTest callback.
  2704. *
  2705. * \threadsafety This function should only be called on the main thread.
  2706. *
  2707. * \since This enum is available since SDL 3.2.0.
  2708. *
  2709. * \sa SDL_HitTest
  2710. */
  2711. typedef enum SDL_HitTestResult
  2712. {
  2713. SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */
  2714. SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */
  2715. SDL_HITTEST_RESIZE_TOPLEFT, /**< Region is the resizable top-left corner border. */
  2716. SDL_HITTEST_RESIZE_TOP, /**< Region is the resizable top border. */
  2717. SDL_HITTEST_RESIZE_TOPRIGHT, /**< Region is the resizable top-right corner border. */
  2718. SDL_HITTEST_RESIZE_RIGHT, /**< Region is the resizable right border. */
  2719. SDL_HITTEST_RESIZE_BOTTOMRIGHT, /**< Region is the resizable bottom-right corner border. */
  2720. SDL_HITTEST_RESIZE_BOTTOM, /**< Region is the resizable bottom border. */
  2721. SDL_HITTEST_RESIZE_BOTTOMLEFT, /**< Region is the resizable bottom-left corner border. */
  2722. SDL_HITTEST_RESIZE_LEFT /**< Region is the resizable left border. */
  2723. } SDL_HitTestResult;
  2724. /**
  2725. * Callback used for hit-testing.
  2726. *
  2727. * \param win the SDL_Window where hit-testing was set on.
  2728. * \param area an SDL_Point which should be hit-tested.
  2729. * \param data what was passed as `callback_data` to SDL_SetWindowHitTest().
  2730. * \returns an SDL_HitTestResult value.
  2731. *
  2732. * \sa SDL_SetWindowHitTest
  2733. */
  2734. typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win,
  2735. const SDL_Point *area,
  2736. void *data);
  2737. /**
  2738. * Provide a callback that decides if a window region has special properties.
  2739. *
  2740. * Normally windows are dragged and resized by decorations provided by the
  2741. * system window manager (a title bar, borders, etc), but for some apps, it
  2742. * makes sense to drag them from somewhere else inside the window itself; for
  2743. * example, one might have a borderless window that wants to be draggable from
  2744. * any part, or simulate its own title bar, etc.
  2745. *
  2746. * This function lets the app provide a callback that designates pieces of a
  2747. * given window as special. This callback is run during event processing if we
  2748. * need to tell the OS to treat a region of the window specially; the use of
  2749. * this callback is known as "hit testing."
  2750. *
  2751. * Mouse input may not be delivered to your application if it is within a
  2752. * special area; the OS will often apply that input to moving the window or
  2753. * resizing the window and not deliver it to the application.
  2754. *
  2755. * Specifying NULL for a callback disables hit-testing. Hit-testing is
  2756. * disabled by default.
  2757. *
  2758. * Platforms that don't support this functionality will return false
  2759. * unconditionally, even if you're attempting to disable hit-testing.
  2760. *
  2761. * Your callback may fire at any time, and its firing does not indicate any
  2762. * specific behavior (for example, on Windows, this certainly might fire when
  2763. * the OS is deciding whether to drag your window, but it fires for lots of
  2764. * other reasons, too, some unrelated to anything you probably care about _and
  2765. * when the mouse isn't actually at the location it is testing_). Since this
  2766. * can fire at any time, you should try to keep your callback efficient,
  2767. * devoid of allocations, etc.
  2768. *
  2769. * \param window the window to set hit-testing on.
  2770. * \param callback the function to call when doing a hit-test.
  2771. * \param callback_data an app-defined void pointer passed to **callback**.
  2772. * \returns true on success or false on failure; call SDL_GetError() for more
  2773. * information.
  2774. *
  2775. * \threadsafety This function should only be called on the main thread.
  2776. *
  2777. * \since This function is available since SDL 3.2.0.
  2778. */
  2779. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
  2780. /**
  2781. * Set the shape of a transparent window.
  2782. *
  2783. * This sets the alpha channel of a transparent window and any fully
  2784. * transparent areas are also transparent to mouse clicks. If you are using
  2785. * something besides the SDL render API, then you are responsible for drawing
  2786. * the alpha channel of the window to match the shape alpha channel to get
  2787. * consistent cross-platform results.
  2788. *
  2789. * The shape is copied inside this function, so you can free it afterwards. If
  2790. * your shape surface changes, you should call SDL_SetWindowShape() again to
  2791. * update the window. This is an expensive operation, so should be done
  2792. * sparingly.
  2793. *
  2794. * The window must have been created with the SDL_WINDOW_TRANSPARENT flag.
  2795. *
  2796. * \param window the window.
  2797. * \param shape the surface representing the shape of the window, or NULL to
  2798. * remove any current shape.
  2799. * \returns true on success or false on failure; call SDL_GetError() for more
  2800. * information.
  2801. *
  2802. * \threadsafety This function should only be called on the main thread.
  2803. *
  2804. * \since This function is available since SDL 3.2.0.
  2805. */
  2806. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape);
  2807. /**
  2808. * Request a window to demand attention from the user.
  2809. *
  2810. * \param window the window to be flashed.
  2811. * \param operation the operation to perform.
  2812. * \returns true on success or false on failure; call SDL_GetError() for more
  2813. * information.
  2814. *
  2815. * \threadsafety This function should only be called on the main thread.
  2816. *
  2817. * \since This function is available since SDL 3.2.0.
  2818. */
  2819. extern SDL_DECLSPEC bool SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
  2820. /**
  2821. * Sets the state of the progress bar for the given window’s taskbar icon.
  2822. *
  2823. * \param window the window whose progress state is to be modified.
  2824. * \param state the progress state. `SDL_PROGRESS_STATE_NONE` stops displaying
  2825. * the progress bar.
  2826. * \returns true on success or false on failure; call SDL_GetError() for more
  2827. * information.
  2828. *
  2829. * \threadsafety This function should only be called on the main thread.
  2830. *
  2831. * \since This function is available since SDL 3.4.0.
  2832. */
  2833. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressState(SDL_Window *window, SDL_ProgressState state);
  2834. /**
  2835. * Get the state of the progress bar for the given window’s taskbar icon.
  2836. *
  2837. * \param window the window to get the current progress state from.
  2838. * \returns the progress state, or `SDL_PROGRESS_STATE_INVALID` on failure;
  2839. * call SDL_GetError() for more information.
  2840. *
  2841. * \threadsafety This function should only be called on the main thread.
  2842. *
  2843. * \since This function is available since SDL 3.4.0.
  2844. */
  2845. extern SDL_DECLSPEC SDL_ProgressState SDLCALL SDL_GetWindowProgressState(SDL_Window *window);
  2846. /**
  2847. * Sets the value of the progress bar for the given window’s taskbar icon.
  2848. *
  2849. * \param window the window whose progress value is to be modified.
  2850. * \param value the progress value in the range of [0.0f - 1.0f]. If the value
  2851. * is outside the valid range, it gets clamped.
  2852. * \returns true on success or false on failure; call SDL_GetError() for more
  2853. * information.
  2854. *
  2855. * \threadsafety This function should only be called on the main thread.
  2856. *
  2857. * \since This function is available since SDL 3.4.0.
  2858. */
  2859. extern SDL_DECLSPEC bool SDLCALL SDL_SetWindowProgressValue(SDL_Window *window, float value);
  2860. /**
  2861. * Get the value of the progress bar for the given window’s taskbar icon.
  2862. *
  2863. * \param window the window to get the current progress value from.
  2864. * \returns the progress value in the range of [0.0f - 1.0f], or -1.0f on
  2865. * failure; call SDL_GetError() for more information.
  2866. *
  2867. * \threadsafety This function should only be called on the main thread.
  2868. *
  2869. * \since This function is available since SDL 3.4.0.
  2870. */
  2871. extern SDL_DECLSPEC float SDLCALL SDL_GetWindowProgressValue(SDL_Window *window);
  2872. /**
  2873. * Destroy a window.
  2874. *
  2875. * Any child windows owned by the window will be recursively destroyed as
  2876. * well.
  2877. *
  2878. * Note that on some platforms, the visible window may not actually be removed
  2879. * from the screen until the SDL event loop is pumped again, even though the
  2880. * SDL_Window is no longer valid after this call.
  2881. *
  2882. * \param window the window to destroy.
  2883. *
  2884. * \threadsafety This function should only be called on the main thread.
  2885. *
  2886. * \since This function is available since SDL 3.2.0.
  2887. *
  2888. * \sa SDL_CreatePopupWindow
  2889. * \sa SDL_CreateWindow
  2890. * \sa SDL_CreateWindowWithProperties
  2891. */
  2892. extern SDL_DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
  2893. /**
  2894. * Check whether the screensaver is currently enabled.
  2895. *
  2896. * The screensaver is disabled by default.
  2897. *
  2898. * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`.
  2899. *
  2900. * \returns true if the screensaver is enabled, false if it is disabled.
  2901. *
  2902. * \threadsafety This function should only be called on the main thread.
  2903. *
  2904. * \since This function is available since SDL 3.2.0.
  2905. *
  2906. * \sa SDL_DisableScreenSaver
  2907. * \sa SDL_EnableScreenSaver
  2908. */
  2909. extern SDL_DECLSPEC bool SDLCALL SDL_ScreenSaverEnabled(void);
  2910. /**
  2911. * Allow the screen to be blanked by a screen saver.
  2912. *
  2913. * \returns true on success or false on failure; call SDL_GetError() for more
  2914. * information.
  2915. *
  2916. * \threadsafety This function should only be called on the main thread.
  2917. *
  2918. * \since This function is available since SDL 3.2.0.
  2919. *
  2920. * \sa SDL_DisableScreenSaver
  2921. * \sa SDL_ScreenSaverEnabled
  2922. */
  2923. extern SDL_DECLSPEC bool SDLCALL SDL_EnableScreenSaver(void);
  2924. /**
  2925. * Prevent the screen from being blanked by a screen saver.
  2926. *
  2927. * If you disable the screensaver, it is automatically re-enabled when SDL
  2928. * quits.
  2929. *
  2930. * The screensaver is disabled by default, but this may by changed by
  2931. * SDL_HINT_VIDEO_ALLOW_SCREENSAVER.
  2932. *
  2933. * \returns true on success or false on failure; call SDL_GetError() for more
  2934. * information.
  2935. *
  2936. * \threadsafety This function should only be called on the main thread.
  2937. *
  2938. * \since This function is available since SDL 3.2.0.
  2939. *
  2940. * \sa SDL_EnableScreenSaver
  2941. * \sa SDL_ScreenSaverEnabled
  2942. */
  2943. extern SDL_DECLSPEC bool SDLCALL SDL_DisableScreenSaver(void);
  2944. /**
  2945. * \name OpenGL support functions
  2946. */
  2947. /* @{ */
  2948. /**
  2949. * Dynamically load an OpenGL library.
  2950. *
  2951. * This should be done after initializing the video driver, but before
  2952. * creating any OpenGL windows. If no OpenGL library is loaded, the default
  2953. * library will be loaded upon creation of the first OpenGL window.
  2954. *
  2955. * If you do this, you need to retrieve all of the GL functions used in your
  2956. * program from the dynamic library using SDL_GL_GetProcAddress().
  2957. *
  2958. * \param path the platform dependent OpenGL library name, or NULL to open the
  2959. * default OpenGL library.
  2960. * \returns true on success or false on failure; call SDL_GetError() for more
  2961. * information.
  2962. *
  2963. * \threadsafety This function should only be called on the main thread.
  2964. *
  2965. * \since This function is available since SDL 3.2.0.
  2966. *
  2967. * \sa SDL_GL_GetProcAddress
  2968. * \sa SDL_GL_UnloadLibrary
  2969. */
  2970. extern SDL_DECLSPEC bool SDLCALL SDL_GL_LoadLibrary(const char *path);
  2971. /**
  2972. * Get an OpenGL function by name.
  2973. *
  2974. * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all
  2975. * GL functions must be retrieved this way. Usually this is used to retrieve
  2976. * function pointers to OpenGL extensions.
  2977. *
  2978. * There are some quirks to looking up OpenGL functions that require some
  2979. * extra care from the application. If you code carefully, you can handle
  2980. * these quirks without any platform-specific code, though:
  2981. *
  2982. * - On Windows, function pointers are specific to the current GL context;
  2983. * this means you need to have created a GL context and made it current
  2984. * before calling SDL_GL_GetProcAddress(). If you recreate your context or
  2985. * create a second context, you should assume that any existing function
  2986. * pointers aren't valid to use with it. This is (currently) a
  2987. * Windows-specific limitation, and in practice lots of drivers don't suffer
  2988. * this limitation, but it is still the way the wgl API is documented to
  2989. * work and you should expect crashes if you don't respect it. Store a copy
  2990. * of the function pointers that comes and goes with context lifespan.
  2991. * - On X11, function pointers returned by this function are valid for any
  2992. * context, and can even be looked up before a context is created at all.
  2993. * This means that, for at least some common OpenGL implementations, if you
  2994. * look up a function that doesn't exist, you'll get a non-NULL result that
  2995. * is _NOT_ safe to call. You must always make sure the function is actually
  2996. * available for a given GL context before calling it, by checking for the
  2997. * existence of the appropriate extension with SDL_GL_ExtensionSupported(),
  2998. * or verifying that the version of OpenGL you're using offers the function
  2999. * as core functionality.
  3000. * - Some OpenGL drivers, on all platforms, *will* return NULL if a function
  3001. * isn't supported, but you can't count on this behavior. Check for
  3002. * extensions you use, and if you get a NULL anyway, act as if that
  3003. * extension wasn't available. This is probably a bug in the driver, but you
  3004. * can code defensively for this scenario anyhow.
  3005. * - Just because you're on Linux/Unix, don't assume you'll be using X11.
  3006. * Next-gen display servers are waiting to replace it, and may or may not
  3007. * make the same promises about function pointers.
  3008. * - OpenGL function pointers must be declared `APIENTRY` as in the example
  3009. * code. This will ensure the proper calling convention is followed on
  3010. * platforms where this matters (Win32) thereby avoiding stack corruption.
  3011. *
  3012. * \param proc the name of an OpenGL function.
  3013. * \returns a pointer to the named OpenGL function. The returned pointer
  3014. * should be cast to the appropriate function signature.
  3015. *
  3016. * \threadsafety This function should only be called on the main thread.
  3017. *
  3018. * \since This function is available since SDL 3.2.0.
  3019. *
  3020. * \sa SDL_GL_ExtensionSupported
  3021. * \sa SDL_GL_LoadLibrary
  3022. * \sa SDL_GL_UnloadLibrary
  3023. */
  3024. extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc);
  3025. /**
  3026. * Get an EGL library function by name.
  3027. *
  3028. * If an EGL library is loaded, this function allows applications to get entry
  3029. * points for EGL functions. This is useful to provide to an EGL API and
  3030. * extension loader.
  3031. *
  3032. * \param proc the name of an EGL function.
  3033. * \returns a pointer to the named EGL function. The returned pointer should
  3034. * be cast to the appropriate function signature.
  3035. *
  3036. * \threadsafety This function should only be called on the main thread.
  3037. *
  3038. * \since This function is available since SDL 3.2.0.
  3039. *
  3040. * \sa SDL_EGL_GetCurrentDisplay
  3041. */
  3042. extern SDL_DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
  3043. /**
  3044. * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
  3045. *
  3046. * \threadsafety This function should only be called on the main thread.
  3047. *
  3048. * \since This function is available since SDL 3.2.0.
  3049. *
  3050. * \sa SDL_GL_LoadLibrary
  3051. */
  3052. extern SDL_DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
  3053. /**
  3054. * Check if an OpenGL extension is supported for the current context.
  3055. *
  3056. * This function operates on the current GL context; you must have created a
  3057. * context and it must be current before calling this function. Do not assume
  3058. * that all contexts you create will have the same set of extensions
  3059. * available, or that recreating an existing context will offer the same
  3060. * extensions again.
  3061. *
  3062. * While it's probably not a massive overhead, this function is not an O(1)
  3063. * operation. Check the extensions you care about after creating the GL
  3064. * context and save that information somewhere instead of calling the function
  3065. * every time you need to know.
  3066. *
  3067. * \param extension the name of the extension to check.
  3068. * \returns true if the extension is supported, false otherwise.
  3069. *
  3070. * \threadsafety This function should only be called on the main thread.
  3071. *
  3072. * \since This function is available since SDL 3.2.0.
  3073. */
  3074. extern SDL_DECLSPEC bool SDLCALL SDL_GL_ExtensionSupported(const char *extension);
  3075. /**
  3076. * Reset all previously set OpenGL context attributes to their default values.
  3077. *
  3078. * \threadsafety This function should only be called on the main thread.
  3079. *
  3080. * \since This function is available since SDL 3.2.0.
  3081. *
  3082. * \sa SDL_GL_GetAttribute
  3083. * \sa SDL_GL_SetAttribute
  3084. */
  3085. extern SDL_DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
  3086. /**
  3087. * Set an OpenGL window attribute before window creation.
  3088. *
  3089. * This function sets the OpenGL attribute `attr` to `value`. The requested
  3090. * attributes should be set before creating an OpenGL window. You should use
  3091. * SDL_GL_GetAttribute() to check the values after creating the OpenGL
  3092. * context, since the values obtained can differ from the requested ones.
  3093. *
  3094. * \param attr an enum value specifying the OpenGL attribute to set.
  3095. * \param value the desired value for the attribute.
  3096. * \returns true on success or false on failure; call SDL_GetError() for more
  3097. * information.
  3098. *
  3099. * \threadsafety This function should only be called on the main thread.
  3100. *
  3101. * \since This function is available since SDL 3.2.0.
  3102. *
  3103. * \sa SDL_GL_CreateContext
  3104. * \sa SDL_GL_GetAttribute
  3105. * \sa SDL_GL_ResetAttributes
  3106. */
  3107. extern SDL_DECLSPEC bool SDLCALL SDL_GL_SetAttribute(SDL_GLAttr attr, int value);
  3108. /**
  3109. * Get the actual value for an attribute from the current context.
  3110. *
  3111. * \param attr an SDL_GLAttr enum value specifying the OpenGL attribute to
  3112. * get.
  3113. * \param value a pointer filled in with the current value of `attr`.
  3114. * \returns true on success or false on failure; call SDL_GetError() for more
  3115. * information.
  3116. *
  3117. * \threadsafety This function should only be called on the main thread.
  3118. *
  3119. * \since This function is available since SDL 3.2.0.
  3120. *
  3121. * \sa SDL_GL_ResetAttributes
  3122. * \sa SDL_GL_SetAttribute
  3123. */
  3124. extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetAttribute(SDL_GLAttr attr, int *value);
  3125. /**
  3126. * Create an OpenGL context for an OpenGL window, and make it current.
  3127. *
  3128. * The OpenGL context will be created with the current states set through
  3129. * SDL_GL_SetAttribute().
  3130. *
  3131. * The SDL_Window specified must have been created with the SDL_WINDOW_OPENGL
  3132. * flag, or context creation will fail.
  3133. *
  3134. * Windows users new to OpenGL should note that, for historical reasons, GL
  3135. * functions added after OpenGL version 1.1 are not available by default.
  3136. * Those functions must be loaded at run-time, either with an OpenGL
  3137. * extension-handling library or with SDL_GL_GetProcAddress() and its related
  3138. * functions.
  3139. *
  3140. * SDL_GLContext is opaque to the application.
  3141. *
  3142. * \param window the window to associate with the context.
  3143. * \returns the OpenGL context associated with `window` or NULL on failure;
  3144. * call SDL_GetError() for more information.
  3145. *
  3146. * \threadsafety This function should only be called on the main thread.
  3147. *
  3148. * \since This function is available since SDL 3.2.0.
  3149. *
  3150. * \sa SDL_GL_DestroyContext
  3151. * \sa SDL_GL_MakeCurrent
  3152. */
  3153. extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window);
  3154. /**
  3155. * Set up an OpenGL context for rendering into an OpenGL window.
  3156. *
  3157. * The context must have been created with a compatible window.
  3158. *
  3159. * \param window the window to associate with the context.
  3160. * \param context the OpenGL context to associate with the window.
  3161. * \returns true on success or false on failure; call SDL_GetError() for more
  3162. * information.
  3163. *
  3164. * \threadsafety This function should only be called on the main thread.
  3165. *
  3166. * \since This function is available since SDL 3.2.0.
  3167. *
  3168. * \sa SDL_GL_CreateContext
  3169. */
  3170. extern SDL_DECLSPEC bool SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
  3171. /**
  3172. * Get the currently active OpenGL window.
  3173. *
  3174. * \returns the currently active OpenGL window on success or NULL on failure;
  3175. * call SDL_GetError() for more information.
  3176. *
  3177. * \threadsafety This function should only be called on the main thread.
  3178. *
  3179. * \since This function is available since SDL 3.2.0.
  3180. */
  3181. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GL_GetCurrentWindow(void);
  3182. /**
  3183. * Get the currently active OpenGL context.
  3184. *
  3185. * \returns the currently active OpenGL context or NULL on failure; call
  3186. * SDL_GetError() for more information.
  3187. *
  3188. * \threadsafety This function should only be called on the main thread.
  3189. *
  3190. * \since This function is available since SDL 3.2.0.
  3191. *
  3192. * \sa SDL_GL_MakeCurrent
  3193. */
  3194. extern SDL_DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
  3195. /**
  3196. * Get the currently active EGL display.
  3197. *
  3198. * \returns the currently active EGL display or NULL on failure; call
  3199. * SDL_GetError() for more information.
  3200. *
  3201. * \threadsafety This function should only be called on the main thread.
  3202. *
  3203. * \since This function is available since SDL 3.2.0.
  3204. */
  3205. extern SDL_DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentDisplay(void);
  3206. /**
  3207. * Get the currently active EGL config.
  3208. *
  3209. * \returns the currently active EGL config or NULL on failure; call
  3210. * SDL_GetError() for more information.
  3211. *
  3212. * \threadsafety This function should only be called on the main thread.
  3213. *
  3214. * \since This function is available since SDL 3.2.0.
  3215. */
  3216. extern SDL_DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentConfig(void);
  3217. /**
  3218. * Get the EGL surface associated with the window.
  3219. *
  3220. * \param window the window to query.
  3221. * \returns the EGLSurface pointer associated with the window, or NULL on
  3222. * failure.
  3223. *
  3224. * \threadsafety This function should only be called on the main thread.
  3225. *
  3226. * \since This function is available since SDL 3.2.0.
  3227. */
  3228. extern SDL_DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowSurface(SDL_Window *window);
  3229. /**
  3230. * Sets the callbacks for defining custom EGLAttrib arrays for EGL
  3231. * initialization.
  3232. *
  3233. * Callbacks that aren't needed can be set to NULL.
  3234. *
  3235. * NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes.
  3236. *
  3237. * \param platformAttribCallback callback for attributes to pass to
  3238. * eglGetPlatformDisplay. May be NULL.
  3239. * \param surfaceAttribCallback callback for attributes to pass to
  3240. * eglCreateSurface. May be NULL.
  3241. * \param contextAttribCallback callback for attributes to pass to
  3242. * eglCreateContext. May be NULL.
  3243. * \param userdata a pointer that is passed to the callbacks.
  3244. *
  3245. * \threadsafety This function should only be called on the main thread.
  3246. *
  3247. * \since This function is available since SDL 3.2.0.
  3248. */
  3249. extern SDL_DECLSPEC void SDLCALL SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback,
  3250. SDL_EGLIntArrayCallback surfaceAttribCallback,
  3251. SDL_EGLIntArrayCallback contextAttribCallback, void *userdata);
  3252. /**
  3253. * Set the swap interval for the current OpenGL context.
  3254. *
  3255. * Some systems allow specifying -1 for the interval, to enable adaptive
  3256. * vsync. Adaptive vsync works the same as vsync, but if you've already missed
  3257. * the vertical retrace for a given frame, it swaps buffers immediately, which
  3258. * might be less jarring for the user during occasional framerate drops. If an
  3259. * application requests adaptive vsync and the system does not support it,
  3260. * this function will fail and return false. In such a case, you should
  3261. * probably retry the call with 1 for the interval.
  3262. *
  3263. * Adaptive vsync is implemented for some glX drivers with
  3264. * GLX_EXT_swap_control_tear, and for some Windows drivers with
  3265. * WGL_EXT_swap_control_tear.
  3266. *
  3267. * Read more on the Khronos wiki:
  3268. * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
  3269. *
  3270. * \param interval 0 for immediate updates, 1 for updates synchronized with
  3271. * the vertical retrace, -1 for adaptive vsync.
  3272. * \returns true on success or false on failure; call SDL_GetError() for more
  3273. * information.
  3274. *
  3275. * \threadsafety This function should only be called on the main thread.
  3276. *
  3277. * \since This function is available since SDL 3.2.0.
  3278. *
  3279. * \sa SDL_GL_GetSwapInterval
  3280. */
  3281. extern SDL_DECLSPEC bool SDLCALL SDL_GL_SetSwapInterval(int interval);
  3282. /**
  3283. * Get the swap interval for the current OpenGL context.
  3284. *
  3285. * If the system can't determine the swap interval, or there isn't a valid
  3286. * current context, this function will set *interval to 0 as a safe default.
  3287. *
  3288. * \param interval output interval value. 0 if there is no vertical retrace
  3289. * synchronization, 1 if the buffer swap is synchronized with
  3290. * the vertical retrace, and -1 if late swaps happen
  3291. * immediately instead of waiting for the next retrace.
  3292. * \returns true on success or false on failure; call SDL_GetError() for more
  3293. * information.
  3294. *
  3295. * \threadsafety This function should only be called on the main thread.
  3296. *
  3297. * \since This function is available since SDL 3.2.0.
  3298. *
  3299. * \sa SDL_GL_SetSwapInterval
  3300. */
  3301. extern SDL_DECLSPEC bool SDLCALL SDL_GL_GetSwapInterval(int *interval);
  3302. /**
  3303. * Update a window with OpenGL rendering.
  3304. *
  3305. * This is used with double-buffered OpenGL contexts, which are the default.
  3306. *
  3307. * On macOS, make sure you bind 0 to the draw framebuffer before swapping the
  3308. * window, otherwise nothing will happen. If you aren't using
  3309. * glBindFramebuffer(), this is the default and you won't have to do anything
  3310. * extra.
  3311. *
  3312. * \param window the window to change.
  3313. * \returns true on success or false on failure; call SDL_GetError() for more
  3314. * information.
  3315. *
  3316. * \threadsafety This function should only be called on the main thread.
  3317. *
  3318. * \since This function is available since SDL 3.2.0.
  3319. */
  3320. extern SDL_DECLSPEC bool SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
  3321. /**
  3322. * Delete an OpenGL context.
  3323. *
  3324. * \param context the OpenGL context to be deleted.
  3325. * \returns true on success or false on failure; call SDL_GetError() for more
  3326. * information.
  3327. *
  3328. * \threadsafety This function should only be called on the main thread.
  3329. *
  3330. * \since This function is available since SDL 3.2.0.
  3331. *
  3332. * \sa SDL_GL_CreateContext
  3333. */
  3334. extern SDL_DECLSPEC bool SDLCALL SDL_GL_DestroyContext(SDL_GLContext context);
  3335. /* @} *//* OpenGL support functions */
  3336. /* Ends C function definitions when using C++ */
  3337. #ifdef __cplusplus
  3338. }
  3339. #endif
  3340. #include <SDL3/SDL_close_code.h>
  3341. #endif /* SDL_video_h_ */