SDL_video.h 102 KB

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