SDL_video.h 95 KB

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