SDL_video.h 69 KB

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