SDL_video.h 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 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_rect.h>
  28. #include <SDL3/SDL_surface.h>
  29. #include <SDL3/SDL_begin_code.h>
  30. /* Set up for C function definitions, even when using C++ */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. typedef Uint32 SDL_DisplayID;
  35. typedef Uint32 SDL_WindowID;
  36. /**
  37. * \brief The structure that defines a display mode
  38. *
  39. * \sa SDL_GetNumDisplayModes()
  40. * \sa SDL_GetDisplayMode()
  41. * \sa SDL_GetDesktopDisplayMode()
  42. * \sa SDL_GetCurrentDisplayMode()
  43. * \sa SDL_GetClosestDisplayMode()
  44. * \sa SDL_SetWindowDisplayMode()
  45. * \sa SDL_GetWindowDisplayMode()
  46. */
  47. typedef struct
  48. {
  49. Uint32 format; /**< pixel format */
  50. int pixel_w; /**< width in pixels (used for creating back buffers) */
  51. int pixel_h; /**< height in pixels (used for creating back buffers) */
  52. int screen_w; /**< width in screen coordinates (used for creating windows) */
  53. int screen_h; /**< height in screen coordinates (used for creating windows) */
  54. float display_scale; /**< scale converting screen coordinates to pixels (e.g. a 2560x1440 screen size mode with 1.5 scale would have 3840x2160 pixels) */
  55. float refresh_rate; /**< refresh rate (or zero for unspecified) */
  56. void *driverdata; /**< driver-specific data, initialize to 0 */
  57. } SDL_DisplayMode;
  58. /**
  59. * \brief The type used to identify a window
  60. *
  61. * \sa SDL_CreateWindow()
  62. * \sa SDL_CreateWindowFrom()
  63. * \sa SDL_DestroyWindow()
  64. * \sa SDL_FlashWindow()
  65. * \sa SDL_GetWindowData()
  66. * \sa SDL_GetWindowFlags()
  67. * \sa SDL_GetWindowGrab()
  68. * \sa SDL_GetWindowKeyboardGrab()
  69. * \sa SDL_GetWindowMouseGrab()
  70. * \sa SDL_GetWindowPosition()
  71. * \sa SDL_GetWindowSize()
  72. * \sa SDL_GetWindowTitle()
  73. * \sa SDL_HideWindow()
  74. * \sa SDL_MaximizeWindow()
  75. * \sa SDL_MinimizeWindow()
  76. * \sa SDL_RaiseWindow()
  77. * \sa SDL_RestoreWindow()
  78. * \sa SDL_SetWindowData()
  79. * \sa SDL_SetWindowFullscreen()
  80. * \sa SDL_SetWindowGrab()
  81. * \sa SDL_SetWindowKeyboardGrab()
  82. * \sa SDL_SetWindowMouseGrab()
  83. * \sa SDL_SetWindowIcon()
  84. * \sa SDL_SetWindowPosition()
  85. * \sa SDL_SetWindowSize()
  86. * \sa SDL_SetWindowBordered()
  87. * \sa SDL_SetWindowResizable()
  88. * \sa SDL_SetWindowTitle()
  89. * \sa SDL_ShowWindow()
  90. */
  91. typedef struct SDL_Window SDL_Window;
  92. /**
  93. * \brief The flags on a window
  94. *
  95. * \sa SDL_GetWindowFlags()
  96. */
  97. typedef enum
  98. {
  99. SDL_WINDOW_FULLSCREEN_EXCLUSIVE = 0x00000001, /**< window is in fullscreen exclusive mode */
  100. SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
  101. /* 0x00000004 was SDL_WINDOW_SHOWN in SDL2, please reserve this bit for sdl2-compat. */
  102. SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
  103. SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
  104. SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
  105. SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */
  106. SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */
  107. SDL_WINDOW_MOUSE_GRABBED = 0x00000100, /**< window has grabbed mouse input */
  108. SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
  109. SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
  110. SDL_WINDOW_FULLSCREEN_DESKTOP = 0x00001000, /**< window is in fullscreen desktop mode */
  111. SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
  112. /* 0x00002000 was SDL_WINDOW_ALLOW_HIGHDPI in SDL2, please reserve this bit for sdl2-compat. */
  113. SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
  114. SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */
  115. SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */
  116. SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */
  117. SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */
  118. SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */
  119. SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000, /**< window has grabbed keyboard input */
  120. SDL_WINDOW_VULKAN = 0x10000000, /**< window usable for Vulkan surface */
  121. SDL_WINDOW_METAL = 0x20000000, /**< window usable for Metal view */
  122. } SDL_WindowFlags;
  123. #define SDL_WINDOW_FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_EXCLUSIVE | SDL_WINDOW_FULLSCREEN_DESKTOP)
  124. /**
  125. * \brief Used to indicate that you don't care what the window position is.
  126. */
  127. #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
  128. #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
  129. #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
  130. #define SDL_WINDOWPOS_ISUNDEFINED(X) \
  131. (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
  132. /**
  133. * \brief Used to indicate that the window position should be centered.
  134. */
  135. #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
  136. #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
  137. #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
  138. #define SDL_WINDOWPOS_ISCENTERED(X) \
  139. (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
  140. /**
  141. * \brief Display orientation
  142. */
  143. typedef enum
  144. {
  145. SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */
  146. SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */
  147. SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */
  148. SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */
  149. SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */
  150. } SDL_DisplayOrientation;
  151. /**
  152. * \brief Window flash operation
  153. */
  154. typedef enum
  155. {
  156. SDL_FLASH_CANCEL, /**< Cancel any window flash state */
  157. SDL_FLASH_BRIEFLY, /**< Flash the window briefly to get attention */
  158. SDL_FLASH_UNTIL_FOCUSED /**< Flash the window until it gets focus */
  159. } SDL_FlashOperation;
  160. /**
  161. * \brief An opaque handle to an OpenGL context.
  162. */
  163. typedef void *SDL_GLContext;
  164. /**
  165. * \brief Opaque EGL types.
  166. */
  167. typedef void *SDL_EGLDisplay;
  168. typedef void *SDL_EGLConfig;
  169. typedef void *SDL_EGLSurface;
  170. typedef intptr_t SDL_EGLAttrib;
  171. typedef int SDL_EGLint;
  172. /**
  173. * \brief EGL attribute initialization callback types.
  174. */
  175. typedef SDL_EGLAttrib *(SDLCALL *SDL_EGLAttribArrayCallback)(void);
  176. typedef SDL_EGLint *(SDLCALL *SDL_EGLIntArrayCallback)(void);
  177. /**
  178. * \brief OpenGL configuration attributes
  179. */
  180. typedef enum
  181. {
  182. SDL_GL_RED_SIZE,
  183. SDL_GL_GREEN_SIZE,
  184. SDL_GL_BLUE_SIZE,
  185. SDL_GL_ALPHA_SIZE,
  186. SDL_GL_BUFFER_SIZE,
  187. SDL_GL_DOUBLEBUFFER,
  188. SDL_GL_DEPTH_SIZE,
  189. SDL_GL_STENCIL_SIZE,
  190. SDL_GL_ACCUM_RED_SIZE,
  191. SDL_GL_ACCUM_GREEN_SIZE,
  192. SDL_GL_ACCUM_BLUE_SIZE,
  193. SDL_GL_ACCUM_ALPHA_SIZE,
  194. SDL_GL_STEREO,
  195. SDL_GL_MULTISAMPLEBUFFERS,
  196. SDL_GL_MULTISAMPLESAMPLES,
  197. SDL_GL_ACCELERATED_VISUAL,
  198. SDL_GL_RETAINED_BACKING,
  199. SDL_GL_CONTEXT_MAJOR_VERSION,
  200. SDL_GL_CONTEXT_MINOR_VERSION,
  201. SDL_GL_CONTEXT_FLAGS,
  202. SDL_GL_CONTEXT_PROFILE_MASK,
  203. SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
  204. SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
  205. SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
  206. SDL_GL_CONTEXT_RESET_NOTIFICATION,
  207. SDL_GL_CONTEXT_NO_ERROR,
  208. SDL_GL_FLOATBUFFERS,
  209. SDL_GL_EGL_PLATFORM
  210. } SDL_GLattr;
  211. typedef enum
  212. {
  213. SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
  214. SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
  215. SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
  216. } SDL_GLprofile;
  217. typedef enum
  218. {
  219. SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
  220. SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
  221. SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
  222. SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
  223. } SDL_GLcontextFlag;
  224. typedef enum
  225. {
  226. SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000,
  227. SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001
  228. } SDL_GLcontextReleaseFlag;
  229. typedef enum
  230. {
  231. SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000,
  232. SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001
  233. } SDL_GLContextResetNotification;
  234. /* Function prototypes */
  235. /**
  236. * Get the number of video drivers compiled into SDL.
  237. *
  238. * \returns a number >= 1 on success or a negative error code on failure; call
  239. * SDL_GetError() for more information.
  240. *
  241. * \since This function is available since SDL 3.0.0.
  242. *
  243. * \sa SDL_GetVideoDriver
  244. */
  245. extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
  246. /**
  247. * Get the name of a built in video driver.
  248. *
  249. * The video drivers are presented in the order in which they are normally
  250. * checked during initialization.
  251. *
  252. * \param index the index of a video driver
  253. * \returns the name of the video driver with the given **index**.
  254. *
  255. * \since This function is available since SDL 3.0.0.
  256. *
  257. * \sa SDL_GetNumVideoDrivers
  258. */
  259. extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
  260. /**
  261. * Get the name of the currently initialized video driver.
  262. *
  263. * \returns the name of the current video driver or NULL if no driver has been
  264. * initialized.
  265. *
  266. * \since This function is available since SDL 3.0.0.
  267. *
  268. * \sa SDL_GetNumVideoDrivers
  269. * \sa SDL_GetVideoDriver
  270. */
  271. extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
  272. /**
  273. * Get a list of currently connected displays.
  274. *
  275. * \param count a pointer filled in with the number of displays returned
  276. * \returns a 0 terminated array of display instance IDs which should be freed
  277. * with SDL_free(), or NULL on error; call SDL_GetError() for more
  278. * details.
  279. *
  280. * \since This function is available since SDL 3.0.0.
  281. */
  282. extern DECLSPEC SDL_DisplayID *SDLCALL SDL_GetDisplays(int *count);
  283. /**
  284. * Return the primary display.
  285. *
  286. * \returns the instance ID of the primary display on success or 0 on failure;
  287. * call SDL_GetError() for more information.
  288. *
  289. * \since This function is available since SDL 3.0.0.
  290. *
  291. * \sa SDL_GetDisplays
  292. */
  293. extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
  294. /**
  295. * Get the name of a display in UTF-8 encoding.
  296. *
  297. * \param displayID the instance ID of the display to query
  298. * \returns the name of a display or NULL on failure; call SDL_GetError() for
  299. * more information.
  300. *
  301. * \since This function is available since SDL 3.0.0.
  302. *
  303. * \sa SDL_GetDisplays
  304. */
  305. extern DECLSPEC const char *SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
  306. /**
  307. * Get the desktop area represented by a display, in screen coordinates.
  308. *
  309. * The primary display is always located at (0,0).
  310. *
  311. * \param displayID the instance ID of the display to query
  312. * \param rect the SDL_Rect structure filled in with the display bounds
  313. * \returns 0 on success or a negative error code on failure; call
  314. * SDL_GetError() for more information.
  315. *
  316. * \since This function is available since SDL 3.0.0.
  317. *
  318. * \sa SDL_GetDisplayUsableBounds
  319. * \sa SDL_GetDisplays
  320. */
  321. extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
  322. /**
  323. * Get the usable desktop area represented by a display, in screen
  324. * coordinates.
  325. *
  326. * This is the same area as SDL_GetDisplayBounds() reports, but with portions
  327. * reserved by the system removed. For example, on Apple's macOS, this
  328. * subtracts the area occupied by the menu bar and dock.
  329. *
  330. * Setting a window to be fullscreen generally bypasses these unusable areas,
  331. * so these are good guidelines for the maximum space available to a
  332. * non-fullscreen window.
  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_GetDisplayBounds
  342. * \sa SDL_GetDisplays
  343. */
  344. extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
  345. /**
  346. * Get the dots/pixels-per-inch for a display.
  347. *
  348. * Diagonal, horizontal and vertical DPI can all be optionally returned if the
  349. * appropriate parameter is non-NULL.
  350. *
  351. * **WARNING**: This reports the DPI that the hardware reports, and it is not
  352. * always reliable! It is almost always better to use SDL_GetWindowSize() to
  353. * find the window size, which might be in logical points instead of pixels,
  354. * and then SDL_GetWindowSizeInPixels() or SDL_GetRendererOutputSize(), and
  355. * compare the two values to get an actual scaling value between the two. We
  356. * will be rethinking how high-dpi details should be managed in SDL3 to make
  357. * things more consistent, reliable, and clear.
  358. *
  359. * \param displayID the instance ID of the display to query
  360. * \param ddpi a pointer filled in with the diagonal DPI of the display; may
  361. * be NULL
  362. * \param hdpi a pointer filled in with the horizontal DPI of the display; may
  363. * be NULL
  364. * \param vdpi a pointer filled in with the vertical DPI of the display; may
  365. * be NULL
  366. * \returns 0 on success or a negative error code on failure; call
  367. * SDL_GetError() for more information.
  368. *
  369. * \since This function is available since SDL 3.0.0.
  370. *
  371. * \sa SDL_GetDisplays
  372. */
  373. extern DECLSPEC int SDLCALL SDL_GetDisplayPhysicalDPI(SDL_DisplayID displayID, float *ddpi, float *hdpi, float *vdpi);
  374. /**
  375. * Get the orientation of a display.
  376. *
  377. * \param displayID the instance ID of the display to query
  378. * \returns The SDL_DisplayOrientation enum value of the display, or
  379. * `SDL_ORIENTATION_UNKNOWN` if it isn't available.
  380. *
  381. * \since This function is available since SDL 3.0.0.
  382. *
  383. * \sa SDL_GetDisplays
  384. */
  385. extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(SDL_DisplayID displayID);
  386. /**
  387. * Get the number of available display modes.
  388. *
  389. * \param displayID the instance ID of the display to query
  390. * \returns a number >= 1 on success or a negative error code on failure; call
  391. * SDL_GetError() for more information.
  392. *
  393. * \since This function is available since SDL 3.0.0.
  394. *
  395. * \sa SDL_GetDisplayMode
  396. * \sa SDL_GetDisplays
  397. */
  398. extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(SDL_DisplayID displayID);
  399. /**
  400. * Get information about a specific display mode.
  401. *
  402. * The display modes are sorted in this priority:
  403. *
  404. * - screen_w -> largest to smallest
  405. * - screen_h -> largest to smallest
  406. * - pixel_w -> largest to smallest
  407. * - pixel_h -> largest to smallest
  408. * - bits per pixel -> more colors to fewer colors
  409. * - packed pixel layout -> largest to smallest
  410. * - refresh rate -> highest to lowest
  411. *
  412. * \param displayID the instance ID of the display to query
  413. * \param modeIndex the index of the display mode to query
  414. * \param mode an SDL_DisplayMode structure filled in with the mode at
  415. * `modeIndex`
  416. * \returns 0 on success or a negative error code on failure; call
  417. * SDL_GetError() for more information.
  418. *
  419. * \since This function is available since SDL 3.0.0.
  420. *
  421. * \sa SDL_GetNumDisplayModes
  422. */
  423. extern DECLSPEC int SDLCALL SDL_GetDisplayMode(SDL_DisplayID displayID, int modeIndex, SDL_DisplayMode *mode);
  424. /**
  425. * Get information about the desktop's display mode.
  426. *
  427. * There's a difference between this function and SDL_GetCurrentDisplayMode()
  428. * when SDL runs fullscreen and has changed the resolution. In that case this
  429. * function will return the previous native display mode, and not the current
  430. * display mode.
  431. *
  432. * \param displayID the instance ID of the display to query
  433. * \param mode an SDL_DisplayMode structure filled in with the current display
  434. * mode
  435. * \returns 0 on success or a negative error code on failure; call
  436. * SDL_GetError() for more information.
  437. *
  438. * \since This function is available since SDL 3.0.0.
  439. *
  440. * \sa SDL_GetCurrentDisplayMode
  441. * \sa SDL_GetDisplayMode
  442. * \sa SDL_SetWindowDisplayMode
  443. */
  444. extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode);
  445. /**
  446. * Get information about the current display mode.
  447. *
  448. * There's a difference between this function and SDL_GetDesktopDisplayMode()
  449. * when SDL runs fullscreen and has changed the resolution. In that case this
  450. * function will return the current display mode, and not the previous native
  451. * display mode.
  452. *
  453. * \param displayID the instance ID of the display to query
  454. * \param mode an SDL_DisplayMode structure filled in with the current display
  455. * mode
  456. * \returns 0 on success or a negative error code on failure; call
  457. * SDL_GetError() for more information.
  458. *
  459. * \since This function is available since SDL 3.0.0.
  460. *
  461. * \sa SDL_GetDesktopDisplayMode
  462. * \sa SDL_GetDisplayMode
  463. * \sa SDL_GetDisplays
  464. * \sa SDL_SetWindowDisplayMode
  465. */
  466. extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode);
  467. /**
  468. * Get the closest match to the requested display mode.
  469. *
  470. * The available display modes are scanned and `closest` is filled in with the
  471. * closest mode matching the requested mode and returned. The mode format and
  472. * refresh rate default to the desktop mode if they are set to 0. The modes
  473. * are scanned with size being first priority, format being second priority,
  474. * and finally checking the refresh rate. If all the available modes are too
  475. * small, then NULL is returned.
  476. *
  477. * \param displayID the instance ID of the display to query
  478. * \param mode an SDL_DisplayMode structure containing the desired display
  479. * mode, should be zero initialized
  480. * \param closest an SDL_DisplayMode structure filled in with the closest
  481. * match of the available display modes
  482. * \returns the passed in value `closest` or NULL if no matching video mode
  483. * was available; call SDL_GetError() for more information.
  484. *
  485. * \since This function is available since SDL 3.0.0.
  486. *
  487. * \sa SDL_GetDisplayMode
  488. * \sa SDL_GetNumDisplayModes
  489. */
  490. extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(SDL_DisplayID displayID, const SDL_DisplayMode *mode, SDL_DisplayMode *closest);
  491. /**
  492. * Get the display containing a point
  493. *
  494. * \param point the point to query
  495. * \returns the instance ID of the display containing the point or 0 on
  496. * failure; call SDL_GetError() for more information.
  497. *
  498. * \since This function is available since SDL 3.0.0.
  499. *
  500. * \sa SDL_GetDisplayBounds
  501. * \sa SDL_GetDisplays
  502. */
  503. extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
  504. /**
  505. * Get the display primarily containing a rect
  506. *
  507. * \param rect the rect to query
  508. * \returns the instance ID of the display entirely containing the rect or
  509. * closest to the center of the rect on success or 0 on failure; call
  510. * SDL_GetError() for more information.
  511. *
  512. * \since This function is available since SDL 3.0.0.
  513. *
  514. * \sa SDL_GetDisplayBounds
  515. * \sa SDL_GetDisplays
  516. */
  517. extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
  518. /**
  519. * Get the display associated with a window.
  520. *
  521. * \param window the window to query
  522. * \returns the instance ID of the display containing the center of the window
  523. * on success or 0 on failure; call SDL_GetError() for more
  524. * information.
  525. *
  526. * \since This function is available since SDL 3.0.0.
  527. *
  528. * \sa SDL_GetDisplayBounds
  529. * \sa SDL_GetDisplays
  530. */
  531. extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
  532. /**
  533. * Set the display mode to use when a window is visible at fullscreen.
  534. *
  535. * This only affects the display mode used when the window is fullscreen. To
  536. * change the window size when the window is not fullscreen, use
  537. * SDL_SetWindowSize().
  538. *
  539. * \param window the window to affect
  540. * \param mode the SDL_DisplayMode structure representing the mode to use, or
  541. * NULL to use the window's dimensions and the desktop's format
  542. * and refresh rate
  543. * \returns 0 on success or a negative error code on failure; call
  544. * SDL_GetError() for more information.
  545. *
  546. * \since This function is available since SDL 3.0.0.
  547. *
  548. * \sa SDL_GetWindowDisplayMode
  549. * \sa SDL_SetWindowFullscreen
  550. */
  551. extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window *window, const SDL_DisplayMode *mode);
  552. /**
  553. * Query the display mode to use when a window is visible at fullscreen.
  554. *
  555. * \param window the window to query
  556. * \param mode an SDL_DisplayMode structure filled in with the fullscreen
  557. * display mode
  558. * \returns 0 on success or a negative error code on failure; call
  559. * SDL_GetError() for more information.
  560. *
  561. * \since This function is available since SDL 3.0.0.
  562. *
  563. * \sa SDL_SetWindowDisplayMode
  564. * \sa SDL_SetWindowFullscreen
  565. */
  566. extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode);
  567. /**
  568. * Get the raw ICC profile data for the screen the window is currently on.
  569. *
  570. * Data returned should be freed with SDL_free.
  571. *
  572. * \param window the window to query
  573. * \param size the size of the ICC profile
  574. * \returns the raw ICC profile data on success or NULL on failure; call
  575. * SDL_GetError() for more information.
  576. *
  577. * \since This function is available since SDL 3.0.0.
  578. */
  579. extern DECLSPEC void *SDLCALL SDL_GetWindowICCProfile(SDL_Window *window, size_t *size);
  580. /**
  581. * Get the pixel format associated with the window.
  582. *
  583. * \param window the window to query
  584. * \returns the pixel format of the window on success or
  585. * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more
  586. * information.
  587. *
  588. * \since This function is available since SDL 3.0.0.
  589. */
  590. extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
  591. /**
  592. * Create a window with the specified position, dimensions, and flags.
  593. *
  594. * `flags` may be any of the following OR'd together:
  595. *
  596. * - `SDL_WINDOW_FULLSCREEN_EXCLUSIVE`: fullscreen window, switching display
  597. * mode to the closest fullscreen resolution
  598. * - `SDL_WINDOW_FULLSCREEN_DESKTOP`: fullscreen window at desktop resolution
  599. * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context
  600. * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance
  601. * - `SDL_WINDOW_METAL`: window usable with a Metal instance
  602. * - `SDL_WINDOW_HIDDEN`: window is not visible
  603. * - `SDL_WINDOW_BORDERLESS`: no window decoration
  604. * - `SDL_WINDOW_RESIZABLE`: window can be resized
  605. * - `SDL_WINDOW_MINIMIZED`: window is minimized
  606. * - `SDL_WINDOW_MAXIMIZED`: window is maximized
  607. * - `SDL_WINDOW_MOUSE_GRABBED`: window has grabbed mouse focus
  608. *
  609. * The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set.
  610. *
  611. * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
  612. * property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
  613. *
  614. * The window size in pixels may differ from its size in screen coordinates if
  615. * the window is on a high density display (one with an OS scaling factor).
  616. * Use SDL_GetWindowSize() to query the client area's size in screen
  617. * coordinates, and SDL_GetWindowSizeInPixels() or SDL_GetRendererOutputSize()
  618. * to query the drawable size in pixels. Note that the drawable size can vary
  619. * after the window is created and should be queried again when the window is
  620. * resized or moved between displays.
  621. *
  622. * If the window is set fullscreen, the width and height parameters `w` and
  623. * `h` will not be used. However, invalid size parameters (e.g. too large) may
  624. * still fail. Window size is actually limited to 16384 x 16384 for all
  625. * platforms at window creation.
  626. *
  627. * If the window is created with any of the SDL_WINDOW_OPENGL or
  628. * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function
  629. * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the
  630. * corresponding UnloadLibrary function is called by SDL_DestroyWindow().
  631. *
  632. * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver,
  633. * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail.
  634. *
  635. * If SDL_WINDOW_METAL is specified on an OS that does not support Metal,
  636. * SDL_CreateWindow() will fail.
  637. *
  638. * On non-Apple devices, SDL requires you to either not link to the Vulkan
  639. * loader or link to a dynamic library version. This limitation may be removed
  640. * in a future version of SDL.
  641. *
  642. * \param title the title of the window, in UTF-8 encoding
  643. * \param x the x position of the window, `SDL_WINDOWPOS_CENTERED`, or
  644. * `SDL_WINDOWPOS_UNDEFINED`
  645. * \param y the y position of the window, `SDL_WINDOWPOS_CENTERED`, or
  646. * `SDL_WINDOWPOS_UNDEFINED`
  647. * \param w the width of the window, in screen coordinates
  648. * \param h the height of the window, in screen coordinates
  649. * \param flags 0, or one or more SDL_WindowFlags OR'd together
  650. * \returns the window that was created or NULL on failure; call
  651. * SDL_GetError() for more information.
  652. *
  653. * \since This function is available since SDL 3.0.0.
  654. *
  655. * \sa SDL_CreateWindowFrom
  656. * \sa SDL_DestroyWindow
  657. */
  658. extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags);
  659. /**
  660. * Create an SDL window from an existing native window.
  661. *
  662. * In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows)
  663. * the hint `SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT` needs to be configured
  664. * before using SDL_CreateWindowFrom().
  665. *
  666. * \param data a pointer to driver-dependent window creation data, typically
  667. * your native window cast to a void*
  668. * \returns the window that was created or NULL on failure; call
  669. * SDL_GetError() for more information.
  670. *
  671. * \since This function is available since SDL 3.0.0.
  672. *
  673. * \sa SDL_CreateWindow
  674. * \sa SDL_DestroyWindow
  675. */
  676. extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowFrom(const void *data);
  677. /**
  678. * Get the numeric ID of a window.
  679. *
  680. * The numeric ID is what SDL_WindowEvent references, and is necessary to map
  681. * these events to specific SDL_Window objects.
  682. *
  683. * \param window the window to query
  684. * \returns the ID of the window on success or 0 on failure; call
  685. * SDL_GetError() for more information.
  686. *
  687. * \since This function is available since SDL 3.0.0.
  688. *
  689. * \sa SDL_GetWindowFromID
  690. */
  691. extern DECLSPEC SDL_WindowID SDLCALL SDL_GetWindowID(SDL_Window *window);
  692. /**
  693. * Get a window from a stored ID.
  694. *
  695. * The numeric ID is what SDL_WindowEvent references, and is necessary to map
  696. * these events to specific SDL_Window objects.
  697. *
  698. * \param id the ID of the window
  699. * \returns the window associated with `id` or NULL if it doesn't exist; call
  700. * SDL_GetError() for more information.
  701. *
  702. * \since This function is available since SDL 3.0.0.
  703. *
  704. * \sa SDL_GetWindowID
  705. */
  706. extern DECLSPEC SDL_Window *SDLCALL SDL_GetWindowFromID(SDL_WindowID id);
  707. /**
  708. * Get the window flags.
  709. *
  710. * \param window the window to query
  711. * \returns a mask of the SDL_WindowFlags associated with `window`
  712. *
  713. * \since This function is available since SDL 3.0.0.
  714. *
  715. * \sa SDL_CreateWindow
  716. * \sa SDL_HideWindow
  717. * \sa SDL_MaximizeWindow
  718. * \sa SDL_MinimizeWindow
  719. * \sa SDL_SetWindowFullscreen
  720. * \sa SDL_SetWindowGrab
  721. * \sa SDL_ShowWindow
  722. */
  723. extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window *window);
  724. /**
  725. * Set the title of a window.
  726. *
  727. * This string is expected to be in UTF-8 encoding.
  728. *
  729. * \param window the window to change
  730. * \param title the desired window title in UTF-8 format
  731. *
  732. * \since This function is available since SDL 3.0.0.
  733. *
  734. * \sa SDL_GetWindowTitle
  735. */
  736. extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
  737. /**
  738. * Get the title of a window.
  739. *
  740. * \param window the window to query
  741. * \returns the title of the window in UTF-8 format or "" if there is no
  742. * title.
  743. *
  744. * \since This function is available since SDL 3.0.0.
  745. *
  746. * \sa SDL_SetWindowTitle
  747. */
  748. extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window *window);
  749. /**
  750. * Set the icon for a window.
  751. *
  752. * \param window the window to change
  753. * \param icon an SDL_Surface structure containing the icon for the window
  754. *
  755. * \since This function is available since SDL 3.0.0.
  756. */
  757. extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
  758. /**
  759. * Associate an arbitrary named pointer with a window.
  760. *
  761. * `name` is case-sensitive.
  762. *
  763. * \param window the window to associate with the pointer
  764. * \param name the name of the pointer
  765. * \param userdata the associated pointer
  766. * \returns the previous value associated with `name`.
  767. *
  768. * \since This function is available since SDL 3.0.0.
  769. *
  770. * \sa SDL_GetWindowData
  771. */
  772. extern DECLSPEC void *SDLCALL SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata);
  773. /**
  774. * Retrieve the data pointer associated with a window.
  775. *
  776. * \param window the window to query
  777. * \param name the name of the pointer
  778. * \returns the value associated with `name`.
  779. *
  780. * \since This function is available since SDL 3.0.0.
  781. *
  782. * \sa SDL_SetWindowData
  783. */
  784. extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *name);
  785. /**
  786. * Set the position of a window, in screen coordinates.
  787. *
  788. * \param window the window to reposition
  789. * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
  790. * `SDL_WINDOWPOS_UNDEFINED`
  791. * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
  792. * `SDL_WINDOWPOS_UNDEFINED`
  793. *
  794. * \since This function is available since SDL 3.0.0.
  795. *
  796. * \sa SDL_GetWindowPosition
  797. */
  798. extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
  799. /**
  800. * Get the position of a window, in screen coordinates.
  801. *
  802. * If you do not need the value for one of the positions a NULL may be passed
  803. * in the `x` or `y` parameter.
  804. *
  805. * \param window the window to query
  806. * \param x a pointer filled in with the x position of the window, may be NULL
  807. * \param y a pointer filled in with the y position of the window, may be NULL
  808. *
  809. * \since This function is available since SDL 3.0.0.
  810. *
  811. * \sa SDL_SetWindowPosition
  812. */
  813. extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
  814. /**
  815. * Set the size of a window's client area, in screen coordinates.
  816. *
  817. * The window size in screen coordinates may differ from the size in pixels if
  818. * the window is on a high density display (one with an OS scaling factor).
  819. *
  820. * Fullscreen windows automatically match the size of the display mode, and
  821. * you should use SDL_SetWindowDisplayMode() to change their size.
  822. *
  823. * \param window the window to change
  824. * \param w the width of the window, must be > 0
  825. * \param h the height of the window, must be > 0
  826. *
  827. * \since This function is available since SDL 3.0.0.
  828. *
  829. * \sa SDL_GetWindowSize
  830. * \sa SDL_SetWindowDisplayMode
  831. */
  832. extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
  833. /**
  834. * Get the size of a window's client area, in screen coordinates.
  835. *
  836. * NULL can safely be passed as the `w` or `h` parameter if the width or
  837. * height value is not desired.
  838. *
  839. * The window size in screen coordinates may differ from the size in pixels if
  840. * the window is on a high density display (one with an OS scaling factor).
  841. * Use SDL_GetWindowSizeInPixels() or SDL_GetRendererOutputSize() to get the
  842. * real client area size in pixels.
  843. *
  844. * \param window the window to query the width and height from
  845. * \param w a pointer filled in with the width of the window, may be NULL
  846. * \param h a pointer filled in with the height of the window, may be NULL
  847. *
  848. * \since This function is available since SDL 3.0.0.
  849. *
  850. * \sa SDL_GetWindowSizeInPixels
  851. * \sa SDL_GetRendererOutputSize
  852. * \sa SDL_SetWindowSize
  853. */
  854. extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
  855. /**
  856. * Get the size of a window's borders (decorations) around the client area, in
  857. * screen coordinates.
  858. *
  859. * Note: If this function fails (returns -1), the size values will be
  860. * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the
  861. * window in question was borderless.
  862. *
  863. * Note: This function may fail on systems where the window has not yet been
  864. * decorated by the display server (for example, immediately after calling
  865. * SDL_CreateWindow). It is recommended that you wait at least until the
  866. * window has been presented and composited, so that the window system has a
  867. * chance to decorate the window and provide the border dimensions to SDL.
  868. *
  869. * This function also returns -1 if getting the information is not supported.
  870. *
  871. * \param window the window to query the size values of the border
  872. * (decorations) from
  873. * \param top pointer to variable for storing the size of the top border; NULL
  874. * is permitted
  875. * \param left pointer to variable for storing the size of the left border;
  876. * NULL is permitted
  877. * \param bottom pointer to variable for storing the size of the bottom
  878. * border; NULL is permitted
  879. * \param right pointer to variable for storing the size of the right border;
  880. * NULL is permitted
  881. * \returns 0 on success or a negative error code on failure; call
  882. * SDL_GetError() for more information.
  883. *
  884. * \since This function is available since SDL 3.0.0.
  885. *
  886. * \sa SDL_GetWindowSize
  887. */
  888. extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
  889. /**
  890. * Get the size of a window's client area, in pixels.
  891. *
  892. * The window size in pixels may differ from the size in screen coordinates if
  893. * the window is on a high density display (one with an OS scaling factor).
  894. *
  895. * \param window the window from which the drawable size should be queried
  896. * \param w a pointer to variable for storing the width in pixels, may be NULL
  897. * \param h a pointer to variable for storing the height in pixels, may be
  898. * NULL
  899. *
  900. * \since This function is available since SDL 3.0.0.
  901. *
  902. * \sa SDL_CreateWindow
  903. * \sa SDL_GetWindowSize
  904. */
  905. extern DECLSPEC void SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
  906. /**
  907. * Set the minimum size of a window's client area, in screen coordinates.
  908. *
  909. * \param window the window to change
  910. * \param min_w the minimum width of the window
  911. * \param min_h the minimum height of the window
  912. *
  913. * \since This function is available since SDL 3.0.0.
  914. *
  915. * \sa SDL_GetWindowMinimumSize
  916. * \sa SDL_SetWindowMaximumSize
  917. */
  918. extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
  919. /**
  920. * Get the minimum size of a window's client area, in screen coordinates.
  921. *
  922. * \param window the window to query
  923. * \param w a pointer filled in with the minimum width of the window, may be
  924. * NULL
  925. * \param h a pointer filled in with the minimum height of the window, may be
  926. * NULL
  927. *
  928. * \since This function is available since SDL 3.0.0.
  929. *
  930. * \sa SDL_GetWindowMaximumSize
  931. * \sa SDL_SetWindowMinimumSize
  932. */
  933. extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
  934. /**
  935. * Set the maximum size of a window's client area, in screen coordinates.
  936. *
  937. * \param window the window to change
  938. * \param max_w the maximum width of the window
  939. * \param max_h the maximum height of the window
  940. *
  941. * \since This function is available since SDL 3.0.0.
  942. *
  943. * \sa SDL_GetWindowMaximumSize
  944. * \sa SDL_SetWindowMinimumSize
  945. */
  946. extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
  947. /**
  948. * Get the maximum size of a window's client area, in screen coordinates.
  949. *
  950. * \param window the window to query
  951. * \param w a pointer filled in with the maximum width of the window, may be
  952. * NULL
  953. * \param h a pointer filled in with the maximum height of the window, may be
  954. * NULL
  955. *
  956. * \since This function is available since SDL 3.0.0.
  957. *
  958. * \sa SDL_GetWindowMinimumSize
  959. * \sa SDL_SetWindowMaximumSize
  960. */
  961. extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
  962. /**
  963. * Set the border state of a window.
  964. *
  965. * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add
  966. * or remove the border from the actual window. This is a no-op if the
  967. * window's border already matches the requested state.
  968. *
  969. * You can't change the border state of a fullscreen window.
  970. *
  971. * \param window the window of which to change the border state
  972. * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border
  973. *
  974. * \since This function is available since SDL 3.0.0.
  975. *
  976. * \sa SDL_GetWindowFlags
  977. */
  978. extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
  979. /**
  980. * Set the user-resizable state of a window.
  981. *
  982. * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and
  983. * allow/disallow user resizing of the window. This is a no-op if the window's
  984. * resizable state already matches the requested state.
  985. *
  986. * You can't change the resizable state of a fullscreen window.
  987. *
  988. * \param window the window of which to change the resizable state
  989. * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow
  990. *
  991. * \since This function is available since SDL 3.0.0.
  992. *
  993. * \sa SDL_GetWindowFlags
  994. */
  995. extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
  996. /**
  997. * Set the window to always be above the others.
  998. *
  999. * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` flag. This
  1000. * will bring the window to the front and keep the window above the rest.
  1001. *
  1002. * \param window The window of which to change the always on top state
  1003. * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to
  1004. * disable
  1005. *
  1006. * \since This function is available since SDL 3.0.0.
  1007. *
  1008. * \sa SDL_GetWindowFlags
  1009. */
  1010. extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
  1011. /**
  1012. * Show a window.
  1013. *
  1014. * \param window the window to show
  1015. *
  1016. * \since This function is available since SDL 3.0.0.
  1017. *
  1018. * \sa SDL_HideWindow
  1019. * \sa SDL_RaiseWindow
  1020. */
  1021. extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window *window);
  1022. /**
  1023. * Hide a window.
  1024. *
  1025. * \param window the window to hide
  1026. *
  1027. * \since This function is available since SDL 3.0.0.
  1028. *
  1029. * \sa SDL_ShowWindow
  1030. */
  1031. extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window *window);
  1032. /**
  1033. * Raise a window above other windows and set the input focus.
  1034. *
  1035. * \param window the window to raise
  1036. *
  1037. * \since This function is available since SDL 3.0.0.
  1038. */
  1039. extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window *window);
  1040. /**
  1041. * Make a window as large as possible.
  1042. *
  1043. * \param window the window to maximize
  1044. *
  1045. * \since This function is available since SDL 3.0.0.
  1046. *
  1047. * \sa SDL_MinimizeWindow
  1048. * \sa SDL_RestoreWindow
  1049. */
  1050. extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window *window);
  1051. /**
  1052. * Minimize a window to an iconic representation.
  1053. *
  1054. * \param window the window to minimize
  1055. *
  1056. * \since This function is available since SDL 3.0.0.
  1057. *
  1058. * \sa SDL_MaximizeWindow
  1059. * \sa SDL_RestoreWindow
  1060. */
  1061. extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window *window);
  1062. /**
  1063. * Restore the size and position of a minimized or maximized window.
  1064. *
  1065. * \param window the window to restore
  1066. *
  1067. * \since This function is available since SDL 3.0.0.
  1068. *
  1069. * \sa SDL_MaximizeWindow
  1070. * \sa SDL_MinimizeWindow
  1071. */
  1072. extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window *window);
  1073. /**
  1074. * Set a window's fullscreen state.
  1075. *
  1076. * `flags` may be `SDL_WINDOW_FULLSCREEN_EXCLUSIVE`, for "real" fullscreen
  1077. * with a videomode change; `SDL_WINDOW_FULLSCREEN_DESKTOP` for "fake"
  1078. * fullscreen that takes the size of the desktop; and 0 for windowed mode.
  1079. *
  1080. * \param window the window to change
  1081. * \param flags `SDL_WINDOW_FULLSCREEN_EXCLUSIVE`,
  1082. * `SDL_WINDOW_FULLSCREEN_DESKTOP` or 0
  1083. * \returns 0 on success or a negative error code on failure; call
  1084. * SDL_GetError() for more information.
  1085. *
  1086. * \since This function is available since SDL 3.0.0.
  1087. *
  1088. * \sa SDL_GetWindowDisplayMode
  1089. * \sa SDL_SetWindowDisplayMode
  1090. */
  1091. extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags);
  1092. /**
  1093. * Get the SDL surface associated with the window.
  1094. *
  1095. * A new surface will be created with the optimal format for the window, if
  1096. * necessary. This surface will be freed when the window is destroyed. Do not
  1097. * free this surface.
  1098. *
  1099. * This surface will be invalidated if the window is resized. After resizing a
  1100. * window this function must be called again to return a valid surface.
  1101. *
  1102. * You may not combine this with 3D or the rendering API on this window.
  1103. *
  1104. * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`.
  1105. *
  1106. * \param window the window to query
  1107. * \returns the surface associated with the window, or NULL on failure; call
  1108. * SDL_GetError() for more information.
  1109. *
  1110. * \since This function is available since SDL 3.0.0.
  1111. *
  1112. * \sa SDL_UpdateWindowSurface
  1113. * \sa SDL_UpdateWindowSurfaceRects
  1114. */
  1115. extern DECLSPEC SDL_Surface *SDLCALL SDL_GetWindowSurface(SDL_Window *window);
  1116. /**
  1117. * Copy the window surface to the screen.
  1118. *
  1119. * This is the function you use to reflect any changes to the surface on the
  1120. * screen.
  1121. *
  1122. * This function is equivalent to the SDL 1.2 API SDL_Flip().
  1123. *
  1124. * \param window the window to update
  1125. * \returns 0 on success or a negative error code on failure; call
  1126. * SDL_GetError() for more information.
  1127. *
  1128. * \since This function is available since SDL 3.0.0.
  1129. *
  1130. * \sa SDL_GetWindowSurface
  1131. * \sa SDL_UpdateWindowSurfaceRects
  1132. */
  1133. extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window *window);
  1134. /**
  1135. * Copy areas of the window surface to the screen.
  1136. *
  1137. * This is the function you use to reflect changes to portions of the surface
  1138. * on the screen.
  1139. *
  1140. * This function is equivalent to the SDL 1.2 API SDL_UpdateRects().
  1141. *
  1142. * \param window the window to update
  1143. * \param rects an array of SDL_Rect structures representing areas of the
  1144. * surface to copy, in pixels
  1145. * \param numrects the number of rectangles
  1146. * \returns 0 on success or a negative error code on failure; call
  1147. * SDL_GetError() for more information.
  1148. *
  1149. * \since This function is available since SDL 3.0.0.
  1150. *
  1151. * \sa SDL_GetWindowSurface
  1152. * \sa SDL_UpdateWindowSurface
  1153. */
  1154. extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
  1155. /**
  1156. * Set a window's input grab mode.
  1157. *
  1158. * When input is grabbed, the mouse is confined to the window. This function
  1159. * will also grab the keyboard if `SDL_HINT_GRAB_KEYBOARD` is set. To grab the
  1160. * keyboard without also grabbing the mouse, use SDL_SetWindowKeyboardGrab().
  1161. *
  1162. * If the caller enables a grab while another window is currently grabbed, the
  1163. * other window loses its grab in favor of the caller's window.
  1164. *
  1165. * \param window the window for which the input grab mode should be set
  1166. * \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input
  1167. *
  1168. * \since This function is available since SDL 3.0.0.
  1169. *
  1170. * \sa SDL_GetGrabbedWindow
  1171. * \sa SDL_GetWindowGrab
  1172. */
  1173. extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
  1174. /**
  1175. * Set a window's keyboard grab mode.
  1176. *
  1177. * Keyboard grab enables capture of system keyboard shortcuts like Alt+Tab or
  1178. * the Meta/Super key. Note that not all system keyboard shortcuts can be
  1179. * captured by applications (one example is Ctrl+Alt+Del on Windows).
  1180. *
  1181. * This is primarily intended for specialized applications such as VNC clients
  1182. * or VM frontends. Normal games should not use keyboard grab.
  1183. *
  1184. * When keyboard grab is enabled, SDL will continue to handle Alt+Tab when the
  1185. * window is full-screen to ensure the user is not trapped in your
  1186. * application. If you have a custom keyboard shortcut to exit fullscreen
  1187. * mode, you may suppress this behavior with
  1188. * `SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED`.
  1189. *
  1190. * If the caller enables a grab while another window is currently grabbed, the
  1191. * other window loses its grab in favor of the caller's window.
  1192. *
  1193. * \param window The window for which the keyboard grab mode should be set.
  1194. * \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release.
  1195. *
  1196. * \since This function is available since SDL 3.0.0.
  1197. *
  1198. * \sa SDL_GetWindowKeyboardGrab
  1199. * \sa SDL_SetWindowMouseGrab
  1200. * \sa SDL_SetWindowGrab
  1201. */
  1202. extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
  1203. /**
  1204. * Set a window's mouse grab mode.
  1205. *
  1206. * Mouse grab confines the mouse cursor to the window.
  1207. *
  1208. * \param window The window for which the mouse grab mode should be set.
  1209. * \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release.
  1210. *
  1211. * \since This function is available since SDL 3.0.0.
  1212. *
  1213. * \sa SDL_GetWindowMouseGrab
  1214. * \sa SDL_SetWindowKeyboardGrab
  1215. * \sa SDL_SetWindowGrab
  1216. */
  1217. extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
  1218. /**
  1219. * Get a window's input grab mode.
  1220. *
  1221. * \param window the window to query
  1222. * \returns SDL_TRUE if input is grabbed, SDL_FALSE otherwise.
  1223. *
  1224. * \since This function is available since SDL 3.0.0.
  1225. *
  1226. * \sa SDL_SetWindowGrab
  1227. */
  1228. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window *window);
  1229. /**
  1230. * Get a window's keyboard grab mode.
  1231. *
  1232. * \param window the window to query
  1233. * \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise.
  1234. *
  1235. * \since This function is available since SDL 3.0.0.
  1236. *
  1237. * \sa SDL_SetWindowKeyboardGrab
  1238. * \sa SDL_GetWindowGrab
  1239. */
  1240. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window *window);
  1241. /**
  1242. * Get a window's mouse grab mode.
  1243. *
  1244. * \param window the window to query
  1245. * \returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise.
  1246. *
  1247. * \since This function is available since SDL 3.0.0.
  1248. *
  1249. * \sa SDL_SetWindowKeyboardGrab
  1250. * \sa SDL_GetWindowGrab
  1251. */
  1252. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window *window);
  1253. /**
  1254. * Get the window that currently has an input grab enabled.
  1255. *
  1256. * \returns the window if input is grabbed or NULL otherwise.
  1257. *
  1258. * \since This function is available since SDL 3.0.0.
  1259. *
  1260. * \sa SDL_GetWindowGrab
  1261. * \sa SDL_SetWindowGrab
  1262. */
  1263. extern DECLSPEC SDL_Window *SDLCALL SDL_GetGrabbedWindow(void);
  1264. /**
  1265. * Confines the cursor to the specified area of a window.
  1266. *
  1267. * Note that this does NOT grab the cursor, it only defines the area a cursor
  1268. * is restricted to when the window has mouse focus.
  1269. *
  1270. * \param window The window that will be associated with the barrier.
  1271. * \param rect A rectangle area in window-relative coordinates. If NULL the
  1272. * barrier for the specified window will be destroyed.
  1273. * \returns 0 on success or a negative error code on failure; call
  1274. * SDL_GetError() for more information.
  1275. *
  1276. * \since This function is available since SDL 3.0.0.
  1277. *
  1278. * \sa SDL_GetWindowMouseRect
  1279. * \sa SDL_SetWindowMouseGrab
  1280. */
  1281. extern DECLSPEC int SDLCALL SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect);
  1282. /**
  1283. * Get the mouse confinement rectangle of a window.
  1284. *
  1285. * \param window The window to query
  1286. * \returns A pointer to the mouse confinement rectangle of a window, or NULL
  1287. * if there isn't one.
  1288. *
  1289. * \since This function is available since SDL 3.0.0.
  1290. *
  1291. * \sa SDL_SetWindowMouseRect
  1292. */
  1293. extern DECLSPEC const SDL_Rect *SDLCALL SDL_GetWindowMouseRect(SDL_Window *window);
  1294. /**
  1295. * Set the opacity for a window.
  1296. *
  1297. * The parameter `opacity` will be clamped internally between 0.0f
  1298. * (transparent) and 1.0f (opaque).
  1299. *
  1300. * This function also returns -1 if setting the opacity isn't supported.
  1301. *
  1302. * \param window the window which will be made transparent or opaque
  1303. * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque)
  1304. * \returns 0 on success or a negative error code on failure; call
  1305. * SDL_GetError() for more information.
  1306. *
  1307. * \since This function is available since SDL 3.0.0.
  1308. *
  1309. * \sa SDL_GetWindowOpacity
  1310. */
  1311. extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window *window, float opacity);
  1312. /**
  1313. * Get the opacity of a window.
  1314. *
  1315. * If transparency isn't supported on this platform, opacity will be reported
  1316. * as 1.0f without error.
  1317. *
  1318. * The parameter `opacity` is ignored if it is NULL.
  1319. *
  1320. * This function also returns -1 if an invalid window was provided.
  1321. *
  1322. * \param window the window to get the current opacity value from
  1323. * \param out_opacity the float filled in (0.0f - transparent, 1.0f - opaque)
  1324. * \returns 0 on success or a negative error code on failure; call
  1325. * SDL_GetError() for more information.
  1326. *
  1327. * \since This function is available since SDL 3.0.0.
  1328. *
  1329. * \sa SDL_SetWindowOpacity
  1330. */
  1331. extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity);
  1332. /**
  1333. * Set the window as a modal for another window.
  1334. *
  1335. * \param modal_window the window that should be set modal
  1336. * \param parent_window the parent window for the modal window
  1337. * \returns 0 on success or a negative error code on failure; call
  1338. * SDL_GetError() for more information.
  1339. *
  1340. * \since This function is available since SDL 3.0.0.
  1341. */
  1342. extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window);
  1343. /**
  1344. * Explicitly set input focus to the window.
  1345. *
  1346. * You almost certainly want SDL_RaiseWindow() instead of this function. Use
  1347. * this with caution, as you might give focus to a window that is completely
  1348. * obscured by other windows.
  1349. *
  1350. * \param window the window that should get the input focus
  1351. * \returns 0 on success or a negative error code on failure; call
  1352. * SDL_GetError() for more information.
  1353. *
  1354. * \since This function is available since SDL 3.0.0.
  1355. *
  1356. * \sa SDL_RaiseWindow
  1357. */
  1358. extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window *window);
  1359. /**
  1360. * Possible return values from the SDL_HitTest callback.
  1361. *
  1362. * \sa SDL_HitTest
  1363. */
  1364. typedef enum
  1365. {
  1366. SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */
  1367. SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */
  1368. SDL_HITTEST_RESIZE_TOPLEFT,
  1369. SDL_HITTEST_RESIZE_TOP,
  1370. SDL_HITTEST_RESIZE_TOPRIGHT,
  1371. SDL_HITTEST_RESIZE_RIGHT,
  1372. SDL_HITTEST_RESIZE_BOTTOMRIGHT,
  1373. SDL_HITTEST_RESIZE_BOTTOM,
  1374. SDL_HITTEST_RESIZE_BOTTOMLEFT,
  1375. SDL_HITTEST_RESIZE_LEFT
  1376. } SDL_HitTestResult;
  1377. /**
  1378. * Callback used for hit-testing.
  1379. *
  1380. * \param win the SDL_Window where hit-testing was set on
  1381. * \param area an SDL_Point which should be hit-tested
  1382. * \param data what was passed as `callback_data` to SDL_SetWindowHitTest()
  1383. * \return an SDL_HitTestResult value.
  1384. *
  1385. * \sa SDL_SetWindowHitTest
  1386. */
  1387. typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win,
  1388. const SDL_Point *area,
  1389. void *data);
  1390. /**
  1391. * Provide a callback that decides if a window region has special properties.
  1392. *
  1393. * Normally windows are dragged and resized by decorations provided by the
  1394. * system window manager (a title bar, borders, etc), but for some apps, it
  1395. * makes sense to drag them from somewhere else inside the window itself; for
  1396. * example, one might have a borderless window that wants to be draggable from
  1397. * any part, or simulate its own title bar, etc.
  1398. *
  1399. * This function lets the app provide a callback that designates pieces of a
  1400. * given window as special. This callback is run during event processing if we
  1401. * need to tell the OS to treat a region of the window specially; the use of
  1402. * this callback is known as "hit testing."
  1403. *
  1404. * Mouse input may not be delivered to your application if it is within a
  1405. * special area; the OS will often apply that input to moving the window or
  1406. * resizing the window and not deliver it to the application.
  1407. *
  1408. * Specifying NULL for a callback disables hit-testing. Hit-testing is
  1409. * disabled by default.
  1410. *
  1411. * Platforms that don't support this functionality will return -1
  1412. * unconditionally, even if you're attempting to disable hit-testing.
  1413. *
  1414. * Your callback may fire at any time, and its firing does not indicate any
  1415. * specific behavior (for example, on Windows, this certainly might fire when
  1416. * the OS is deciding whether to drag your window, but it fires for lots of
  1417. * other reasons, too, some unrelated to anything you probably care about _and
  1418. * when the mouse isn't actually at the location it is testing_). Since this
  1419. * can fire at any time, you should try to keep your callback efficient,
  1420. * devoid of allocations, etc.
  1421. *
  1422. * \param window the window to set hit-testing on
  1423. * \param callback the function to call when doing a hit-test
  1424. * \param callback_data an app-defined void pointer passed to **callback**
  1425. * \returns 0 on success or -1 on error (including unsupported); call
  1426. * SDL_GetError() for more information.
  1427. *
  1428. * \since This function is available since SDL 3.0.0.
  1429. */
  1430. extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
  1431. /**
  1432. * Request a window to demand attention from the user.
  1433. *
  1434. * \param window the window to be flashed
  1435. * \param operation the flash operation
  1436. * \returns 0 on success or a negative error code on failure; call
  1437. * SDL_GetError() for more information.
  1438. *
  1439. * \since This function is available since SDL 3.0.0.
  1440. */
  1441. extern DECLSPEC int SDLCALL SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation);
  1442. /**
  1443. * Destroy a window.
  1444. *
  1445. * If `window` is NULL, this function will return immediately after setting
  1446. * the SDL error message to "Invalid window". See SDL_GetError().
  1447. *
  1448. * \param window the window to destroy
  1449. *
  1450. * \since This function is available since SDL 3.0.0.
  1451. *
  1452. * \sa SDL_CreateWindow
  1453. * \sa SDL_CreateWindowFrom
  1454. */
  1455. extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window *window);
  1456. /**
  1457. * Check whether the screensaver is currently enabled.
  1458. *
  1459. * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2
  1460. * the screensaver was enabled by default.
  1461. *
  1462. * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`.
  1463. *
  1464. * \returns SDL_TRUE if the screensaver is enabled, SDL_FALSE if it is
  1465. * disabled.
  1466. *
  1467. * \since This function is available since SDL 3.0.0.
  1468. *
  1469. * \sa SDL_DisableScreenSaver
  1470. * \sa SDL_EnableScreenSaver
  1471. */
  1472. extern DECLSPEC SDL_bool SDLCALL SDL_ScreenSaverEnabled(void);
  1473. /**
  1474. * Allow the screen to be blanked by a screen saver.
  1475. *
  1476. * \since This function is available since SDL 3.0.0.
  1477. *
  1478. * \sa SDL_DisableScreenSaver
  1479. * \sa SDL_ScreenSaverEnabled
  1480. */
  1481. extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void);
  1482. /**
  1483. * Prevent the screen from being blanked by a screen saver.
  1484. *
  1485. * If you disable the screensaver, it is automatically re-enabled when SDL
  1486. * quits.
  1487. *
  1488. * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2
  1489. * the screensaver was enabled by default.
  1490. *
  1491. * \since This function is available since SDL 3.0.0.
  1492. *
  1493. * \sa SDL_EnableScreenSaver
  1494. * \sa SDL_ScreenSaverEnabled
  1495. */
  1496. extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void);
  1497. /**
  1498. * \name OpenGL support functions
  1499. */
  1500. /* @{ */
  1501. /**
  1502. * Dynamically load an OpenGL library.
  1503. *
  1504. * This should be done after initializing the video driver, but before
  1505. * creating any OpenGL windows. If no OpenGL library is loaded, the default
  1506. * library will be loaded upon creation of the first OpenGL window.
  1507. *
  1508. * If you do this, you need to retrieve all of the GL functions used in your
  1509. * program from the dynamic library using SDL_GL_GetProcAddress().
  1510. *
  1511. * \param path the platform dependent OpenGL library name, or NULL to open the
  1512. * default OpenGL library
  1513. * \returns 0 on success or a negative error code on failure; call
  1514. * SDL_GetError() for more information.
  1515. *
  1516. * \since This function is available since SDL 3.0.0.
  1517. *
  1518. * \sa SDL_GL_GetProcAddress
  1519. * \sa SDL_GL_UnloadLibrary
  1520. */
  1521. extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
  1522. /**
  1523. * Get an OpenGL function by name.
  1524. *
  1525. * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all
  1526. * GL functions must be retrieved this way. Usually this is used to retrieve
  1527. * function pointers to OpenGL extensions.
  1528. *
  1529. * There are some quirks to looking up OpenGL functions that require some
  1530. * extra care from the application. If you code carefully, you can handle
  1531. * these quirks without any platform-specific code, though:
  1532. *
  1533. * - On Windows, function pointers are specific to the current GL context;
  1534. * this means you need to have created a GL context and made it current
  1535. * before calling SDL_GL_GetProcAddress(). If you recreate your context or
  1536. * create a second context, you should assume that any existing function
  1537. * pointers aren't valid to use with it. This is (currently) a
  1538. * Windows-specific limitation, and in practice lots of drivers don't suffer
  1539. * this limitation, but it is still the way the wgl API is documented to
  1540. * work and you should expect crashes if you don't respect it. Store a copy
  1541. * of the function pointers that comes and goes with context lifespan.
  1542. * - On X11, function pointers returned by this function are valid for any
  1543. * context, and can even be looked up before a context is created at all.
  1544. * This means that, for at least some common OpenGL implementations, if you
  1545. * look up a function that doesn't exist, you'll get a non-NULL result that
  1546. * is _NOT_ safe to call. You must always make sure the function is actually
  1547. * available for a given GL context before calling it, by checking for the
  1548. * existence of the appropriate extension with SDL_GL_ExtensionSupported(),
  1549. * or verifying that the version of OpenGL you're using offers the function
  1550. * as core functionality.
  1551. * - Some OpenGL drivers, on all platforms, *will* return NULL if a function
  1552. * isn't supported, but you can't count on this behavior. Check for
  1553. * extensions you use, and if you get a NULL anyway, act as if that
  1554. * extension wasn't available. This is probably a bug in the driver, but you
  1555. * can code defensively for this scenario anyhow.
  1556. * - Just because you're on Linux/Unix, don't assume you'll be using X11.
  1557. * Next-gen display servers are waiting to replace it, and may or may not
  1558. * make the same promises about function pointers.
  1559. * - OpenGL function pointers must be declared `APIENTRY` as in the example
  1560. * code. This will ensure the proper calling convention is followed on
  1561. * platforms where this matters (Win32) thereby avoiding stack corruption.
  1562. *
  1563. * \param proc the name of an OpenGL function
  1564. * \returns a pointer to the named OpenGL function. The returned pointer
  1565. * should be cast to the appropriate function signature.
  1566. *
  1567. * \since This function is available since SDL 3.0.0.
  1568. *
  1569. * \sa SDL_GL_ExtensionSupported
  1570. * \sa SDL_GL_LoadLibrary
  1571. * \sa SDL_GL_UnloadLibrary
  1572. */
  1573. extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_GL_GetProcAddress(const char *proc);
  1574. /**
  1575. * Get an EGL library function by name.
  1576. *
  1577. * If an EGL library is loaded, this function allows applications to get entry
  1578. * points for EGL functions. This is useful to provide to an EGL API and
  1579. * extension loader.
  1580. *
  1581. * \param proc the name of an EGL function
  1582. * \returns a pointer to the named EGL function. The returned pointer should
  1583. * be cast to the appropriate function signature.
  1584. *
  1585. * \since This function is available since SDL 3.0.0.
  1586. *
  1587. * \sa SDL_GL_GetCurrentEGLDisplay
  1588. */
  1589. extern DECLSPEC SDL_FunctionPointer SDLCALL SDL_EGL_GetProcAddress(const char *proc);
  1590. /**
  1591. * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
  1592. *
  1593. * \since This function is available since SDL 3.0.0.
  1594. *
  1595. * \sa SDL_GL_LoadLibrary
  1596. */
  1597. extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
  1598. /**
  1599. * Check if an OpenGL extension is supported for the current context.
  1600. *
  1601. * This function operates on the current GL context; you must have created a
  1602. * context and it must be current before calling this function. Do not assume
  1603. * that all contexts you create will have the same set of extensions
  1604. * available, or that recreating an existing context will offer the same
  1605. * extensions again.
  1606. *
  1607. * While it's probably not a massive overhead, this function is not an O(1)
  1608. * operation. Check the extensions you care about after creating the GL
  1609. * context and save that information somewhere instead of calling the function
  1610. * every time you need to know.
  1611. *
  1612. * \param extension the name of the extension to check
  1613. * \returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise.
  1614. *
  1615. * \since This function is available since SDL 3.0.0.
  1616. */
  1617. extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension);
  1618. /**
  1619. * Reset all previously set OpenGL context attributes to their default values.
  1620. *
  1621. * \since This function is available since SDL 3.0.0.
  1622. *
  1623. * \sa SDL_GL_GetAttribute
  1624. * \sa SDL_GL_SetAttribute
  1625. */
  1626. extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
  1627. /**
  1628. * Set an OpenGL window attribute before window creation.
  1629. *
  1630. * This function sets the OpenGL attribute `attr` to `value`. The requested
  1631. * attributes should be set before creating an OpenGL window. You should use
  1632. * SDL_GL_GetAttribute() to check the values after creating the OpenGL
  1633. * context, since the values obtained can differ from the requested ones.
  1634. *
  1635. * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to set
  1636. * \param value the desired value for the attribute
  1637. * \returns 0 on success or a negative error code on failure; call
  1638. * SDL_GetError() for more information.
  1639. *
  1640. * \since This function is available since SDL 3.0.0.
  1641. *
  1642. * \sa SDL_GL_GetAttribute
  1643. * \sa SDL_GL_ResetAttributes
  1644. */
  1645. extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
  1646. /**
  1647. * Get the actual value for an attribute from the current context.
  1648. *
  1649. * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to get
  1650. * \param value a pointer filled in with the current value of `attr`
  1651. * \returns 0 on success or a negative error code on failure; call
  1652. * SDL_GetError() for more information.
  1653. *
  1654. * \since This function is available since SDL 3.0.0.
  1655. *
  1656. * \sa SDL_GL_ResetAttributes
  1657. * \sa SDL_GL_SetAttribute
  1658. */
  1659. extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
  1660. /**
  1661. * Create an OpenGL context for an OpenGL window, and make it current.
  1662. *
  1663. * Windows users new to OpenGL should note that, for historical reasons, GL
  1664. * functions added after OpenGL version 1.1 are not available by default.
  1665. * Those functions must be loaded at run-time, either with an OpenGL
  1666. * extension-handling library or with SDL_GL_GetProcAddress() and its related
  1667. * functions.
  1668. *
  1669. * SDL_GLContext is an alias for `void *`. It's opaque to the application.
  1670. *
  1671. * \param window the window to associate with the context
  1672. * \returns the OpenGL context associated with `window` or NULL on error; call
  1673. * SDL_GetError() for more details.
  1674. *
  1675. * \since This function is available since SDL 3.0.0.
  1676. *
  1677. * \sa SDL_GL_DeleteContext
  1678. * \sa SDL_GL_MakeCurrent
  1679. */
  1680. extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window);
  1681. /**
  1682. * Set up an OpenGL context for rendering into an OpenGL window.
  1683. *
  1684. * The context must have been created with a compatible window.
  1685. *
  1686. * \param window the window to associate with the context
  1687. * \param context the OpenGL context to associate with the window
  1688. * \returns 0 on success or a negative error code on failure; call
  1689. * SDL_GetError() for more information.
  1690. *
  1691. * \since This function is available since SDL 3.0.0.
  1692. *
  1693. * \sa SDL_GL_CreateContext
  1694. */
  1695. extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
  1696. /**
  1697. * Get the currently active OpenGL window.
  1698. *
  1699. * \returns the currently active OpenGL window on success or NULL on failure;
  1700. * call SDL_GetError() for more information.
  1701. *
  1702. * \since This function is available since SDL 3.0.0.
  1703. */
  1704. extern DECLSPEC SDL_Window *SDLCALL SDL_GL_GetCurrentWindow(void);
  1705. /**
  1706. * Get the currently active OpenGL context.
  1707. *
  1708. * \returns the currently active OpenGL context or NULL on failure; call
  1709. * SDL_GetError() for more information.
  1710. *
  1711. * \since This function is available since SDL 3.0.0.
  1712. *
  1713. * \sa SDL_GL_MakeCurrent
  1714. */
  1715. extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
  1716. /**
  1717. * Get the currently active EGL display.
  1718. *
  1719. * \returns the currently active EGL display or NULL on failure; call
  1720. * SDL_GetError() for more information.
  1721. *
  1722. * \since This function is available since SDL 3.0.0.
  1723. */
  1724. extern DECLSPEC SDL_EGLDisplay SDLCALL SDL_EGL_GetCurrentEGLDisplay(void);
  1725. /**
  1726. * Get the currently active EGL config.
  1727. *
  1728. * \returns the currently active EGL config or NULL on failure; call
  1729. * SDL_GetError() for more information.
  1730. *
  1731. * \since This function is available since SDL 3.0.0.
  1732. */
  1733. extern DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentEGLConfig(void);
  1734. /**
  1735. * Get the EGL surface associated with the window.
  1736. *
  1737. * \returns the EGLSurface pointer associated with the window, or NULL on
  1738. * failure.
  1739. *
  1740. * \since This function is available since SDL 3.0.0.
  1741. */
  1742. extern DECLSPEC SDL_EGLSurface SDLCALL SDL_EGL_GetWindowEGLSurface(SDL_Window *window);
  1743. /**
  1744. * Sets the callbacks for defining custom EGLAttrib arrays for EGL
  1745. * initialization.
  1746. *
  1747. * Each callback should return a pointer to an EGL attribute array terminated
  1748. * with EGL_NONE. Callbacks may return NULL pointers to signal an error, which
  1749. * will cause the SDL_CreateWindow process to fail gracefully.
  1750. *
  1751. * The arrays returned by each callback will be appended to the existing
  1752. * attribute arrays defined by SDL.
  1753. *
  1754. * NOTE: These callback pointers will be reset after SDL_GL_ResetAttributes.
  1755. *
  1756. * \param platformAttribCallback Callback for attributes to pass to
  1757. * eglGetPlatformDisplay.
  1758. * \param surfaceAttribCallback Callback for attributes to pass to
  1759. * eglCreateSurface.
  1760. * \param contextAttribCallback Callback for attributes to pass to
  1761. * eglCreateContext.
  1762. *
  1763. * \since This function is available since SDL 3.0.0.
  1764. */
  1765. extern DECLSPEC void SDLCALL SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback,
  1766. SDL_EGLIntArrayCallback surfaceAttribCallback,
  1767. SDL_EGLIntArrayCallback contextAttribCallback);
  1768. /**
  1769. * Set the swap interval for the current OpenGL context.
  1770. *
  1771. * Some systems allow specifying -1 for the interval, to enable adaptive
  1772. * vsync. Adaptive vsync works the same as vsync, but if you've already missed
  1773. * the vertical retrace for a given frame, it swaps buffers immediately, which
  1774. * might be less jarring for the user during occasional framerate drops. If an
  1775. * application requests adaptive vsync and the system does not support it,
  1776. * this function will fail and return -1. In such a case, you should probably
  1777. * retry the call with 1 for the interval.
  1778. *
  1779. * Adaptive vsync is implemented for some glX drivers with
  1780. * GLX_EXT_swap_control_tear, and for some Windows drivers with
  1781. * WGL_EXT_swap_control_tear.
  1782. *
  1783. * Read more on the Khronos wiki:
  1784. * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync
  1785. *
  1786. * \param interval 0 for immediate updates, 1 for updates synchronized with
  1787. * the vertical retrace, -1 for adaptive vsync
  1788. * \returns 0 on success or -1 if setting the swap interval is not supported;
  1789. * call SDL_GetError() for more information.
  1790. *
  1791. * \since This function is available since SDL 3.0.0.
  1792. *
  1793. * \sa SDL_GL_GetSwapInterval
  1794. */
  1795. extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
  1796. /**
  1797. * Get the swap interval for the current OpenGL context.
  1798. *
  1799. * If the system can't determine the swap interval, or there isn't a valid
  1800. * current context, this function will set *interval to 0 as a safe default.
  1801. *
  1802. * \param interval Output interval value. 0 if there is no vertical retrace
  1803. * synchronization, 1 if the buffer swap is synchronized with
  1804. * the vertical retrace, and -1 if late swaps happen
  1805. * immediately instead of waiting for the next retrace
  1806. * \returns 0 on success or -1 error. call SDL_GetError() for more
  1807. * information.
  1808. *
  1809. * \since This function is available since SDL 3.0.0.
  1810. *
  1811. * \sa SDL_GL_SetSwapInterval
  1812. */
  1813. extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(int *interval);
  1814. /**
  1815. * Update a window with OpenGL rendering.
  1816. *
  1817. * This is used with double-buffered OpenGL contexts, which are the default.
  1818. *
  1819. * On macOS, make sure you bind 0 to the draw framebuffer before swapping the
  1820. * window, otherwise nothing will happen. If you aren't using
  1821. * glBindFramebuffer(), this is the default and you won't have to do anything
  1822. * extra.
  1823. *
  1824. * \param window the window to change
  1825. * \returns 0 on success or a negative error code on failure; call
  1826. * SDL_GetError() for more information.
  1827. *
  1828. * \since This function is available since SDL 3.0.0.
  1829. */
  1830. extern DECLSPEC int SDLCALL SDL_GL_SwapWindow(SDL_Window *window);
  1831. /**
  1832. * Delete an OpenGL context.
  1833. *
  1834. * \param context the OpenGL context to be deleted
  1835. *
  1836. * \since This function is available since SDL 3.0.0.
  1837. *
  1838. * \sa SDL_GL_CreateContext
  1839. */
  1840. extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
  1841. /* @} *//* OpenGL support functions */
  1842. /* Ends C function definitions when using C++ */
  1843. #ifdef __cplusplus
  1844. }
  1845. #endif
  1846. #include <SDL3/SDL_close_code.h>
  1847. #endif /* SDL_video_h_ */