SDL_video.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2014 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 "SDL_stdinc.h"
  26. #include "SDL_pixels.h"
  27. #include "SDL_rect.h"
  28. #include "SDL_surface.h"
  29. #include "begin_code.h"
  30. /* Set up for C function definitions, even when using C++ */
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /**
  35. * \brief The structure that defines a display mode
  36. *
  37. * \sa SDL_GetNumDisplayModes()
  38. * \sa SDL_GetDisplayMode()
  39. * \sa SDL_GetDesktopDisplayMode()
  40. * \sa SDL_GetCurrentDisplayMode()
  41. * \sa SDL_GetClosestDisplayMode()
  42. * \sa SDL_SetWindowDisplayMode()
  43. * \sa SDL_GetWindowDisplayMode()
  44. */
  45. typedef struct
  46. {
  47. Uint32 format; /**< pixel format */
  48. int w; /**< width */
  49. int h; /**< height */
  50. int refresh_rate; /**< refresh rate (or zero for unspecified) */
  51. void *driverdata; /**< driver-specific data, initialize to 0 */
  52. } SDL_DisplayMode;
  53. /**
  54. * \brief The type used to identify a window
  55. *
  56. * \sa SDL_CreateWindow()
  57. * \sa SDL_CreateWindowFrom()
  58. * \sa SDL_DestroyWindow()
  59. * \sa SDL_GetWindowData()
  60. * \sa SDL_GetWindowFlags()
  61. * \sa SDL_GetWindowGrab()
  62. * \sa SDL_GetWindowPosition()
  63. * \sa SDL_GetWindowSize()
  64. * \sa SDL_GetWindowTitle()
  65. * \sa SDL_HideWindow()
  66. * \sa SDL_MaximizeWindow()
  67. * \sa SDL_MinimizeWindow()
  68. * \sa SDL_RaiseWindow()
  69. * \sa SDL_RestoreWindow()
  70. * \sa SDL_SetWindowData()
  71. * \sa SDL_SetWindowFullscreen()
  72. * \sa SDL_SetWindowGrab()
  73. * \sa SDL_SetWindowIcon()
  74. * \sa SDL_SetWindowPosition()
  75. * \sa SDL_SetWindowSize()
  76. * \sa SDL_SetWindowBordered()
  77. * \sa SDL_SetWindowTitle()
  78. * \sa SDL_ShowWindow()
  79. */
  80. typedef struct SDL_Window SDL_Window;
  81. /**
  82. * \brief The flags on a window
  83. *
  84. * \sa SDL_GetWindowFlags()
  85. */
  86. typedef enum
  87. {
  88. SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */
  89. SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
  90. SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */
  91. SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
  92. SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
  93. SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
  94. SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */
  95. SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */
  96. SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */
  97. SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
  98. SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
  99. SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
  100. SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
  101. SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /**< window should be created in high-DPI mode if supported */
  102. } SDL_WindowFlags;
  103. /**
  104. * \brief Used to indicate that you don't care what the window position is.
  105. */
  106. #define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000
  107. #define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
  108. #define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
  109. #define SDL_WINDOWPOS_ISUNDEFINED(X) \
  110. (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
  111. /**
  112. * \brief Used to indicate that the window position should be centered.
  113. */
  114. #define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000
  115. #define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
  116. #define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
  117. #define SDL_WINDOWPOS_ISCENTERED(X) \
  118. (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
  119. /**
  120. * \brief Event subtype for window events
  121. */
  122. typedef enum
  123. {
  124. SDL_WINDOWEVENT_NONE, /**< Never used */
  125. SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */
  126. SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */
  127. SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be
  128. redrawn */
  129. SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2
  130. */
  131. SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */
  132. SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */
  133. SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */
  134. SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */
  135. SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size
  136. and position */
  137. SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */
  138. SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */
  139. SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */
  140. SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */
  141. SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the
  142. window be closed */
  143. } SDL_WindowEventID;
  144. /**
  145. * \brief An opaque handle to an OpenGL context.
  146. */
  147. typedef void *SDL_GLContext;
  148. /**
  149. * \brief OpenGL configuration attributes
  150. */
  151. typedef enum
  152. {
  153. SDL_GL_RED_SIZE,
  154. SDL_GL_GREEN_SIZE,
  155. SDL_GL_BLUE_SIZE,
  156. SDL_GL_ALPHA_SIZE,
  157. SDL_GL_BUFFER_SIZE,
  158. SDL_GL_DOUBLEBUFFER,
  159. SDL_GL_DEPTH_SIZE,
  160. SDL_GL_STENCIL_SIZE,
  161. SDL_GL_ACCUM_RED_SIZE,
  162. SDL_GL_ACCUM_GREEN_SIZE,
  163. SDL_GL_ACCUM_BLUE_SIZE,
  164. SDL_GL_ACCUM_ALPHA_SIZE,
  165. SDL_GL_STEREO,
  166. SDL_GL_MULTISAMPLEBUFFERS,
  167. SDL_GL_MULTISAMPLESAMPLES,
  168. SDL_GL_ACCELERATED_VISUAL,
  169. SDL_GL_RETAINED_BACKING,
  170. SDL_GL_CONTEXT_MAJOR_VERSION,
  171. SDL_GL_CONTEXT_MINOR_VERSION,
  172. SDL_GL_CONTEXT_EGL,
  173. SDL_GL_CONTEXT_FLAGS,
  174. SDL_GL_CONTEXT_PROFILE_MASK,
  175. SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
  176. SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
  177. } SDL_GLattr;
  178. typedef enum
  179. {
  180. SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
  181. SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
  182. SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /* GLX_CONTEXT_ES2_PROFILE_BIT_EXT */
  183. } SDL_GLprofile;
  184. typedef enum
  185. {
  186. SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
  187. SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
  188. SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
  189. SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
  190. } SDL_GLcontextFlag;
  191. /* Function prototypes */
  192. /**
  193. * \brief Get the number of video drivers compiled into SDL
  194. *
  195. * \sa SDL_GetVideoDriver()
  196. */
  197. extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void);
  198. /**
  199. * \brief Get the name of a built in video driver.
  200. *
  201. * \note The video drivers are presented in the order in which they are
  202. * normally checked during initialization.
  203. *
  204. * \sa SDL_GetNumVideoDrivers()
  205. */
  206. extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
  207. /**
  208. * \brief Initialize the video subsystem, optionally specifying a video driver.
  209. *
  210. * \param driver_name Initialize a specific driver by name, or NULL for the
  211. * default video driver.
  212. *
  213. * \return 0 on success, -1 on error
  214. *
  215. * This function initializes the video subsystem; setting up a connection
  216. * to the window manager, etc, and determines the available display modes
  217. * and pixel formats, but does not initialize a window or graphics mode.
  218. *
  219. * \sa SDL_VideoQuit()
  220. */
  221. extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name);
  222. /**
  223. * \brief Shuts down the video subsystem.
  224. *
  225. * This function closes all windows, and restores the original video mode.
  226. *
  227. * \sa SDL_VideoInit()
  228. */
  229. extern DECLSPEC void SDLCALL SDL_VideoQuit(void);
  230. /**
  231. * \brief Returns the name of the currently initialized video driver.
  232. *
  233. * \return The name of the current video driver or NULL if no driver
  234. * has been initialized
  235. *
  236. * \sa SDL_GetNumVideoDrivers()
  237. * \sa SDL_GetVideoDriver()
  238. */
  239. extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
  240. /**
  241. * \brief Returns the number of available video displays.
  242. *
  243. * \sa SDL_GetDisplayBounds()
  244. */
  245. extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
  246. /**
  247. * \brief Get the name of a display in UTF-8 encoding
  248. *
  249. * \return The name of a display, or NULL for an invalid display index.
  250. *
  251. * \sa SDL_GetNumVideoDisplays()
  252. */
  253. extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex);
  254. /**
  255. * \brief Get the desktop area represented by a display, with the primary
  256. * display located at 0,0
  257. *
  258. * \return 0 on success, or -1 if the index is out of range.
  259. *
  260. * \sa SDL_GetNumVideoDisplays()
  261. */
  262. extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);
  263. /**
  264. * \brief Returns the number of available display modes.
  265. *
  266. * \sa SDL_GetDisplayMode()
  267. */
  268. extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
  269. /**
  270. * \brief Fill in information about a specific display mode.
  271. *
  272. * \note The display modes are sorted in this priority:
  273. * \li bits per pixel -> more colors to fewer colors
  274. * \li width -> largest to smallest
  275. * \li height -> largest to smallest
  276. * \li refresh rate -> highest to lowest
  277. *
  278. * \sa SDL_GetNumDisplayModes()
  279. */
  280. extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
  281. SDL_DisplayMode * mode);
  282. /**
  283. * \brief Fill in information about the desktop display mode.
  284. */
  285. extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode);
  286. /**
  287. * \brief Fill in information about the current display mode.
  288. */
  289. extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode);
  290. /**
  291. * \brief Get the closest match to the requested display mode.
  292. *
  293. * \param displayIndex The index of display from which mode should be queried.
  294. * \param mode The desired display mode
  295. * \param closest A pointer to a display mode to be filled in with the closest
  296. * match of the available display modes.
  297. *
  298. * \return The passed in value \c closest, or NULL if no matching video mode
  299. * was available.
  300. *
  301. * The available display modes are scanned, and \c closest is filled in with the
  302. * closest mode matching the requested mode and returned. The mode format and
  303. * refresh_rate default to the desktop mode if they are 0. The modes are
  304. * scanned with size being first priority, format being second priority, and
  305. * finally checking the refresh_rate. If all the available modes are too
  306. * small, then NULL is returned.
  307. *
  308. * \sa SDL_GetNumDisplayModes()
  309. * \sa SDL_GetDisplayMode()
  310. */
  311. extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
  312. /**
  313. * \brief Get the display index associated with a window.
  314. *
  315. * \return the display index of the display containing the center of the
  316. * window, or -1 on error.
  317. */
  318. extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window);
  319. /**
  320. * \brief Set the display mode used when a fullscreen window is visible.
  321. *
  322. * By default the window's dimensions and the desktop format and refresh rate
  323. * are used.
  324. *
  325. * \param window The window for which the display mode should be set.
  326. * \param mode The mode to use, or NULL for the default mode.
  327. *
  328. * \return 0 on success, or -1 if setting the display mode failed.
  329. *
  330. * \sa SDL_GetWindowDisplayMode()
  331. * \sa SDL_SetWindowFullscreen()
  332. */
  333. extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
  334. const SDL_DisplayMode
  335. * mode);
  336. /**
  337. * \brief Fill in information about the display mode used when a fullscreen
  338. * window is visible.
  339. *
  340. * \sa SDL_SetWindowDisplayMode()
  341. * \sa SDL_SetWindowFullscreen()
  342. */
  343. extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
  344. SDL_DisplayMode * mode);
  345. /**
  346. * \brief Get the pixel format associated with the window.
  347. */
  348. extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
  349. /**
  350. * \brief Create a window with the specified position, dimensions, and flags.
  351. *
  352. * \param title The title of the window, in UTF-8 encoding.
  353. * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
  354. * ::SDL_WINDOWPOS_UNDEFINED.
  355. * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
  356. * ::SDL_WINDOWPOS_UNDEFINED.
  357. * \param w The width of the window.
  358. * \param h The height of the window.
  359. * \param flags The flags for the window, a mask of any of the following:
  360. * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL,
  361. * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS,
  362. * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED,
  363. * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED,
  364. * ::SDL_WINDOW_ALLOW_HIGHDPI.
  365. *
  366. * \return The id of the window created, or zero if window creation failed.
  367. *
  368. * \sa SDL_DestroyWindow()
  369. */
  370. extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
  371. int x, int y, int w,
  372. int h, Uint32 flags);
  373. /**
  374. * \brief Create an SDL window from an existing native window.
  375. *
  376. * \param data A pointer to driver-dependent window creation data
  377. *
  378. * \return The id of the window created, or zero if window creation failed.
  379. *
  380. * \sa SDL_DestroyWindow()
  381. */
  382. extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data);
  383. /**
  384. * \brief Get the numeric ID of a window, for logging purposes.
  385. */
  386. extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window);
  387. /**
  388. * \brief Get a window from a stored ID, or NULL if it doesn't exist.
  389. */
  390. extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id);
  391. /**
  392. * \brief Get the window flags.
  393. */
  394. extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window);
  395. /**
  396. * \brief Set the title of a window, in UTF-8 format.
  397. *
  398. * \sa SDL_GetWindowTitle()
  399. */
  400. extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
  401. const char *title);
  402. /**
  403. * \brief Get the title of a window, in UTF-8 format.
  404. *
  405. * \sa SDL_SetWindowTitle()
  406. */
  407. extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
  408. /**
  409. * \brief Set the icon for a window.
  410. *
  411. * \param window The window for which the icon should be set.
  412. * \param icon The icon for the window.
  413. */
  414. extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
  415. SDL_Surface * icon);
  416. /**
  417. * \brief Associate an arbitrary named pointer with a window.
  418. *
  419. * \param window The window to associate with the pointer.
  420. * \param name The name of the pointer.
  421. * \param userdata The associated pointer.
  422. *
  423. * \return The previous value associated with 'name'
  424. *
  425. * \note The name is case-sensitive.
  426. *
  427. * \sa SDL_GetWindowData()
  428. */
  429. extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
  430. const char *name,
  431. void *userdata);
  432. /**
  433. * \brief Retrieve the data pointer associated with a window.
  434. *
  435. * \param window The window to query.
  436. * \param name The name of the pointer.
  437. *
  438. * \return The value associated with 'name'
  439. *
  440. * \sa SDL_SetWindowData()
  441. */
  442. extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window,
  443. const char *name);
  444. /**
  445. * \brief Set the position of a window.
  446. *
  447. * \param window The window to reposition.
  448. * \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
  449. ::SDL_WINDOWPOS_UNDEFINED.
  450. * \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
  451. ::SDL_WINDOWPOS_UNDEFINED.
  452. *
  453. * \note The window coordinate origin is the upper left of the display.
  454. *
  455. * \sa SDL_GetWindowPosition()
  456. */
  457. extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
  458. int x, int y);
  459. /**
  460. * \brief Get the position of a window.
  461. *
  462. * \param window The window to query.
  463. * \param x Pointer to variable for storing the x position, may be NULL
  464. * \param y Pointer to variable for storing the y position, may be NULL
  465. *
  466. * \sa SDL_SetWindowPosition()
  467. */
  468. extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
  469. int *x, int *y);
  470. /**
  471. * \brief Set the size of a window's client area.
  472. *
  473. * \param window The window to resize.
  474. * \param w The width of the window, must be >0
  475. * \param h The height of the window, must be >0
  476. *
  477. * \note You can't change the size of a fullscreen window, it automatically
  478. * matches the size of the display mode.
  479. *
  480. * \sa SDL_GetWindowSize()
  481. */
  482. extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
  483. int h);
  484. /**
  485. * \brief Get the size of a window's client area.
  486. *
  487. * \param window The window to query.
  488. * \param w Pointer to variable for storing the width, may be NULL
  489. * \param h Pointer to variable for storing the height, may be NULL
  490. *
  491. * \sa SDL_SetWindowSize()
  492. */
  493. extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
  494. int *h);
  495. /**
  496. * \brief Set the minimum size of a window's client area.
  497. *
  498. * \param window The window to set a new minimum size.
  499. * \param min_w The minimum width of the window, must be >0
  500. * \param min_h The minimum height of the window, must be >0
  501. *
  502. * \note You can't change the minimum size of a fullscreen window, it
  503. * automatically matches the size of the display mode.
  504. *
  505. * \sa SDL_GetWindowMinimumSize()
  506. * \sa SDL_SetWindowMaximumSize()
  507. */
  508. extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
  509. int min_w, int min_h);
  510. /**
  511. * \brief Get the minimum size of a window's client area.
  512. *
  513. * \param window The window to query.
  514. * \param w Pointer to variable for storing the minimum width, may be NULL
  515. * \param h Pointer to variable for storing the minimum height, may be NULL
  516. *
  517. * \sa SDL_GetWindowMaximumSize()
  518. * \sa SDL_SetWindowMinimumSize()
  519. */
  520. extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
  521. int *w, int *h);
  522. /**
  523. * \brief Set the maximum size of a window's client area.
  524. *
  525. * \param window The window to set a new maximum size.
  526. * \param max_w The maximum width of the window, must be >0
  527. * \param max_h The maximum height of the window, must be >0
  528. *
  529. * \note You can't change the maximum size of a fullscreen window, it
  530. * automatically matches the size of the display mode.
  531. *
  532. * \sa SDL_GetWindowMaximumSize()
  533. * \sa SDL_SetWindowMinimumSize()
  534. */
  535. extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,
  536. int max_w, int max_h);
  537. /**
  538. * \brief Get the maximum size of a window's client area.
  539. *
  540. * \param window The window to query.
  541. * \param w Pointer to variable for storing the maximum width, may be NULL
  542. * \param h Pointer to variable for storing the maximum height, may be NULL
  543. *
  544. * \sa SDL_GetWindowMinimumSize()
  545. * \sa SDL_SetWindowMaximumSize()
  546. */
  547. extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window,
  548. int *w, int *h);
  549. /**
  550. * \brief Set the border state of a window.
  551. *
  552. * This will add or remove the window's SDL_WINDOW_BORDERLESS flag and
  553. * add or remove the border from the actual window. This is a no-op if the
  554. * window's border already matches the requested state.
  555. *
  556. * \param window The window of which to change the border state.
  557. * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border.
  558. *
  559. * \note You can't change the border state of a fullscreen window.
  560. *
  561. * \sa SDL_GetWindowFlags()
  562. */
  563. extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
  564. SDL_bool bordered);
  565. /**
  566. * \brief Show a window.
  567. *
  568. * \sa SDL_HideWindow()
  569. */
  570. extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window);
  571. /**
  572. * \brief Hide a window.
  573. *
  574. * \sa SDL_ShowWindow()
  575. */
  576. extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window);
  577. /**
  578. * \brief Raise a window above other windows and set the input focus.
  579. */
  580. extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window);
  581. /**
  582. * \brief Make a window as large as possible.
  583. *
  584. * \sa SDL_RestoreWindow()
  585. */
  586. extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window);
  587. /**
  588. * \brief Minimize a window to an iconic representation.
  589. *
  590. * \sa SDL_RestoreWindow()
  591. */
  592. extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window);
  593. /**
  594. * \brief Restore the size and position of a minimized or maximized window.
  595. *
  596. * \sa SDL_MaximizeWindow()
  597. * \sa SDL_MinimizeWindow()
  598. */
  599. extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
  600. /**
  601. * \brief Set a window's fullscreen state.
  602. *
  603. * \return 0 on success, or -1 if setting the display mode failed.
  604. *
  605. * \sa SDL_SetWindowDisplayMode()
  606. * \sa SDL_GetWindowDisplayMode()
  607. */
  608. extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
  609. Uint32 flags);
  610. /**
  611. * \brief Get the SDL surface associated with the window.
  612. *
  613. * \return The window's framebuffer surface, or NULL on error.
  614. *
  615. * A new surface will be created with the optimal format for the window,
  616. * if necessary. This surface will be freed when the window is destroyed.
  617. *
  618. * \note You may not combine this with 3D or the rendering API on this window.
  619. *
  620. * \sa SDL_UpdateWindowSurface()
  621. * \sa SDL_UpdateWindowSurfaceRects()
  622. */
  623. extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window);
  624. /**
  625. * \brief Copy the window surface to the screen.
  626. *
  627. * \return 0 on success, or -1 on error.
  628. *
  629. * \sa SDL_GetWindowSurface()
  630. * \sa SDL_UpdateWindowSurfaceRects()
  631. */
  632. extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
  633. /**
  634. * \brief Copy a number of rectangles on the window surface to the screen.
  635. *
  636. * \return 0 on success, or -1 on error.
  637. *
  638. * \sa SDL_GetWindowSurface()
  639. * \sa SDL_UpdateWindowSurfaceRect()
  640. */
  641. extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
  642. const SDL_Rect * rects,
  643. int numrects);
  644. /**
  645. * \brief Set a window's input grab mode.
  646. *
  647. * \param window The window for which the input grab mode should be set.
  648. * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input.
  649. *
  650. * \sa SDL_GetWindowGrab()
  651. */
  652. extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
  653. SDL_bool grabbed);
  654. /**
  655. * \brief Get a window's input grab mode.
  656. *
  657. * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise.
  658. *
  659. * \sa SDL_SetWindowGrab()
  660. */
  661. extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window);
  662. /**
  663. * \brief Set the brightness (gamma correction) for a window.
  664. *
  665. * \return 0 on success, or -1 if setting the brightness isn't supported.
  666. *
  667. * \sa SDL_GetWindowBrightness()
  668. * \sa SDL_SetWindowGammaRamp()
  669. */
  670. extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness);
  671. /**
  672. * \brief Get the brightness (gamma correction) for a window.
  673. *
  674. * \return The last brightness value passed to SDL_SetWindowBrightness()
  675. *
  676. * \sa SDL_SetWindowBrightness()
  677. */
  678. extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window);
  679. /**
  680. * \brief Set the gamma ramp for a window.
  681. *
  682. * \param window The window for which the gamma ramp should be set.
  683. * \param red The translation table for the red channel, or NULL.
  684. * \param green The translation table for the green channel, or NULL.
  685. * \param blue The translation table for the blue channel, or NULL.
  686. *
  687. * \return 0 on success, or -1 if gamma ramps are unsupported.
  688. *
  689. * Set the gamma translation table for the red, green, and blue channels
  690. * of the video hardware. Each table is an array of 256 16-bit quantities,
  691. * representing a mapping between the input and output for that channel.
  692. * The input is the index into the array, and the output is the 16-bit
  693. * gamma value at that index, scaled to the output color precision.
  694. *
  695. * \sa SDL_GetWindowGammaRamp()
  696. */
  697. extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window,
  698. const Uint16 * red,
  699. const Uint16 * green,
  700. const Uint16 * blue);
  701. /**
  702. * \brief Get the gamma ramp for a window.
  703. *
  704. * \param window The window from which the gamma ramp should be queried.
  705. * \param red A pointer to a 256 element array of 16-bit quantities to hold
  706. * the translation table for the red channel, or NULL.
  707. * \param green A pointer to a 256 element array of 16-bit quantities to hold
  708. * the translation table for the green channel, or NULL.
  709. * \param blue A pointer to a 256 element array of 16-bit quantities to hold
  710. * the translation table for the blue channel, or NULL.
  711. *
  712. * \return 0 on success, or -1 if gamma ramps are unsupported.
  713. *
  714. * \sa SDL_SetWindowGammaRamp()
  715. */
  716. extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window,
  717. Uint16 * red,
  718. Uint16 * green,
  719. Uint16 * blue);
  720. /**
  721. * \brief Destroy a window.
  722. */
  723. extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window);
  724. /**
  725. * \brief Returns whether the screensaver is currently enabled (default on).
  726. *
  727. * \sa SDL_EnableScreenSaver()
  728. * \sa SDL_DisableScreenSaver()
  729. */
  730. extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void);
  731. /**
  732. * \brief Allow the screen to be blanked by a screensaver
  733. *
  734. * \sa SDL_IsScreenSaverEnabled()
  735. * \sa SDL_DisableScreenSaver()
  736. */
  737. extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void);
  738. /**
  739. * \brief Prevent the screen from being blanked by a screensaver
  740. *
  741. * \sa SDL_IsScreenSaverEnabled()
  742. * \sa SDL_EnableScreenSaver()
  743. */
  744. extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void);
  745. /**
  746. * \name OpenGL support functions
  747. */
  748. /* @{ */
  749. /**
  750. * \brief Dynamically load an OpenGL library.
  751. *
  752. * \param path The platform dependent OpenGL library name, or NULL to open the
  753. * default OpenGL library.
  754. *
  755. * \return 0 on success, or -1 if the library couldn't be loaded.
  756. *
  757. * This should be done after initializing the video driver, but before
  758. * creating any OpenGL windows. If no OpenGL library is loaded, the default
  759. * library will be loaded upon creation of the first OpenGL window.
  760. *
  761. * \note If you do this, you need to retrieve all of the GL functions used in
  762. * your program from the dynamic library using SDL_GL_GetProcAddress().
  763. *
  764. * \sa SDL_GL_GetProcAddress()
  765. * \sa SDL_GL_UnloadLibrary()
  766. */
  767. extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path);
  768. /**
  769. * \brief Get the address of an OpenGL function.
  770. */
  771. extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc);
  772. /**
  773. * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary().
  774. *
  775. * \sa SDL_GL_LoadLibrary()
  776. */
  777. extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
  778. /**
  779. * \brief Return true if an OpenGL extension is supported for the current
  780. * context.
  781. */
  782. extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char
  783. *extension);
  784. /**
  785. * \brief Reset all previously set OpenGL context attributes to their default values
  786. */
  787. extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void);
  788. /**
  789. * \brief Set an OpenGL window attribute before window creation.
  790. */
  791. extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value);
  792. /**
  793. * \brief Get the actual value for an attribute from the current context.
  794. */
  795. extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
  796. /**
  797. * \brief Create an OpenGL context for use with an OpenGL window, and make it
  798. * current.
  799. *
  800. * \sa SDL_GL_DeleteContext()
  801. */
  802. extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *
  803. window);
  804. /**
  805. * \brief Set up an OpenGL context for rendering into an OpenGL window.
  806. *
  807. * \note The context must have been created with a compatible window.
  808. */
  809. extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window,
  810. SDL_GLContext context);
  811. /**
  812. * \brief Get the currently active OpenGL window.
  813. */
  814. extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void);
  815. /**
  816. * \brief Get the currently active OpenGL context.
  817. */
  818. extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void);
  819. /**
  820. * \brief Get the size of a window's underlying drawable (for use with glViewport).
  821. *
  822. * \param window Window from which the drawable size should be queried
  823. * \param w Pointer to variable for storing the width, may be NULL
  824. * \param h Pointer to variable for storing the height, may be NULL
  825. *
  826. * This may differ from SDL_GetWindowSize if we're rendering to a high-DPI
  827. * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a
  828. * platform with high-DPI support (Apple calls this "Retina"), and not disabled
  829. * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.
  830. *
  831. * \sa SDL_GetWindowSize()
  832. * \sa SDL_CreateWindow()
  833. */
  834. extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w,
  835. int *h);
  836. /**
  837. * \brief Set the swap interval for the current OpenGL context.
  838. *
  839. * \param interval 0 for immediate updates, 1 for updates synchronized with the
  840. * vertical retrace. If the system supports it, you may
  841. * specify -1 to allow late swaps to happen immediately
  842. * instead of waiting for the next retrace.
  843. *
  844. * \return 0 on success, or -1 if setting the swap interval is not supported.
  845. *
  846. * \sa SDL_GL_GetSwapInterval()
  847. */
  848. extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
  849. /**
  850. * \brief Get the swap interval for the current OpenGL context.
  851. *
  852. * \return 0 if there is no vertical retrace synchronization, 1 if the buffer
  853. * swap is synchronized with the vertical retrace, and -1 if late
  854. * swaps happen immediately instead of waiting for the next retrace.
  855. * If the system can't determine the swap interval, or there isn't a
  856. * valid current context, this will return 0 as a safe default.
  857. *
  858. * \sa SDL_GL_SetSwapInterval()
  859. */
  860. extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void);
  861. /**
  862. * \brief Swap the OpenGL buffers for a window, if double-buffering is
  863. * supported.
  864. */
  865. extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window);
  866. /**
  867. * \brief Delete an OpenGL context.
  868. *
  869. * \sa SDL_GL_CreateContext()
  870. */
  871. extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context);
  872. /* @} *//* OpenGL support functions */
  873. /* Ends C function definitions when using C++ */
  874. #ifdef __cplusplus
  875. }
  876. #endif
  877. #include "close_code.h"
  878. #endif /* _SDL_video_h */
  879. /* vi: set ts=4 sw=4 expandtab: */