You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5913 lines
211 KiB

1 year ago
  1. /*************************************************************************
  2. * GLFW 3.3 - www.glfw.org
  3. * A library for OpenGL, window and input
  4. *------------------------------------------------------------------------
  5. * Copyright (c) 2002-2006 Marcus Geelnard
  6. * Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
  7. *
  8. * This software is provided 'as-is', without any express or implied
  9. * warranty. In no event will the authors be held liable for any damages
  10. * arising from the use of this software.
  11. *
  12. * Permission is granted to anyone to use this software for any purpose,
  13. * including commercial applications, and to alter it and redistribute it
  14. * freely, subject to the following restrictions:
  15. *
  16. * 1. The origin of this software must not be misrepresented; you must not
  17. * claim that you wrote the original software. If you use this software
  18. * in a product, an acknowledgment in the product documentation would
  19. * be appreciated but is not required.
  20. *
  21. * 2. Altered source versions must be plainly marked as such, and must not
  22. * be misrepresented as being the original software.
  23. *
  24. * 3. This notice may not be removed or altered from any source
  25. * distribution.
  26. *
  27. *************************************************************************/
  28. #ifndef _glfw3_h_
  29. #define _glfw3_h_
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /*************************************************************************
  34. * Doxygen documentation
  35. *************************************************************************/
  36. /*! @file glfw3.h
  37. * @brief The header of the GLFW 3 API.
  38. *
  39. * This is the header file of the GLFW 3 API. It defines all its types and
  40. * declares all its functions.
  41. *
  42. * For more information about how to use this file, see @ref build_include.
  43. */
  44. /*! @defgroup context Context reference
  45. * @brief Functions and types related to OpenGL and OpenGL ES contexts.
  46. *
  47. * This is the reference documentation for OpenGL and OpenGL ES context related
  48. * functions. For more task-oriented information, see the @ref context_guide.
  49. */
  50. /*! @defgroup vulkan Vulkan support reference
  51. * @brief Functions and types related to Vulkan.
  52. *
  53. * This is the reference documentation for Vulkan related functions and types.
  54. * For more task-oriented information, see the @ref vulkan_guide.
  55. */
  56. /*! @defgroup init Initialization, version and error reference
  57. * @brief Functions and types related to initialization and error handling.
  58. *
  59. * This is the reference documentation for initialization and termination of
  60. * the library, version management and error handling. For more task-oriented
  61. * information, see the @ref intro_guide.
  62. */
  63. /*! @defgroup input Input reference
  64. * @brief Functions and types related to input handling.
  65. *
  66. * This is the reference documentation for input related functions and types.
  67. * For more task-oriented information, see the @ref input_guide.
  68. */
  69. /*! @defgroup monitor Monitor reference
  70. * @brief Functions and types related to monitors.
  71. *
  72. * This is the reference documentation for monitor related functions and types.
  73. * For more task-oriented information, see the @ref monitor_guide.
  74. */
  75. /*! @defgroup window Window reference
  76. * @brief Functions and types related to windows.
  77. *
  78. * This is the reference documentation for window related functions and types,
  79. * including creation, deletion and event polling. For more task-oriented
  80. * information, see the @ref window_guide.
  81. */
  82. /*************************************************************************
  83. * Compiler- and platform-specific preprocessor work
  84. *************************************************************************/
  85. /* If we are we on Windows, we want a single define for it.
  86. */
  87. #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
  88. #define _WIN32
  89. #endif /* _WIN32 */
  90. /* Include because most Windows GLU headers need wchar_t and
  91. * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
  92. * Include it unconditionally to avoid surprising side-effects.
  93. */
  94. #include <stddef.h>
  95. /* Include because it is needed by Vulkan and related functions.
  96. * Include it unconditionally to avoid surprising side-effects.
  97. */
  98. #include <stdint.h>
  99. #if defined(GLFW_INCLUDE_VULKAN)
  100. #include <vulkan/vulkan.h>
  101. #endif /* Vulkan header */
  102. /* The Vulkan header may have indirectly included windows.h (because of
  103. * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it.
  104. */
  105. /* It is customary to use APIENTRY for OpenGL function pointer declarations on
  106. * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
  107. */
  108. #if !defined(APIENTRY)
  109. #if defined(_WIN32)
  110. #define APIENTRY __stdcall
  111. #else
  112. #define APIENTRY
  113. #endif
  114. #define GLFW_APIENTRY_DEFINED
  115. #endif /* APIENTRY */
  116. /* Some Windows OpenGL headers need this.
  117. */
  118. #if !defined(WINGDIAPI) && defined(_WIN32)
  119. #define WINGDIAPI __declspec(dllimport)
  120. #define GLFW_WINGDIAPI_DEFINED
  121. #endif /* WINGDIAPI */
  122. /* Some Windows GLU headers need this.
  123. */
  124. #if !defined(CALLBACK) && defined(_WIN32)
  125. #define CALLBACK __stdcall
  126. #define GLFW_CALLBACK_DEFINED
  127. #endif /* CALLBACK */
  128. /* Include the chosen OpenGL or OpenGL ES headers.
  129. */
  130. #if defined(GLFW_INCLUDE_ES1)
  131. #include <GLES/gl.h>
  132. #if defined(GLFW_INCLUDE_GLEXT)
  133. #include <GLES/glext.h>
  134. #endif
  135. #elif defined(GLFW_INCLUDE_ES2)
  136. #include <GLES2/gl2.h>
  137. #if defined(GLFW_INCLUDE_GLEXT)
  138. #include <GLES2/gl2ext.h>
  139. #endif
  140. #elif defined(GLFW_INCLUDE_ES3)
  141. #include <GLES3/gl3.h>
  142. #if defined(GLFW_INCLUDE_GLEXT)
  143. #include <GLES2/gl2ext.h>
  144. #endif
  145. #elif defined(GLFW_INCLUDE_ES31)
  146. #include <GLES3/gl31.h>
  147. #if defined(GLFW_INCLUDE_GLEXT)
  148. #include <GLES2/gl2ext.h>
  149. #endif
  150. #elif defined(GLFW_INCLUDE_ES32)
  151. #include <GLES3/gl32.h>
  152. #if defined(GLFW_INCLUDE_GLEXT)
  153. #include <GLES2/gl2ext.h>
  154. #endif
  155. #elif defined(GLFW_INCLUDE_GLCOREARB)
  156. #if defined(__APPLE__)
  157. #include <OpenGL/gl3.h>
  158. #if defined(GLFW_INCLUDE_GLEXT)
  159. #include <OpenGL/gl3ext.h>
  160. #endif /*GLFW_INCLUDE_GLEXT*/
  161. #else /*__APPLE__*/
  162. #include <GL/glcorearb.h>
  163. #if defined(GLFW_INCLUDE_GLEXT)
  164. #include <GL/glext.h>
  165. #endif
  166. #endif /*__APPLE__*/
  167. #elif defined(GLFW_INCLUDE_GLU)
  168. #if defined(__APPLE__)
  169. #if defined(GLFW_INCLUDE_GLU)
  170. #include <OpenGL/glu.h>
  171. #endif
  172. #else /*__APPLE__*/
  173. #if defined(GLFW_INCLUDE_GLU)
  174. #include <GL/glu.h>
  175. #endif
  176. #endif /*__APPLE__*/
  177. #elif !defined(GLFW_INCLUDE_NONE) && \
  178. !defined(__gl_h_) && \
  179. !defined(__gles1_gl_h_) && \
  180. !defined(__gles2_gl2_h_) && \
  181. !defined(__gles2_gl3_h_) && \
  182. !defined(__gles2_gl31_h_) && \
  183. !defined(__gles2_gl32_h_) && \
  184. !defined(__gl_glcorearb_h_) && \
  185. !defined(__gl2_h_) /*legacy*/ && \
  186. !defined(__gl3_h_) /*legacy*/ && \
  187. !defined(__gl31_h_) /*legacy*/ && \
  188. !defined(__gl32_h_) /*legacy*/ && \
  189. !defined(__glcorearb_h_) /*legacy*/ && \
  190. !defined(__GL_H__) /*non-standard*/ && \
  191. !defined(__gltypes_h_) /*non-standard*/ && \
  192. !defined(__glee_h_) /*non-standard*/
  193. #if defined(__APPLE__)
  194. #if !defined(GLFW_INCLUDE_GLEXT)
  195. #define GL_GLEXT_LEGACY
  196. #endif
  197. #include <OpenGL/gl.h>
  198. #else /*__APPLE__*/
  199. #include <GL/gl.h>
  200. #if defined(GLFW_INCLUDE_GLEXT)
  201. #include <GL/glext.h>
  202. #endif
  203. #endif /*__APPLE__*/
  204. #endif /* OpenGL and OpenGL ES headers */
  205. #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
  206. /* GLFW_DLL must be defined by applications that are linking against the DLL
  207. * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
  208. * configuration header when compiling the DLL version of the library.
  209. */
  210. #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
  211. #endif
  212. /* GLFWAPI is used to declare public API functions for export
  213. * from the DLL / shared library / dynamic library.
  214. */
  215. #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
  216. /* We are building GLFW as a Win32 DLL */
  217. #define GLFWAPI __declspec(dllexport)
  218. #elif defined(_WIN32) && defined(GLFW_DLL)
  219. /* We are calling GLFW as a Win32 DLL */
  220. #define GLFWAPI __declspec(dllimport)
  221. #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
  222. /* We are building GLFW as a shared / dynamic library */
  223. #define GLFWAPI __attribute__((visibility("default")))
  224. #else
  225. /* We are building or calling GLFW as a static library */
  226. #define GLFWAPI
  227. #endif
  228. /*************************************************************************
  229. * GLFW API tokens
  230. *************************************************************************/
  231. /*! @name GLFW version macros
  232. * @{ */
  233. /*! @brief The major version number of the GLFW header.
  234. *
  235. * The major version number of the GLFW header. This is incremented when the
  236. * API is changed in non-compatible ways.
  237. * @ingroup init
  238. */
  239. #define GLFW_VERSION_MAJOR 3
  240. /*! @brief The minor version number of the GLFW header.
  241. *
  242. * The minor version number of the GLFW header. This is incremented when
  243. * features are added to the API but it remains backward-compatible.
  244. * @ingroup init
  245. */
  246. #define GLFW_VERSION_MINOR 3
  247. /*! @brief The revision number of the GLFW header.
  248. *
  249. * The revision number of the GLFW header. This is incremented when a bug fix
  250. * release is made that does not contain any API changes.
  251. * @ingroup init
  252. */
  253. #define GLFW_VERSION_REVISION 7
  254. /*! @} */
  255. /*! @brief One.
  256. *
  257. * This is only semantic sugar for the number 1. You can instead use `1` or
  258. * `true` or `_True` or `GL_TRUE` or `VK_TRUE` or anything else that is equal
  259. * to one.
  260. *
  261. * @ingroup init
  262. */
  263. #define GLFW_TRUE 1
  264. /*! @brief Zero.
  265. *
  266. * This is only semantic sugar for the number 0. You can instead use `0` or
  267. * `false` or `_False` or `GL_FALSE` or `VK_FALSE` or anything else that is
  268. * equal to zero.
  269. *
  270. * @ingroup init
  271. */
  272. #define GLFW_FALSE 0
  273. /*! @name Key and button actions
  274. * @{ */
  275. /*! @brief The key or mouse button was released.
  276. *
  277. * The key or mouse button was released.
  278. *
  279. * @ingroup input
  280. */
  281. #define GLFW_RELEASE 0
  282. /*! @brief The key or mouse button was pressed.
  283. *
  284. * The key or mouse button was pressed.
  285. *
  286. * @ingroup input
  287. */
  288. #define GLFW_PRESS 1
  289. /*! @brief The key was held down until it repeated.
  290. *
  291. * The key was held down until it repeated.
  292. *
  293. * @ingroup input
  294. */
  295. #define GLFW_REPEAT 2
  296. /*! @} */
  297. /*! @defgroup hat_state Joystick hat states
  298. * @brief Joystick hat states.
  299. *
  300. * See [joystick hat input](@ref joystick_hat) for how these are used.
  301. *
  302. * @ingroup input
  303. * @{ */
  304. #define GLFW_HAT_CENTERED 0
  305. #define GLFW_HAT_UP 1
  306. #define GLFW_HAT_RIGHT 2
  307. #define GLFW_HAT_DOWN 4
  308. #define GLFW_HAT_LEFT 8
  309. #define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP)
  310. #define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
  311. #define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
  312. #define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
  313. /*! @} */
  314. /*! @defgroup keys Keyboard keys
  315. * @brief Keyboard key IDs.
  316. *
  317. * See [key input](@ref input_key) for how these are used.
  318. *
  319. * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
  320. * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
  321. * put in the 256+ range).
  322. *
  323. * The naming of the key codes follow these rules:
  324. * - The US keyboard layout is used
  325. * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
  326. * "3", etc.)
  327. * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
  328. * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
  329. * correspond to the Unicode standard (usually for brevity)
  330. * - Keys that lack a clear US mapping are named "WORLD_x"
  331. * - For non-printable keys, custom names are used (e.g. "F4",
  332. * "BACKSPACE", etc.)
  333. *
  334. * @ingroup input
  335. * @{
  336. */
  337. /* The unknown key */
  338. #define GLFW_KEY_UNKNOWN -1
  339. /* Printable keys */
  340. #define GLFW_KEY_SPACE 32
  341. #define GLFW_KEY_APOSTROPHE 39 /* ' */
  342. #define GLFW_KEY_COMMA 44 /* , */
  343. #define GLFW_KEY_MINUS 45 /* - */
  344. #define GLFW_KEY_PERIOD 46 /* . */
  345. #define GLFW_KEY_SLASH 47 /* / */
  346. #define GLFW_KEY_0 48
  347. #define GLFW_KEY_1 49
  348. #define GLFW_KEY_2 50
  349. #define GLFW_KEY_3 51
  350. #define GLFW_KEY_4 52
  351. #define GLFW_KEY_5 53
  352. #define GLFW_KEY_6 54
  353. #define GLFW_KEY_7 55
  354. #define GLFW_KEY_8 56
  355. #define GLFW_KEY_9 57
  356. #define GLFW_KEY_SEMICOLON 59 /* ; */
  357. #define GLFW_KEY_EQUAL 61 /* = */
  358. #define GLFW_KEY_A 65
  359. #define GLFW_KEY_B 66
  360. #define GLFW_KEY_C 67
  361. #define GLFW_KEY_D 68
  362. #define GLFW_KEY_E 69
  363. #define GLFW_KEY_F 70
  364. #define GLFW_KEY_G 71
  365. #define GLFW_KEY_H 72
  366. #define GLFW_KEY_I 73
  367. #define GLFW_KEY_J 74
  368. #define GLFW_KEY_K 75
  369. #define GLFW_KEY_L 76
  370. #define GLFW_KEY_M 77
  371. #define GLFW_KEY_N 78
  372. #define GLFW_KEY_O 79
  373. #define GLFW_KEY_P 80
  374. #define GLFW_KEY_Q 81
  375. #define GLFW_KEY_R 82
  376. #define GLFW_KEY_S 83
  377. #define GLFW_KEY_T 84
  378. #define GLFW_KEY_U 85
  379. #define GLFW_KEY_V 86
  380. #define GLFW_KEY_W 87
  381. #define GLFW_KEY_X 88
  382. #define GLFW_KEY_Y 89
  383. #define GLFW_KEY_Z 90
  384. #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
  385. #define GLFW_KEY_BACKSLASH 92 /* \ */
  386. #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
  387. #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
  388. #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
  389. #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
  390. /* Function keys */
  391. #define GLFW_KEY_ESCAPE 256
  392. #define GLFW_KEY_ENTER 257
  393. #define GLFW_KEY_TAB 258
  394. #define GLFW_KEY_BACKSPACE 259
  395. #define GLFW_KEY_INSERT 260
  396. #define GLFW_KEY_DELETE 261
  397. #define GLFW_KEY_RIGHT 262
  398. #define GLFW_KEY_LEFT 263
  399. #define GLFW_KEY_DOWN 264
  400. #define GLFW_KEY_UP 265
  401. #define GLFW_KEY_PAGE_UP 266
  402. #define GLFW_KEY_PAGE_DOWN 267
  403. #define GLFW_KEY_HOME 268
  404. #define GLFW_KEY_END 269
  405. #define GLFW_KEY_CAPS_LOCK 280
  406. #define GLFW_KEY_SCROLL_LOCK 281
  407. #define GLFW_KEY_NUM_LOCK 282
  408. #define GLFW_KEY_PRINT_SCREEN 283
  409. #define GLFW_KEY_PAUSE 284
  410. #define GLFW_KEY_F1 290
  411. #define GLFW_KEY_F2 291
  412. #define GLFW_KEY_F3 292
  413. #define GLFW_KEY_F4 293
  414. #define GLFW_KEY_F5 294
  415. #define GLFW_KEY_F6 295
  416. #define GLFW_KEY_F7 296
  417. #define GLFW_KEY_F8 297
  418. #define GLFW_KEY_F9 298
  419. #define GLFW_KEY_F10 299
  420. #define GLFW_KEY_F11 300
  421. #define GLFW_KEY_F12 301
  422. #define GLFW_KEY_F13 302
  423. #define GLFW_KEY_F14 303
  424. #define GLFW_KEY_F15 304
  425. #define GLFW_KEY_F16 305
  426. #define GLFW_KEY_F17 306
  427. #define GLFW_KEY_F18 307
  428. #define GLFW_KEY_F19 308
  429. #define GLFW_KEY_F20 309
  430. #define GLFW_KEY_F21 310
  431. #define GLFW_KEY_F22 311
  432. #define GLFW_KEY_F23 312
  433. #define GLFW_KEY_F24 313
  434. #define GLFW_KEY_F25 314
  435. #define GLFW_KEY_KP_0 320
  436. #define GLFW_KEY_KP_1 321
  437. #define GLFW_KEY_KP_2 322
  438. #define GLFW_KEY_KP_3 323
  439. #define GLFW_KEY_KP_4 324
  440. #define GLFW_KEY_KP_5 325
  441. #define GLFW_KEY_KP_6 326
  442. #define GLFW_KEY_KP_7 327
  443. #define GLFW_KEY_KP_8 328
  444. #define GLFW_KEY_KP_9 329
  445. #define GLFW_KEY_KP_DECIMAL 330
  446. #define GLFW_KEY_KP_DIVIDE 331
  447. #define GLFW_KEY_KP_MULTIPLY 332
  448. #define GLFW_KEY_KP_SUBTRACT 333
  449. #define GLFW_KEY_KP_ADD 334
  450. #define GLFW_KEY_KP_ENTER 335
  451. #define GLFW_KEY_KP_EQUAL 336
  452. #define GLFW_KEY_LEFT_SHIFT 340
  453. #define GLFW_KEY_LEFT_CONTROL 341
  454. #define GLFW_KEY_LEFT_ALT 342
  455. #define GLFW_KEY_LEFT_SUPER 343
  456. #define GLFW_KEY_RIGHT_SHIFT 344
  457. #define GLFW_KEY_RIGHT_CONTROL 345
  458. #define GLFW_KEY_RIGHT_ALT 346
  459. #define GLFW_KEY_RIGHT_SUPER 347
  460. #define GLFW_KEY_MENU 348
  461. #define GLFW_KEY_LAST GLFW_KEY_MENU
  462. /*! @} */
  463. /*! @defgroup mods Modifier key flags
  464. * @brief Modifier key flags.
  465. *
  466. * See [key input](@ref input_key) for how these are used.
  467. *
  468. * @ingroup input
  469. * @{ */
  470. /*! @brief If this bit is set one or more Shift keys were held down.
  471. *
  472. * If this bit is set one or more Shift keys were held down.
  473. */
  474. #define GLFW_MOD_SHIFT 0x0001
  475. /*! @brief If this bit is set one or more Control keys were held down.
  476. *
  477. * If this bit is set one or more Control keys were held down.
  478. */
  479. #define GLFW_MOD_CONTROL 0x0002
  480. /*! @brief If this bit is set one or more Alt keys were held down.
  481. *
  482. * If this bit is set one or more Alt keys were held down.
  483. */
  484. #define GLFW_MOD_ALT 0x0004
  485. /*! @brief If this bit is set one or more Super keys were held down.
  486. *
  487. * If this bit is set one or more Super keys were held down.
  488. */
  489. #define GLFW_MOD_SUPER 0x0008
  490. /*! @brief If this bit is set the Caps Lock key is enabled.
  491. *
  492. * If this bit is set the Caps Lock key is enabled and the @ref
  493. * GLFW_LOCK_KEY_MODS input mode is set.
  494. */
  495. #define GLFW_MOD_CAPS_LOCK 0x0010
  496. /*! @brief If this bit is set the Num Lock key is enabled.
  497. *
  498. * If this bit is set the Num Lock key is enabled and the @ref
  499. * GLFW_LOCK_KEY_MODS input mode is set.
  500. */
  501. #define GLFW_MOD_NUM_LOCK 0x0020
  502. /*! @} */
  503. /*! @defgroup buttons Mouse buttons
  504. * @brief Mouse button IDs.
  505. *
  506. * See [mouse button input](@ref input_mouse_button) for how these are used.
  507. *
  508. * @ingroup input
  509. * @{ */
  510. #define GLFW_MOUSE_BUTTON_1 0
  511. #define GLFW_MOUSE_BUTTON_2 1
  512. #define GLFW_MOUSE_BUTTON_3 2
  513. #define GLFW_MOUSE_BUTTON_4 3
  514. #define GLFW_MOUSE_BUTTON_5 4
  515. #define GLFW_MOUSE_BUTTON_6 5
  516. #define GLFW_MOUSE_BUTTON_7 6
  517. #define GLFW_MOUSE_BUTTON_8 7
  518. #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
  519. #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
  520. #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
  521. #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
  522. /*! @} */
  523. /*! @defgroup joysticks Joysticks
  524. * @brief Joystick IDs.
  525. *
  526. * See [joystick input](@ref joystick) for how these are used.
  527. *
  528. * @ingroup input
  529. * @{ */
  530. #define GLFW_JOYSTICK_1 0
  531. #define GLFW_JOYSTICK_2 1
  532. #define GLFW_JOYSTICK_3 2
  533. #define GLFW_JOYSTICK_4 3
  534. #define GLFW_JOYSTICK_5 4
  535. #define GLFW_JOYSTICK_6 5
  536. #define GLFW_JOYSTICK_7 6
  537. #define GLFW_JOYSTICK_8 7
  538. #define GLFW_JOYSTICK_9 8
  539. #define GLFW_JOYSTICK_10 9
  540. #define GLFW_JOYSTICK_11 10
  541. #define GLFW_JOYSTICK_12 11
  542. #define GLFW_JOYSTICK_13 12
  543. #define GLFW_JOYSTICK_14 13
  544. #define GLFW_JOYSTICK_15 14
  545. #define GLFW_JOYSTICK_16 15
  546. #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
  547. /*! @} */
  548. /*! @defgroup gamepad_buttons Gamepad buttons
  549. * @brief Gamepad buttons.
  550. *
  551. * See @ref gamepad for how these are used.
  552. *
  553. * @ingroup input
  554. * @{ */
  555. #define GLFW_GAMEPAD_BUTTON_A 0
  556. #define GLFW_GAMEPAD_BUTTON_B 1
  557. #define GLFW_GAMEPAD_BUTTON_X 2
  558. #define GLFW_GAMEPAD_BUTTON_Y 3
  559. #define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
  560. #define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
  561. #define GLFW_GAMEPAD_BUTTON_BACK 6
  562. #define GLFW_GAMEPAD_BUTTON_START 7
  563. #define GLFW_GAMEPAD_BUTTON_GUIDE 8
  564. #define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
  565. #define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
  566. #define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
  567. #define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
  568. #define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
  569. #define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
  570. #define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
  571. #define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
  572. #define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
  573. #define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
  574. #define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
  575. /*! @} */
  576. /*! @defgroup gamepad_axes Gamepad axes
  577. * @brief Gamepad axes.
  578. *
  579. * See @ref gamepad for how these are used.
  580. *
  581. * @ingroup input
  582. * @{ */
  583. #define GLFW_GAMEPAD_AXIS_LEFT_X 0
  584. #define GLFW_GAMEPAD_AXIS_LEFT_Y 1
  585. #define GLFW_GAMEPAD_AXIS_RIGHT_X 2
  586. #define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
  587. #define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
  588. #define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
  589. #define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
  590. /*! @} */
  591. /*! @defgroup errors Error codes
  592. * @brief Error codes.
  593. *
  594. * See [error handling](@ref error_handling) for how these are used.
  595. *
  596. * @ingroup init
  597. * @{ */
  598. /*! @brief No error has occurred.
  599. *
  600. * No error has occurred.
  601. *
  602. * @analysis Yay.
  603. */
  604. #define GLFW_NO_ERROR 0
  605. /*! @brief GLFW has not been initialized.
  606. *
  607. * This occurs if a GLFW function was called that must not be called unless the
  608. * library is [initialized](@ref intro_init).
  609. *
  610. * @analysis Application programmer error. Initialize GLFW before calling any
  611. * function that requires initialization.
  612. */
  613. #define GLFW_NOT_INITIALIZED 0x00010001
  614. /*! @brief No context is current for this thread.
  615. *
  616. * This occurs if a GLFW function was called that needs and operates on the
  617. * current OpenGL or OpenGL ES context but no context is current on the calling
  618. * thread. One such function is @ref glfwSwapInterval.
  619. *
  620. * @analysis Application programmer error. Ensure a context is current before
  621. * calling functions that require a current context.
  622. */
  623. #define GLFW_NO_CURRENT_CONTEXT 0x00010002
  624. /*! @brief One of the arguments to the function was an invalid enum value.
  625. *
  626. * One of the arguments to the function was an invalid enum value, for example
  627. * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
  628. *
  629. * @analysis Application programmer error. Fix the offending call.
  630. */
  631. #define GLFW_INVALID_ENUM 0x00010003
  632. /*! @brief One of the arguments to the function was an invalid value.
  633. *
  634. * One of the arguments to the function was an invalid value, for example
  635. * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
  636. *
  637. * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
  638. * result in a @ref GLFW_VERSION_UNAVAILABLE error.
  639. *
  640. * @analysis Application programmer error. Fix the offending call.
  641. */
  642. #define GLFW_INVALID_VALUE 0x00010004
  643. /*! @brief A memory allocation failed.
  644. *
  645. * A memory allocation failed.
  646. *
  647. * @analysis A bug in GLFW or the underlying operating system. Report the bug
  648. * to our [issue tracker](https://github.com/glfw/glfw/issues).
  649. */
  650. #define GLFW_OUT_OF_MEMORY 0x00010005
  651. /*! @brief GLFW could not find support for the requested API on the system.
  652. *
  653. * GLFW could not find support for the requested API on the system.
  654. *
  655. * @analysis The installed graphics driver does not support the requested
  656. * API, or does not support it via the chosen context creation backend.
  657. * Below are a few examples.
  658. *
  659. * @par
  660. * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
  661. * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
  662. * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
  663. * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
  664. * driver. Older graphics drivers do not support Vulkan.
  665. */
  666. #define GLFW_API_UNAVAILABLE 0x00010006
  667. /*! @brief The requested OpenGL or OpenGL ES version is not available.
  668. *
  669. * The requested OpenGL or OpenGL ES version (including any requested context
  670. * or framebuffer hints) is not available on this machine.
  671. *
  672. * @analysis The machine does not support your requirements. If your
  673. * application is sufficiently flexible, downgrade your requirements and try
  674. * again. Otherwise, inform the user that their machine does not match your
  675. * requirements.
  676. *
  677. * @par
  678. * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
  679. * comes out before the 4.x series gets that far, also fail with this error and
  680. * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
  681. * will exist.
  682. */
  683. #define GLFW_VERSION_UNAVAILABLE 0x00010007
  684. /*! @brief A platform-specific error occurred that does not match any of the
  685. * more specific categories.
  686. *
  687. * A platform-specific error occurred that does not match any of the more
  688. * specific categories.
  689. *
  690. * @analysis A bug or configuration error in GLFW, the underlying operating
  691. * system or its drivers, or a lack of required resources. Report the issue to
  692. * our [issue tracker](https://github.com/glfw/glfw/issues).
  693. */
  694. #define GLFW_PLATFORM_ERROR 0x00010008
  695. /*! @brief The requested format is not supported or available.
  696. *
  697. * If emitted during window creation, the requested pixel format is not
  698. * supported.
  699. *
  700. * If emitted when querying the clipboard, the contents of the clipboard could
  701. * not be converted to the requested format.
  702. *
  703. * @analysis If emitted during window creation, one or more
  704. * [hard constraints](@ref window_hints_hard) did not match any of the
  705. * available pixel formats. If your application is sufficiently flexible,
  706. * downgrade your requirements and try again. Otherwise, inform the user that
  707. * their machine does not match your requirements.
  708. *
  709. * @par
  710. * If emitted when querying the clipboard, ignore the error or report it to
  711. * the user, as appropriate.
  712. */
  713. #define GLFW_FORMAT_UNAVAILABLE 0x00010009
  714. /*! @brief The specified window does not have an OpenGL or OpenGL ES context.
  715. *
  716. * A window that does not have an OpenGL or OpenGL ES context was passed to
  717. * a function that requires it to have one.
  718. *
  719. * @analysis Application programmer error. Fix the offending call.
  720. */
  721. #define GLFW_NO_WINDOW_CONTEXT 0x0001000A
  722. /*! @} */
  723. /*! @addtogroup window
  724. * @{ */
  725. /*! @brief Input focus window hint and attribute
  726. *
  727. * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
  728. * [window attribute](@ref GLFW_FOCUSED_attrib).
  729. */
  730. #define GLFW_FOCUSED 0x00020001
  731. /*! @brief Window iconification window attribute
  732. *
  733. * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
  734. */
  735. #define GLFW_ICONIFIED 0x00020002
  736. /*! @brief Window resize-ability window hint and attribute
  737. *
  738. * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
  739. * [window attribute](@ref GLFW_RESIZABLE_attrib).
  740. */
  741. #define GLFW_RESIZABLE 0x00020003
  742. /*! @brief Window visibility window hint and attribute
  743. *
  744. * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
  745. * [window attribute](@ref GLFW_VISIBLE_attrib).
  746. */
  747. #define GLFW_VISIBLE 0x00020004
  748. /*! @brief Window decoration window hint and attribute
  749. *
  750. * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
  751. * [window attribute](@ref GLFW_DECORATED_attrib).
  752. */
  753. #define GLFW_DECORATED 0x00020005
  754. /*! @brief Window auto-iconification window hint and attribute
  755. *
  756. * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
  757. * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
  758. */
  759. #define GLFW_AUTO_ICONIFY 0x00020006
  760. /*! @brief Window decoration window hint and attribute
  761. *
  762. * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
  763. * [window attribute](@ref GLFW_FLOATING_attrib).
  764. */
  765. #define GLFW_FLOATING 0x00020007
  766. /*! @brief Window maximization window hint and attribute
  767. *
  768. * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
  769. * [window attribute](@ref GLFW_MAXIMIZED_attrib).
  770. */
  771. #define GLFW_MAXIMIZED 0x00020008
  772. /*! @brief Cursor centering window hint
  773. *
  774. * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
  775. */
  776. #define GLFW_CENTER_CURSOR 0x00020009
  777. /*! @brief Window framebuffer transparency hint and attribute
  778. *
  779. * Window framebuffer transparency
  780. * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
  781. * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
  782. */
  783. #define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
  784. /*! @brief Mouse cursor hover window attribute.
  785. *
  786. * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
  787. */
  788. #define GLFW_HOVERED 0x0002000B
  789. /*! @brief Input focus on calling show window hint and attribute
  790. *
  791. * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
  792. * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
  793. */
  794. #define GLFW_FOCUS_ON_SHOW 0x0002000C
  795. /*! @brief Framebuffer bit depth hint.
  796. *
  797. * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
  798. */
  799. #define GLFW_RED_BITS 0x00021001
  800. /*! @brief Framebuffer bit depth hint.
  801. *
  802. * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
  803. */
  804. #define GLFW_GREEN_BITS 0x00021002
  805. /*! @brief Framebuffer bit depth hint.
  806. *
  807. * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
  808. */
  809. #define GLFW_BLUE_BITS 0x00021003
  810. /*! @brief Framebuffer bit depth hint.
  811. *
  812. * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
  813. */
  814. #define GLFW_ALPHA_BITS 0x00021004
  815. /*! @brief Framebuffer bit depth hint.
  816. *
  817. * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
  818. */
  819. #define GLFW_DEPTH_BITS 0x00021005
  820. /*! @brief Framebuffer bit depth hint.
  821. *
  822. * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
  823. */
  824. #define GLFW_STENCIL_BITS 0x00021006
  825. /*! @brief Framebuffer bit depth hint.
  826. *
  827. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
  828. */
  829. #define GLFW_ACCUM_RED_BITS 0x00021007
  830. /*! @brief Framebuffer bit depth hint.
  831. *
  832. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
  833. */
  834. #define GLFW_ACCUM_GREEN_BITS 0x00021008
  835. /*! @brief Framebuffer bit depth hint.
  836. *
  837. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
  838. */
  839. #define GLFW_ACCUM_BLUE_BITS 0x00021009
  840. /*! @brief Framebuffer bit depth hint.
  841. *
  842. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
  843. */
  844. #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
  845. /*! @brief Framebuffer auxiliary buffer hint.
  846. *
  847. * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
  848. */
  849. #define GLFW_AUX_BUFFERS 0x0002100B
  850. /*! @brief OpenGL stereoscopic rendering hint.
  851. *
  852. * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
  853. */
  854. #define GLFW_STEREO 0x0002100C
  855. /*! @brief Framebuffer MSAA samples hint.
  856. *
  857. * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
  858. */
  859. #define GLFW_SAMPLES 0x0002100D
  860. /*! @brief Framebuffer sRGB hint.
  861. *
  862. * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
  863. */
  864. #define GLFW_SRGB_CAPABLE 0x0002100E
  865. /*! @brief Monitor refresh rate hint.
  866. *
  867. * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
  868. */
  869. #define GLFW_REFRESH_RATE 0x0002100F
  870. /*! @brief Framebuffer double buffering hint.
  871. *
  872. * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
  873. */
  874. #define GLFW_DOUBLEBUFFER 0x00021010
  875. /*! @brief Context client API hint and attribute.
  876. *
  877. * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
  878. * [attribute](@ref GLFW_CLIENT_API_attrib).
  879. */
  880. #define GLFW_CLIENT_API 0x00022001
  881. /*! @brief Context client API major version hint and attribute.
  882. *
  883. * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint)
  884. * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib).
  885. */
  886. #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
  887. /*! @brief Context client API minor version hint and attribute.
  888. *
  889. * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint)
  890. * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
  891. */
  892. #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
  893. /*! @brief Context client API revision number attribute.
  894. *
  895. * Context client API revision number
  896. * [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
  897. */
  898. #define GLFW_CONTEXT_REVISION 0x00022004
  899. /*! @brief Context robustness hint and attribute.
  900. *
  901. * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint)
  902. * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib).
  903. */
  904. #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
  905. /*! @brief OpenGL forward-compatibility hint and attribute.
  906. *
  907. * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
  908. * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
  909. */
  910. #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
  911. /*! @brief Debug mode context hint and attribute.
  912. *
  913. * Debug mode context [hint](@ref GLFW_OPENGL_DEBUG_CONTEXT_hint) and
  914. * [attribute](@ref GLFW_OPENGL_DEBUG_CONTEXT_attrib).
  915. */
  916. #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
  917. /*! @brief OpenGL profile hint and attribute.
  918. *
  919. * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
  920. * [attribute](@ref GLFW_OPENGL_PROFILE_attrib).
  921. */
  922. #define GLFW_OPENGL_PROFILE 0x00022008
  923. /*! @brief Context flush-on-release hint and attribute.
  924. *
  925. * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and
  926. * [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib).
  927. */
  928. #define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
  929. /*! @brief Context error suppression hint and attribute.
  930. *
  931. * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and
  932. * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib).
  933. */
  934. #define GLFW_CONTEXT_NO_ERROR 0x0002200A
  935. /*! @brief Context creation API hint and attribute.
  936. *
  937. * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and
  938. * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
  939. */
  940. #define GLFW_CONTEXT_CREATION_API 0x0002200B
  941. /*! @brief Window content area scaling window
  942. * [window hint](@ref GLFW_SCALE_TO_MONITOR).
  943. */
  944. #define GLFW_SCALE_TO_MONITOR 0x0002200C
  945. /*! @brief macOS specific
  946. * [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint).
  947. */
  948. #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
  949. /*! @brief macOS specific
  950. * [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
  951. */
  952. #define GLFW_COCOA_FRAME_NAME 0x00023002
  953. /*! @brief macOS specific
  954. * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint).
  955. */
  956. #define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
  957. /*! @brief X11 specific
  958. * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
  959. */
  960. #define GLFW_X11_CLASS_NAME 0x00024001
  961. /*! @brief X11 specific
  962. * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
  963. */
  964. #define GLFW_X11_INSTANCE_NAME 0x00024002
  965. /*! @} */
  966. #define GLFW_NO_API 0
  967. #define GLFW_OPENGL_API 0x00030001
  968. #define GLFW_OPENGL_ES_API 0x00030002
  969. #define GLFW_NO_ROBUSTNESS 0
  970. #define GLFW_NO_RESET_NOTIFICATION 0x00031001
  971. #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
  972. #define GLFW_OPENGL_ANY_PROFILE 0
  973. #define GLFW_OPENGL_CORE_PROFILE 0x00032001
  974. #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
  975. #define GLFW_CURSOR 0x00033001
  976. #define GLFW_STICKY_KEYS 0x00033002
  977. #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
  978. #define GLFW_LOCK_KEY_MODS 0x00033004
  979. #define GLFW_RAW_MOUSE_MOTION 0x00033005
  980. #define GLFW_CURSOR_NORMAL 0x00034001
  981. #define GLFW_CURSOR_HIDDEN 0x00034002
  982. #define GLFW_CURSOR_DISABLED 0x00034003
  983. #define GLFW_ANY_RELEASE_BEHAVIOR 0
  984. #define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
  985. #define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
  986. #define GLFW_NATIVE_CONTEXT_API 0x00036001
  987. #define GLFW_EGL_CONTEXT_API 0x00036002
  988. #define GLFW_OSMESA_CONTEXT_API 0x00036003
  989. /*! @defgroup shapes Standard cursor shapes
  990. * @brief Standard system cursor shapes.
  991. *
  992. * See [standard cursor creation](@ref cursor_standard) for how these are used.
  993. *
  994. * @ingroup input
  995. * @{ */
  996. /*! @brief The regular arrow cursor shape.
  997. *
  998. * The regular arrow cursor.
  999. */
  1000. #define GLFW_ARROW_CURSOR 0x00036001
  1001. /*! @brief The text input I-beam cursor shape.
  1002. *
  1003. * The text input I-beam cursor shape.
  1004. */
  1005. #define GLFW_IBEAM_CURSOR 0x00036002
  1006. /*! @brief The crosshair shape.
  1007. *
  1008. * The crosshair shape.
  1009. */
  1010. #define GLFW_CROSSHAIR_CURSOR 0x00036003
  1011. /*! @brief The hand shape.
  1012. *
  1013. * The hand shape.
  1014. */
  1015. #define GLFW_HAND_CURSOR 0x00036004
  1016. /*! @brief The horizontal resize arrow shape.
  1017. *
  1018. * The horizontal resize arrow shape.
  1019. */
  1020. #define GLFW_HRESIZE_CURSOR 0x00036005
  1021. /*! @brief The vertical resize arrow shape.
  1022. *
  1023. * The vertical resize arrow shape.
  1024. */
  1025. #define GLFW_VRESIZE_CURSOR 0x00036006
  1026. /*! @} */
  1027. #define GLFW_CONNECTED 0x00040001
  1028. #define GLFW_DISCONNECTED 0x00040002
  1029. /*! @addtogroup init
  1030. * @{ */
  1031. /*! @brief Joystick hat buttons init hint.
  1032. *
  1033. * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
  1034. */
  1035. #define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
  1036. /*! @brief macOS specific init hint.
  1037. *
  1038. * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
  1039. */
  1040. #define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
  1041. /*! @brief macOS specific init hint.
  1042. *
  1043. * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
  1044. */
  1045. #define GLFW_COCOA_MENUBAR 0x00051002
  1046. /*! @} */
  1047. #define GLFW_DONT_CARE -1
  1048. /*************************************************************************
  1049. * GLFW API types
  1050. *************************************************************************/
  1051. /*! @brief Client API function pointer type.
  1052. *
  1053. * Generic function pointer used for returning client API function pointers
  1054. * without forcing a cast from a regular pointer.
  1055. *
  1056. * @sa @ref context_glext
  1057. * @sa @ref glfwGetProcAddress
  1058. *
  1059. * @since Added in version 3.0.
  1060. *
  1061. * @ingroup context
  1062. */
  1063. typedef void (*GLFWglproc)(void);
  1064. /*! @brief Vulkan API function pointer type.
  1065. *
  1066. * Generic function pointer used for returning Vulkan API function pointers
  1067. * without forcing a cast from a regular pointer.
  1068. *
  1069. * @sa @ref vulkan_proc
  1070. * @sa @ref glfwGetInstanceProcAddress
  1071. *
  1072. * @since Added in version 3.2.
  1073. *
  1074. * @ingroup vulkan
  1075. */
  1076. typedef void (*GLFWvkproc)(void);
  1077. /*! @brief Opaque monitor object.
  1078. *
  1079. * Opaque monitor object.
  1080. *
  1081. * @see @ref monitor_object
  1082. *
  1083. * @since Added in version 3.0.
  1084. *
  1085. * @ingroup monitor
  1086. */
  1087. typedef struct GLFWmonitor GLFWmonitor;
  1088. /*! @brief Opaque window object.
  1089. *
  1090. * Opaque window object.
  1091. *
  1092. * @see @ref window_object
  1093. *
  1094. * @since Added in version 3.0.
  1095. *
  1096. * @ingroup window
  1097. */
  1098. typedef struct GLFWwindow GLFWwindow;
  1099. /*! @brief Opaque cursor object.
  1100. *
  1101. * Opaque cursor object.
  1102. *
  1103. * @see @ref cursor_object
  1104. *
  1105. * @since Added in version 3.1.
  1106. *
  1107. * @ingroup input
  1108. */
  1109. typedef struct GLFWcursor GLFWcursor;
  1110. /*! @brief The function pointer type for error callbacks.
  1111. *
  1112. * This is the function pointer type for error callbacks. An error callback
  1113. * function has the following signature:
  1114. * @code
  1115. * void callback_name(int error_code, const char* description)
  1116. * @endcode
  1117. *
  1118. * @param[in] error_code An [error code](@ref errors). Future releases may add
  1119. * more error codes.
  1120. * @param[in] description A UTF-8 encoded string describing the error.
  1121. *
  1122. * @pointer_lifetime The error description string is valid until the callback
  1123. * function returns.
  1124. *
  1125. * @sa @ref error_handling
  1126. * @sa @ref glfwSetErrorCallback
  1127. *
  1128. * @since Added in version 3.0.
  1129. *
  1130. * @ingroup init
  1131. */
  1132. typedef void (* GLFWerrorfun)(int error_code, const char* description);
  1133. /*! @brief The function pointer type for window position callbacks.
  1134. *
  1135. * This is the function pointer type for window position callbacks. A window
  1136. * position callback function has the following signature:
  1137. * @code
  1138. * void callback_name(GLFWwindow* window, int xpos, int ypos)
  1139. * @endcode
  1140. *
  1141. * @param[in] window The window that was moved.
  1142. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  1143. * upper-left corner of the content area of the window.
  1144. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  1145. * upper-left corner of the content area of the window.
  1146. *
  1147. * @sa @ref window_pos
  1148. * @sa @ref glfwSetWindowPosCallback
  1149. *
  1150. * @since Added in version 3.0.
  1151. *
  1152. * @ingroup window
  1153. */
  1154. typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
  1155. /*! @brief The function pointer type for window size callbacks.
  1156. *
  1157. * This is the function pointer type for window size callbacks. A window size
  1158. * callback function has the following signature:
  1159. * @code
  1160. * void callback_name(GLFWwindow* window, int width, int height)
  1161. * @endcode
  1162. *
  1163. * @param[in] window The window that was resized.
  1164. * @param[in] width The new width, in screen coordinates, of the window.
  1165. * @param[in] height The new height, in screen coordinates, of the window.
  1166. *
  1167. * @sa @ref window_size
  1168. * @sa @ref glfwSetWindowSizeCallback
  1169. *
  1170. * @since Added in version 1.0.
  1171. * @glfw3 Added window handle parameter.
  1172. *
  1173. * @ingroup window
  1174. */
  1175. typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
  1176. /*! @brief The function pointer type for window close callbacks.
  1177. *
  1178. * This is the function pointer type for window close callbacks. A window
  1179. * close callback function has the following signature:
  1180. * @code
  1181. * void function_name(GLFWwindow* window)
  1182. * @endcode
  1183. *
  1184. * @param[in] window The window that the user attempted to close.
  1185. *
  1186. * @sa @ref window_close
  1187. * @sa @ref glfwSetWindowCloseCallback
  1188. *
  1189. * @since Added in version 2.5.
  1190. * @glfw3 Added window handle parameter.
  1191. *
  1192. * @ingroup window
  1193. */
  1194. typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
  1195. /*! @brief The function pointer type for window content refresh callbacks.
  1196. *
  1197. * This is the function pointer type for window content refresh callbacks.
  1198. * A window content refresh callback function has the following signature:
  1199. * @code
  1200. * void function_name(GLFWwindow* window);
  1201. * @endcode
  1202. *
  1203. * @param[in] window The window whose content needs to be refreshed.
  1204. *
  1205. * @sa @ref window_refresh
  1206. * @sa @ref glfwSetWindowRefreshCallback
  1207. *
  1208. * @since Added in version 2.5.
  1209. * @glfw3 Added window handle parameter.
  1210. *
  1211. * @ingroup window
  1212. */
  1213. typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window);
  1214. /*! @brief The function pointer type for window focus callbacks.
  1215. *
  1216. * This is the function pointer type for window focus callbacks. A window
  1217. * focus callback function has the following signature:
  1218. * @code
  1219. * void function_name(GLFWwindow* window, int focused)
  1220. * @endcode
  1221. *
  1222. * @param[in] window The window that gained or lost input focus.
  1223. * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
  1224. * `GLFW_FALSE` if it lost it.
  1225. *
  1226. * @sa @ref window_focus
  1227. * @sa @ref glfwSetWindowFocusCallback
  1228. *
  1229. * @since Added in version 3.0.
  1230. *
  1231. * @ingroup window
  1232. */
  1233. typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused);
  1234. /*! @brief The function pointer type for window iconify callbacks.
  1235. *
  1236. * This is the function pointer type for window iconify callbacks. A window
  1237. * iconify callback function has the following signature:
  1238. * @code
  1239. * void function_name(GLFWwindow* window, int iconified)
  1240. * @endcode
  1241. *
  1242. * @param[in] window The window that was iconified or restored.
  1243. * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
  1244. * `GLFW_FALSE` if it was restored.
  1245. *
  1246. * @sa @ref window_iconify
  1247. * @sa @ref glfwSetWindowIconifyCallback
  1248. *
  1249. * @since Added in version 3.0.
  1250. *
  1251. * @ingroup window
  1252. */
  1253. typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified);
  1254. /*! @brief The function pointer type for window maximize callbacks.
  1255. *
  1256. * This is the function pointer type for window maximize callbacks. A window
  1257. * maximize callback function has the following signature:
  1258. * @code
  1259. * void function_name(GLFWwindow* window, int maximized)
  1260. * @endcode
  1261. *
  1262. * @param[in] window The window that was maximized or restored.
  1263. * @param[in] maximized `GLFW_TRUE` if the window was maximized, or
  1264. * `GLFW_FALSE` if it was restored.
  1265. *
  1266. * @sa @ref window_maximize
  1267. * @sa glfwSetWindowMaximizeCallback
  1268. *
  1269. * @since Added in version 3.3.
  1270. *
  1271. * @ingroup window
  1272. */
  1273. typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized);
  1274. /*! @brief The function pointer type for framebuffer size callbacks.
  1275. *
  1276. * This is the function pointer type for framebuffer size callbacks.
  1277. * A framebuffer size callback function has the following signature:
  1278. * @code
  1279. * void function_name(GLFWwindow* window, int width, int height)
  1280. * @endcode
  1281. *
  1282. * @param[in] window The window whose framebuffer was resized.
  1283. * @param[in] width The new width, in pixels, of the framebuffer.
  1284. * @param[in] height The new height, in pixels, of the framebuffer.
  1285. *
  1286. * @sa @ref window_fbsize
  1287. * @sa @ref glfwSetFramebufferSizeCallback
  1288. *
  1289. * @since Added in version 3.0.
  1290. *
  1291. * @ingroup window
  1292. */
  1293. typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height);
  1294. /*! @brief The function pointer type for window content scale callbacks.
  1295. *
  1296. * This is the function pointer type for window content scale callbacks.
  1297. * A window content scale callback function has the following signature:
  1298. * @code
  1299. * void function_name(GLFWwindow* window, float xscale, float yscale)
  1300. * @endcode
  1301. *
  1302. * @param[in] window The window whose content scale changed.
  1303. * @param[in] xscale The new x-axis content scale of the window.
  1304. * @param[in] yscale The new y-axis content scale of the window.
  1305. *
  1306. * @sa @ref window_scale
  1307. * @sa @ref glfwSetWindowContentScaleCallback
  1308. *
  1309. * @since Added in version 3.3.
  1310. *
  1311. * @ingroup window
  1312. */
  1313. typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale);
  1314. /*! @brief The function pointer type for mouse button callbacks.
  1315. *
  1316. * This is the function pointer type for mouse button callback functions.
  1317. * A mouse button callback function has the following signature:
  1318. * @code
  1319. * void function_name(GLFWwindow* window, int button, int action, int mods)
  1320. * @endcode
  1321. *
  1322. * @param[in] window The window that received the event.
  1323. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  1324. * released.
  1325. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases
  1326. * may add more actions.
  1327. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  1328. * held down.
  1329. *
  1330. * @sa @ref input_mouse_button
  1331. * @sa @ref glfwSetMouseButtonCallback
  1332. *
  1333. * @since Added in version 1.0.
  1334. * @glfw3 Added window handle and modifier mask parameters.
  1335. *
  1336. * @ingroup input
  1337. */
  1338. typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
  1339. /*! @brief The function pointer type for cursor position callbacks.
  1340. *
  1341. * This is the function pointer type for cursor position callbacks. A cursor
  1342. * position callback function has the following signature:
  1343. * @code
  1344. * void function_name(GLFWwindow* window, double xpos, double ypos);
  1345. * @endcode
  1346. *
  1347. * @param[in] window The window that received the event.
  1348. * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
  1349. * the content area.
  1350. * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
  1351. * content area.
  1352. *
  1353. * @sa @ref cursor_pos
  1354. * @sa @ref glfwSetCursorPosCallback
  1355. *
  1356. * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
  1357. *
  1358. * @ingroup input
  1359. */
  1360. typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos);
  1361. /*! @brief The function pointer type for cursor enter/leave callbacks.
  1362. *
  1363. * This is the function pointer type for cursor enter/leave callbacks.
  1364. * A cursor enter/leave callback function has the following signature:
  1365. * @code
  1366. * void function_name(GLFWwindow* window, int entered)
  1367. * @endcode
  1368. *
  1369. * @param[in] window The window that received the event.
  1370. * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
  1371. * area, or `GLFW_FALSE` if it left it.
  1372. *
  1373. * @sa @ref cursor_enter
  1374. * @sa @ref glfwSetCursorEnterCallback
  1375. *
  1376. * @since Added in version 3.0.
  1377. *
  1378. * @ingroup input
  1379. */
  1380. typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered);
  1381. /*! @brief The function pointer type for scroll callbacks.
  1382. *
  1383. * This is the function pointer type for scroll callbacks. A scroll callback
  1384. * function has the following signature:
  1385. * @code
  1386. * void function_name(GLFWwindow* window, double xoffset, double yoffset)
  1387. * @endcode
  1388. *
  1389. * @param[in] window The window that received the event.
  1390. * @param[in] xoffset The scroll offset along the x-axis.
  1391. * @param[in] yoffset The scroll offset along the y-axis.
  1392. *
  1393. * @sa @ref scrolling
  1394. * @sa @ref glfwSetScrollCallback
  1395. *
  1396. * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
  1397. *
  1398. * @ingroup input
  1399. */
  1400. typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset);
  1401. /*! @brief The function pointer type for keyboard key callbacks.
  1402. *
  1403. * This is the function pointer type for keyboard key callbacks. A keyboard
  1404. * key callback function has the following signature:
  1405. * @code
  1406. * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
  1407. * @endcode
  1408. *
  1409. * @param[in] window The window that received the event.
  1410. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
  1411. * @param[in] scancode The system-specific scancode of the key.
  1412. * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
  1413. * releases may add more actions.
  1414. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  1415. * held down.
  1416. *
  1417. * @sa @ref input_key
  1418. * @sa @ref glfwSetKeyCallback
  1419. *
  1420. * @since Added in version 1.0.
  1421. * @glfw3 Added window handle, scancode and modifier mask parameters.
  1422. *
  1423. * @ingroup input
  1424. */
  1425. typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods);
  1426. /*! @brief The function pointer type for Unicode character callbacks.
  1427. *
  1428. * This is the function pointer type for Unicode character callbacks.
  1429. * A Unicode character callback function has the following signature:
  1430. * @code
  1431. * void function_name(GLFWwindow* window, unsigned int codepoint)
  1432. * @endcode
  1433. *
  1434. * @param[in] window The window that received the event.
  1435. * @param[in] codepoint The Unicode code point of the character.
  1436. *
  1437. * @sa @ref input_char
  1438. * @sa @ref glfwSetCharCallback
  1439. *
  1440. * @since Added in version 2.4.
  1441. * @glfw3 Added window handle parameter.
  1442. *
  1443. * @ingroup input
  1444. */
  1445. typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
  1446. /*! @brief The function pointer type for Unicode character with modifiers
  1447. * callbacks.
  1448. *
  1449. * This is the function pointer type for Unicode character with modifiers
  1450. * callbacks. It is called for each input character, regardless of what
  1451. * modifier keys are held down. A Unicode character with modifiers callback
  1452. * function has the following signature:
  1453. * @code
  1454. * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
  1455. * @endcode
  1456. *
  1457. * @param[in] window The window that received the event.
  1458. * @param[in] codepoint The Unicode code point of the character.
  1459. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  1460. * held down.
  1461. *
  1462. * @sa @ref input_char
  1463. * @sa @ref glfwSetCharModsCallback
  1464. *
  1465. * @deprecated Scheduled for removal in version 4.0.
  1466. *
  1467. * @since Added in version 3.1.
  1468. *
  1469. * @ingroup input
  1470. */
  1471. typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
  1472. /*! @brief The function pointer type for path drop callbacks.
  1473. *
  1474. * This is the function pointer type for path drop callbacks. A path drop
  1475. * callback function has the following signature:
  1476. * @code
  1477. * void function_name(GLFWwindow* window, int path_count, const char* paths[])
  1478. * @endcode
  1479. *
  1480. * @param[in] window The window that received the event.
  1481. * @param[in] path_count The number of dropped paths.
  1482. * @param[in] paths The UTF-8 encoded file and/or directory path names.
  1483. *
  1484. * @pointer_lifetime The path array and its strings are valid until the
  1485. * callback function returns.
  1486. *
  1487. * @sa @ref path_drop
  1488. * @sa @ref glfwSetDropCallback
  1489. *
  1490. * @since Added in version 3.1.
  1491. *
  1492. * @ingroup input
  1493. */
  1494. typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
  1495. /*! @brief The function pointer type for monitor configuration callbacks.
  1496. *
  1497. * This is the function pointer type for monitor configuration callbacks.
  1498. * A monitor callback function has the following signature:
  1499. * @code
  1500. * void function_name(GLFWmonitor* monitor, int event)
  1501. * @endcode
  1502. *
  1503. * @param[in] monitor The monitor that was connected or disconnected.
  1504. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
  1505. * releases may add more events.
  1506. *
  1507. * @sa @ref monitor_event
  1508. * @sa @ref glfwSetMonitorCallback
  1509. *
  1510. * @since Added in version 3.0.
  1511. *
  1512. * @ingroup monitor
  1513. */
  1514. typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event);
  1515. /*! @brief The function pointer type for joystick configuration callbacks.
  1516. *
  1517. * This is the function pointer type for joystick configuration callbacks.
  1518. * A joystick configuration callback function has the following signature:
  1519. * @code
  1520. * void function_name(int jid, int event)
  1521. * @endcode
  1522. *
  1523. * @param[in] jid The joystick that was connected or disconnected.
  1524. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
  1525. * releases may add more events.
  1526. *
  1527. * @sa @ref joystick_event
  1528. * @sa @ref glfwSetJoystickCallback
  1529. *
  1530. * @since Added in version 3.2.
  1531. *
  1532. * @ingroup input
  1533. */
  1534. typedef void (* GLFWjoystickfun)(int jid, int event);
  1535. /*! @brief Video mode type.
  1536. *
  1537. * This describes a single video mode.
  1538. *
  1539. * @sa @ref monitor_modes
  1540. * @sa @ref glfwGetVideoMode
  1541. * @sa @ref glfwGetVideoModes
  1542. *
  1543. * @since Added in version 1.0.
  1544. * @glfw3 Added refresh rate member.
  1545. *
  1546. * @ingroup monitor
  1547. */
  1548. typedef struct GLFWvidmode
  1549. {
  1550. /*! The width, in screen coordinates, of the video mode.
  1551. */
  1552. int width;
  1553. /*! The height, in screen coordinates, of the video mode.
  1554. */
  1555. int height;
  1556. /*! The bit depth of the red channel of the video mode.
  1557. */
  1558. int redBits;
  1559. /*! The bit depth of the green channel of the video mode.
  1560. */
  1561. int greenBits;
  1562. /*! The bit depth of the blue channel of the video mode.
  1563. */
  1564. int blueBits;
  1565. /*! The refresh rate, in Hz, of the video mode.
  1566. */
  1567. int refreshRate;
  1568. } GLFWvidmode;
  1569. /*! @brief Gamma ramp.
  1570. *
  1571. * This describes the gamma ramp for a monitor.
  1572. *
  1573. * @sa @ref monitor_gamma
  1574. * @sa @ref glfwGetGammaRamp
  1575. * @sa @ref glfwSetGammaRamp
  1576. *
  1577. * @since Added in version 3.0.
  1578. *
  1579. * @ingroup monitor
  1580. */
  1581. typedef struct GLFWgammaramp
  1582. {
  1583. /*! An array of value describing the response of the red channel.
  1584. */
  1585. unsigned short* red;
  1586. /*! An array of value describing the response of the green channel.
  1587. */
  1588. unsigned short* green;
  1589. /*! An array of value describing the response of the blue channel.
  1590. */
  1591. unsigned short* blue;
  1592. /*! The number of elements in each array.
  1593. */
  1594. unsigned int size;
  1595. } GLFWgammaramp;
  1596. /*! @brief Image data.
  1597. *
  1598. * This describes a single 2D image. See the documentation for each related
  1599. * function what the expected pixel format is.
  1600. *
  1601. * @sa @ref cursor_custom
  1602. * @sa @ref window_icon
  1603. *
  1604. * @since Added in version 2.1.
  1605. * @glfw3 Removed format and bytes-per-pixel members.
  1606. *
  1607. * @ingroup window
  1608. */
  1609. typedef struct GLFWimage
  1610. {
  1611. /*! The width, in pixels, of this image.
  1612. */
  1613. int width;
  1614. /*! The height, in pixels, of this image.
  1615. */
  1616. int height;
  1617. /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
  1618. */
  1619. unsigned char* pixels;
  1620. } GLFWimage;
  1621. /*! @brief Gamepad input state
  1622. *
  1623. * This describes the input state of a gamepad.
  1624. *
  1625. * @sa @ref gamepad
  1626. * @sa @ref glfwGetGamepadState
  1627. *
  1628. * @since Added in version 3.3.
  1629. *
  1630. * @ingroup input
  1631. */
  1632. typedef struct GLFWgamepadstate
  1633. {
  1634. /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
  1635. * or `GLFW_RELEASE`.
  1636. */
  1637. unsigned char buttons[15];
  1638. /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
  1639. * to 1.0 inclusive.
  1640. */
  1641. float axes[6];
  1642. } GLFWgamepadstate;
  1643. /*************************************************************************
  1644. * GLFW API functions
  1645. *************************************************************************/
  1646. /*! @brief Initializes the GLFW library.
  1647. *
  1648. * This function initializes the GLFW library. Before most GLFW functions can
  1649. * be used, GLFW must be initialized, and before an application terminates GLFW
  1650. * should be terminated in order to free any resources allocated during or
  1651. * after initialization.
  1652. *
  1653. * If this function fails, it calls @ref glfwTerminate before returning. If it
  1654. * succeeds, you should call @ref glfwTerminate before the application exits.
  1655. *
  1656. * Additional calls to this function after successful initialization but before
  1657. * termination will return `GLFW_TRUE` immediately.
  1658. *
  1659. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  1660. * [error](@ref error_handling) occurred.
  1661. *
  1662. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1663. *
  1664. * @remark @macos This function will change the current directory of the
  1665. * application to the `Contents/Resources` subdirectory of the application's
  1666. * bundle, if present. This can be disabled with the @ref
  1667. * GLFW_COCOA_CHDIR_RESOURCES init hint.
  1668. *
  1669. * @remark @x11 This function will set the `LC_CTYPE` category of the
  1670. * application locale according to the current environment if that category is
  1671. * still "C". This is because the "C" locale breaks Unicode text input.
  1672. *
  1673. * @thread_safety This function must only be called from the main thread.
  1674. *
  1675. * @sa @ref intro_init
  1676. * @sa @ref glfwTerminate
  1677. *
  1678. * @since Added in version 1.0.
  1679. *
  1680. * @ingroup init
  1681. */
  1682. GLFWAPI int glfwInit(void);
  1683. /*! @brief Terminates the GLFW library.
  1684. *
  1685. * This function destroys all remaining windows and cursors, restores any
  1686. * modified gamma ramps and frees any other allocated resources. Once this
  1687. * function is called, you must again call @ref glfwInit successfully before
  1688. * you will be able to use most GLFW functions.
  1689. *
  1690. * If GLFW has been successfully initialized, this function should be called
  1691. * before the application exits. If initialization fails, there is no need to
  1692. * call this function, as it is called by @ref glfwInit before it returns
  1693. * failure.
  1694. *
  1695. * This function has no effect if GLFW is not initialized.
  1696. *
  1697. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1698. *
  1699. * @remark This function may be called before @ref glfwInit.
  1700. *
  1701. * @warning The contexts of any remaining windows must not be current on any
  1702. * other thread when this function is called.
  1703. *
  1704. * @reentrancy This function must not be called from a callback.
  1705. *
  1706. * @thread_safety This function must only be called from the main thread.
  1707. *
  1708. * @sa @ref intro_init
  1709. * @sa @ref glfwInit
  1710. *
  1711. * @since Added in version 1.0.
  1712. *
  1713. * @ingroup init
  1714. */
  1715. GLFWAPI void glfwTerminate(void);
  1716. /*! @brief Sets the specified init hint to the desired value.
  1717. *
  1718. * This function sets hints for the next initialization of GLFW.
  1719. *
  1720. * The values you set hints to are never reset by GLFW, but they only take
  1721. * effect during initialization. Once GLFW has been initialized, any values
  1722. * you set will be ignored until the library is terminated and initialized
  1723. * again.
  1724. *
  1725. * Some hints are platform specific. These may be set on any platform but they
  1726. * will only affect their specific platform. Other platforms will ignore them.
  1727. * Setting these hints requires no platform specific headers or functions.
  1728. *
  1729. * @param[in] hint The [init hint](@ref init_hints) to set.
  1730. * @param[in] value The new value of the init hint.
  1731. *
  1732. * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
  1733. * GLFW_INVALID_VALUE.
  1734. *
  1735. * @remarks This function may be called before @ref glfwInit.
  1736. *
  1737. * @thread_safety This function must only be called from the main thread.
  1738. *
  1739. * @sa init_hints
  1740. * @sa glfwInit
  1741. *
  1742. * @since Added in version 3.3.
  1743. *
  1744. * @ingroup init
  1745. */
  1746. GLFWAPI void glfwInitHint(int hint, int value);
  1747. /*! @brief Retrieves the version of the GLFW library.
  1748. *
  1749. * This function retrieves the major, minor and revision numbers of the GLFW
  1750. * library. It is intended for when you are using GLFW as a shared library and
  1751. * want to ensure that you are using the minimum required version.
  1752. *
  1753. * Any or all of the version arguments may be `NULL`.
  1754. *
  1755. * @param[out] major Where to store the major version number, or `NULL`.
  1756. * @param[out] minor Where to store the minor version number, or `NULL`.
  1757. * @param[out] rev Where to store the revision number, or `NULL`.
  1758. *
  1759. * @errors None.
  1760. *
  1761. * @remark This function may be called before @ref glfwInit.
  1762. *
  1763. * @thread_safety This function may be called from any thread.
  1764. *
  1765. * @sa @ref intro_version
  1766. * @sa @ref glfwGetVersionString
  1767. *
  1768. * @since Added in version 1.0.
  1769. *
  1770. * @ingroup init
  1771. */
  1772. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  1773. /*! @brief Returns a string describing the compile-time configuration.
  1774. *
  1775. * This function returns the compile-time generated
  1776. * [version string](@ref intro_version_string) of the GLFW library binary. It
  1777. * describes the version, platform, compiler and any platform-specific
  1778. * compile-time options. It should not be confused with the OpenGL or OpenGL
  1779. * ES version string, queried with `glGetString`.
  1780. *
  1781. * __Do not use the version string__ to parse the GLFW library version. The
  1782. * @ref glfwGetVersion function provides the version of the running library
  1783. * binary in numerical format.
  1784. *
  1785. * @return The ASCII encoded GLFW version string.
  1786. *
  1787. * @errors None.
  1788. *
  1789. * @remark This function may be called before @ref glfwInit.
  1790. *
  1791. * @pointer_lifetime The returned string is static and compile-time generated.
  1792. *
  1793. * @thread_safety This function may be called from any thread.
  1794. *
  1795. * @sa @ref intro_version
  1796. * @sa @ref glfwGetVersion
  1797. *
  1798. * @since Added in version 3.0.
  1799. *
  1800. * @ingroup init
  1801. */
  1802. GLFWAPI const char* glfwGetVersionString(void);
  1803. /*! @brief Returns and clears the last error for the calling thread.
  1804. *
  1805. * This function returns and clears the [error code](@ref errors) of the last
  1806. * error that occurred on the calling thread, and optionally a UTF-8 encoded
  1807. * human-readable description of it. If no error has occurred since the last
  1808. * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
  1809. * set to `NULL`.
  1810. *
  1811. * @param[in] description Where to store the error description pointer, or `NULL`.
  1812. * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
  1813. * (zero).
  1814. *
  1815. * @errors None.
  1816. *
  1817. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  1818. * should not free it yourself. It is guaranteed to be valid only until the
  1819. * next error occurs or the library is terminated.
  1820. *
  1821. * @remark This function may be called before @ref glfwInit.
  1822. *
  1823. * @thread_safety This function may be called from any thread.
  1824. *
  1825. * @sa @ref error_handling
  1826. * @sa @ref glfwSetErrorCallback
  1827. *
  1828. * @since Added in version 3.3.
  1829. *
  1830. * @ingroup init
  1831. */
  1832. GLFWAPI int glfwGetError(const char** description);
  1833. /*! @brief Sets the error callback.
  1834. *
  1835. * This function sets the error callback, which is called with an error code
  1836. * and a human-readable description each time a GLFW error occurs.
  1837. *
  1838. * The error code is set before the callback is called. Calling @ref
  1839. * glfwGetError from the error callback will return the same value as the error
  1840. * code argument.
  1841. *
  1842. * The error callback is called on the thread where the error occurred. If you
  1843. * are using GLFW from multiple threads, your error callback needs to be
  1844. * written accordingly.
  1845. *
  1846. * Because the description string may have been generated specifically for that
  1847. * error, it is not guaranteed to be valid after the callback has returned. If
  1848. * you wish to use it after the callback returns, you need to make a copy.
  1849. *
  1850. * Once set, the error callback remains set even after the library has been
  1851. * terminated.
  1852. *
  1853. * @param[in] callback The new callback, or `NULL` to remove the currently set
  1854. * callback.
  1855. * @return The previously set callback, or `NULL` if no callback was set.
  1856. *
  1857. * @callback_signature
  1858. * @code
  1859. * void callback_name(int error_code, const char* description)
  1860. * @endcode
  1861. * For more information about the callback parameters, see the
  1862. * [callback pointer type](@ref GLFWerrorfun).
  1863. *
  1864. * @errors None.
  1865. *
  1866. * @remark This function may be called before @ref glfwInit.
  1867. *
  1868. * @thread_safety This function must only be called from the main thread.
  1869. *
  1870. * @sa @ref error_handling
  1871. * @sa @ref glfwGetError
  1872. *
  1873. * @since Added in version 3.0.
  1874. *
  1875. * @ingroup init
  1876. */
  1877. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
  1878. /*! @brief Returns the currently connected monitors.
  1879. *
  1880. * This function returns an array of handles for all currently connected
  1881. * monitors. The primary monitor is always first in the returned array. If no
  1882. * monitors were found, this function returns `NULL`.
  1883. *
  1884. * @param[out] count Where to store the number of monitors in the returned
  1885. * array. This is set to zero if an error occurred.
  1886. * @return An array of monitor handles, or `NULL` if no monitors were found or
  1887. * if an [error](@ref error_handling) occurred.
  1888. *
  1889. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1890. *
  1891. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1892. * should not free it yourself. It is guaranteed to be valid only until the
  1893. * monitor configuration changes or the library is terminated.
  1894. *
  1895. * @thread_safety This function must only be called from the main thread.
  1896. *
  1897. * @sa @ref monitor_monitors
  1898. * @sa @ref monitor_event
  1899. * @sa @ref glfwGetPrimaryMonitor
  1900. *
  1901. * @since Added in version 3.0.
  1902. *
  1903. * @ingroup monitor
  1904. */
  1905. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  1906. /*! @brief Returns the primary monitor.
  1907. *
  1908. * This function returns the primary monitor. This is usually the monitor
  1909. * where elements like the task bar or global menu bar are located.
  1910. *
  1911. * @return The primary monitor, or `NULL` if no monitors were found or if an
  1912. * [error](@ref error_handling) occurred.
  1913. *
  1914. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1915. *
  1916. * @thread_safety This function must only be called from the main thread.
  1917. *
  1918. * @remark The primary monitor is always first in the array returned by @ref
  1919. * glfwGetMonitors.
  1920. *
  1921. * @sa @ref monitor_monitors
  1922. * @sa @ref glfwGetMonitors
  1923. *
  1924. * @since Added in version 3.0.
  1925. *
  1926. * @ingroup monitor
  1927. */
  1928. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  1929. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  1930. *
  1931. * This function returns the position, in screen coordinates, of the upper-left
  1932. * corner of the specified monitor.
  1933. *
  1934. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1935. * non-`NULL` position arguments will be set to zero.
  1936. *
  1937. * @param[in] monitor The monitor to query.
  1938. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  1939. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  1940. *
  1941. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1942. * GLFW_PLATFORM_ERROR.
  1943. *
  1944. * @thread_safety This function must only be called from the main thread.
  1945. *
  1946. * @sa @ref monitor_properties
  1947. *
  1948. * @since Added in version 3.0.
  1949. *
  1950. * @ingroup monitor
  1951. */
  1952. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  1953. /*! @brief Retrieves the work area of the monitor.
  1954. *
  1955. * This function returns the position, in screen coordinates, of the upper-left
  1956. * corner of the work area of the specified monitor along with the work area
  1957. * size in screen coordinates. The work area is defined as the area of the
  1958. * monitor not occluded by the operating system task bar where present. If no
  1959. * task bar exists then the work area is the monitor resolution in screen
  1960. * coordinates.
  1961. *
  1962. * Any or all of the position and size arguments may be `NULL`. If an error
  1963. * occurs, all non-`NULL` position and size arguments will be set to zero.
  1964. *
  1965. * @param[in] monitor The monitor to query.
  1966. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  1967. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  1968. * @param[out] width Where to store the monitor width, or `NULL`.
  1969. * @param[out] height Where to store the monitor height, or `NULL`.
  1970. *
  1971. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1972. * GLFW_PLATFORM_ERROR.
  1973. *
  1974. * @thread_safety This function must only be called from the main thread.
  1975. *
  1976. * @sa @ref monitor_workarea
  1977. *
  1978. * @since Added in version 3.3.
  1979. *
  1980. * @ingroup monitor
  1981. */
  1982. GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
  1983. /*! @brief Returns the physical size of the monitor.
  1984. *
  1985. * This function returns the size, in millimetres, of the display area of the
  1986. * specified monitor.
  1987. *
  1988. * Some systems do not provide accurate monitor size information, either
  1989. * because the monitor
  1990. * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
  1991. * data is incorrect or because the driver does not report it accurately.
  1992. *
  1993. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1994. * non-`NULL` size arguments will be set to zero.
  1995. *
  1996. * @param[in] monitor The monitor to query.
  1997. * @param[out] widthMM Where to store the width, in millimetres, of the
  1998. * monitor's display area, or `NULL`.
  1999. * @param[out] heightMM Where to store the height, in millimetres, of the
  2000. * monitor's display area, or `NULL`.
  2001. *
  2002. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2003. *
  2004. * @remark @win32 On Windows 8 and earlier the physical size is calculated from
  2005. * the current resolution and system DPI instead of querying the monitor EDID data.
  2006. *
  2007. * @thread_safety This function must only be called from the main thread.
  2008. *
  2009. * @sa @ref monitor_properties
  2010. *
  2011. * @since Added in version 3.0.
  2012. *
  2013. * @ingroup monitor
  2014. */
  2015. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
  2016. /*! @brief Retrieves the content scale for the specified monitor.
  2017. *
  2018. * This function retrieves the content scale for the specified monitor. The
  2019. * content scale is the ratio between the current DPI and the platform's
  2020. * default DPI. This is especially important for text and any UI elements. If
  2021. * the pixel dimensions of your UI scaled by this look appropriate on your
  2022. * machine then it should appear at a reasonable size on other machines
  2023. * regardless of their DPI and scaling settings. This relies on the system DPI
  2024. * and scaling settings being somewhat correct.
  2025. *
  2026. * The content scale may depend on both the monitor resolution and pixel
  2027. * density and on user settings. It may be very different from the raw DPI
  2028. * calculated from the physical size and current resolution.
  2029. *
  2030. * @param[in] monitor The monitor to query.
  2031. * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
  2032. * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
  2033. *
  2034. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2035. * GLFW_PLATFORM_ERROR.
  2036. *
  2037. * @thread_safety This function must only be called from the main thread.
  2038. *
  2039. * @sa @ref monitor_scale
  2040. * @sa @ref glfwGetWindowContentScale
  2041. *
  2042. * @since Added in version 3.3.
  2043. *
  2044. * @ingroup monitor
  2045. */
  2046. GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
  2047. /*! @brief Returns the name of the specified monitor.
  2048. *
  2049. * This function returns a human-readable name, encoded as UTF-8, of the
  2050. * specified monitor. The name typically reflects the make and model of the
  2051. * monitor and is not guaranteed to be unique among the connected monitors.
  2052. *
  2053. * @param[in] monitor The monitor to query.
  2054. * @return The UTF-8 encoded name of the monitor, or `NULL` if an
  2055. * [error](@ref error_handling) occurred.
  2056. *
  2057. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2058. *
  2059. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  2060. * should not free it yourself. It is valid until the specified monitor is
  2061. * disconnected or the library is terminated.
  2062. *
  2063. * @thread_safety This function must only be called from the main thread.
  2064. *
  2065. * @sa @ref monitor_properties
  2066. *
  2067. * @since Added in version 3.0.
  2068. *
  2069. * @ingroup monitor
  2070. */
  2071. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  2072. /*! @brief Sets the user pointer of the specified monitor.
  2073. *
  2074. * This function sets the user-defined pointer of the specified monitor. The
  2075. * current value is retained until the monitor is disconnected. The initial
  2076. * value is `NULL`.
  2077. *
  2078. * This function may be called from the monitor callback, even for a monitor
  2079. * that is being disconnected.
  2080. *
  2081. * @param[in] monitor The monitor whose pointer to set.
  2082. * @param[in] pointer The new value.
  2083. *
  2084. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2085. *
  2086. * @thread_safety This function may be called from any thread. Access is not
  2087. * synchronized.
  2088. *
  2089. * @sa @ref monitor_userptr
  2090. * @sa @ref glfwGetMonitorUserPointer
  2091. *
  2092. * @since Added in version 3.3.
  2093. *
  2094. * @ingroup monitor
  2095. */
  2096. GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
  2097. /*! @brief Returns the user pointer of the specified monitor.
  2098. *
  2099. * This function returns the current value of the user-defined pointer of the
  2100. * specified monitor. The initial value is `NULL`.
  2101. *
  2102. * This function may be called from the monitor callback, even for a monitor
  2103. * that is being disconnected.
  2104. *
  2105. * @param[in] monitor The monitor whose pointer to return.
  2106. *
  2107. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2108. *
  2109. * @thread_safety This function may be called from any thread. Access is not
  2110. * synchronized.
  2111. *
  2112. * @sa @ref monitor_userptr
  2113. * @sa @ref glfwSetMonitorUserPointer
  2114. *
  2115. * @since Added in version 3.3.
  2116. *
  2117. * @ingroup monitor
  2118. */
  2119. GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
  2120. /*! @brief Sets the monitor configuration callback.
  2121. *
  2122. * This function sets the monitor configuration callback, or removes the
  2123. * currently set callback. This is called when a monitor is connected to or
  2124. * disconnected from the system.
  2125. *
  2126. * @param[in] callback The new callback, or `NULL` to remove the currently set
  2127. * callback.
  2128. * @return The previously set callback, or `NULL` if no callback was set or the
  2129. * library had not been [initialized](@ref intro_init).
  2130. *
  2131. * @callback_signature
  2132. * @code
  2133. * void function_name(GLFWmonitor* monitor, int event)
  2134. * @endcode
  2135. * For more information about the callback parameters, see the
  2136. * [function pointer type](@ref GLFWmonitorfun).
  2137. *
  2138. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2139. *
  2140. * @thread_safety This function must only be called from the main thread.
  2141. *
  2142. * @sa @ref monitor_event
  2143. *
  2144. * @since Added in version 3.0.
  2145. *
  2146. * @ingroup monitor
  2147. */
  2148. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
  2149. /*! @brief Returns the available video modes for the specified monitor.
  2150. *
  2151. * This function returns an array of all video modes supported by the specified
  2152. * monitor. The returned array is sorted in ascending order, first by color
  2153. * bit depth (the sum of all channel depths), then by resolution area (the
  2154. * product of width and height), then resolution width and finally by refresh
  2155. * rate.
  2156. *
  2157. * @param[in] monitor The monitor to query.
  2158. * @param[out] count Where to store the number of video modes in the returned
  2159. * array. This is set to zero if an error occurred.
  2160. * @return An array of video modes, or `NULL` if an
  2161. * [error](@ref error_handling) occurred.
  2162. *
  2163. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2164. * GLFW_PLATFORM_ERROR.
  2165. *
  2166. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  2167. * should not free it yourself. It is valid until the specified monitor is
  2168. * disconnected, this function is called again for that monitor or the library
  2169. * is terminated.
  2170. *
  2171. * @thread_safety This function must only be called from the main thread.
  2172. *
  2173. * @sa @ref monitor_modes
  2174. * @sa @ref glfwGetVideoMode
  2175. *
  2176. * @since Added in version 1.0.
  2177. * @glfw3 Changed to return an array of modes for a specific monitor.
  2178. *
  2179. * @ingroup monitor
  2180. */
  2181. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  2182. /*! @brief Returns the current mode of the specified monitor.
  2183. *
  2184. * This function returns the current video mode of the specified monitor. If
  2185. * you have created a full screen window for that monitor, the return value
  2186. * will depend on whether that window is iconified.
  2187. *
  2188. * @param[in] monitor The monitor to query.
  2189. * @return The current mode of the monitor, or `NULL` if an
  2190. * [error](@ref error_handling) occurred.
  2191. *
  2192. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2193. * GLFW_PLATFORM_ERROR.
  2194. *
  2195. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  2196. * should not free it yourself. It is valid until the specified monitor is
  2197. * disconnected or the library is terminated.
  2198. *
  2199. * @thread_safety This function must only be called from the main thread.
  2200. *
  2201. * @sa @ref monitor_modes
  2202. * @sa @ref glfwGetVideoModes
  2203. *
  2204. * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
  2205. *
  2206. * @ingroup monitor
  2207. */
  2208. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  2209. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  2210. *
  2211. * This function generates an appropriately sized gamma ramp from the specified
  2212. * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
  2213. * a finite number greater than zero.
  2214. *
  2215. * The software controlled gamma ramp is applied _in addition_ to the hardware
  2216. * gamma correction, which today is usually an approximation of sRGB gamma.
  2217. * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
  2218. * the default (usually sRGB-like) behavior.
  2219. *
  2220. * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
  2221. * GLFW_SRGB_CAPABLE hint.
  2222. *
  2223. * @param[in] monitor The monitor whose gamma ramp to set.
  2224. * @param[in] gamma The desired exponent.
  2225. *
  2226. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2227. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2228. *
  2229. * @remark @wayland Gamma handling is a privileged protocol, this function
  2230. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
  2231. *
  2232. * @thread_safety This function must only be called from the main thread.
  2233. *
  2234. * @sa @ref monitor_gamma
  2235. *
  2236. * @since Added in version 3.0.
  2237. *
  2238. * @ingroup monitor
  2239. */
  2240. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  2241. /*! @brief Returns the current gamma ramp for the specified monitor.
  2242. *
  2243. * This function returns the current gamma ramp of the specified monitor.
  2244. *
  2245. * @param[in] monitor The monitor to query.
  2246. * @return The current gamma ramp, or `NULL` if an
  2247. * [error](@ref error_handling) occurred.
  2248. *
  2249. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2250. * GLFW_PLATFORM_ERROR.
  2251. *
  2252. * @remark @wayland Gamma handling is a privileged protocol, this function
  2253. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
  2254. * returning `NULL`.
  2255. *
  2256. * @pointer_lifetime The returned structure and its arrays are allocated and
  2257. * freed by GLFW. You should not free them yourself. They are valid until the
  2258. * specified monitor is disconnected, this function is called again for that
  2259. * monitor or the library is terminated.
  2260. *
  2261. * @thread_safety This function must only be called from the main thread.
  2262. *
  2263. * @sa @ref monitor_gamma
  2264. *
  2265. * @since Added in version 3.0.
  2266. *
  2267. * @ingroup monitor
  2268. */
  2269. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  2270. /*! @brief Sets the current gamma ramp for the specified monitor.
  2271. *
  2272. * This function sets the current gamma ramp for the specified monitor. The
  2273. * original gamma ramp for that monitor is saved by GLFW the first time this
  2274. * function is called and is restored by @ref glfwTerminate.
  2275. *
  2276. * The software controlled gamma ramp is applied _in addition_ to the hardware
  2277. * gamma correction, which today is usually an approximation of sRGB gamma.
  2278. * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
  2279. * the default (usually sRGB-like) behavior.
  2280. *
  2281. * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
  2282. * GLFW_SRGB_CAPABLE hint.
  2283. *
  2284. * @param[in] monitor The monitor whose gamma ramp to set.
  2285. * @param[in] ramp The gamma ramp to use.
  2286. *
  2287. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2288. * GLFW_PLATFORM_ERROR.
  2289. *
  2290. * @remark The size of the specified gamma ramp should match the size of the
  2291. * current ramp for that monitor.
  2292. *
  2293. * @remark @win32 The gamma ramp size must be 256.
  2294. *
  2295. * @remark @wayland Gamma handling is a privileged protocol, this function
  2296. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
  2297. *
  2298. * @pointer_lifetime The specified gamma ramp is copied before this function
  2299. * returns.
  2300. *
  2301. * @thread_safety This function must only be called from the main thread.
  2302. *
  2303. * @sa @ref monitor_gamma
  2304. *
  2305. * @since Added in version 3.0.
  2306. *
  2307. * @ingroup monitor
  2308. */
  2309. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  2310. /*! @brief Resets all window hints to their default values.
  2311. *
  2312. * This function resets all window hints to their
  2313. * [default values](@ref window_hints_values).
  2314. *
  2315. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2316. *
  2317. * @thread_safety This function must only be called from the main thread.
  2318. *
  2319. * @sa @ref window_hints
  2320. * @sa @ref glfwWindowHint
  2321. * @sa @ref glfwWindowHintString
  2322. *
  2323. * @since Added in version 3.0.
  2324. *
  2325. * @ingroup window
  2326. */
  2327. GLFWAPI void glfwDefaultWindowHints(void);
  2328. /*! @brief Sets the specified window hint to the desired value.
  2329. *
  2330. * This function sets hints for the next call to @ref glfwCreateWindow. The
  2331. * hints, once set, retain their values until changed by a call to this
  2332. * function or @ref glfwDefaultWindowHints, or until the library is terminated.
  2333. *
  2334. * Only integer value hints can be set with this function. String value hints
  2335. * are set with @ref glfwWindowHintString.
  2336. *
  2337. * This function does not check whether the specified hint values are valid.
  2338. * If you set hints to invalid values this will instead be reported by the next
  2339. * call to @ref glfwCreateWindow.
  2340. *
  2341. * Some hints are platform specific. These may be set on any platform but they
  2342. * will only affect their specific platform. Other platforms will ignore them.
  2343. * Setting these hints requires no platform specific headers or functions.
  2344. *
  2345. * @param[in] hint The [window hint](@ref window_hints) to set.
  2346. * @param[in] value The new value of the window hint.
  2347. *
  2348. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2349. * GLFW_INVALID_ENUM.
  2350. *
  2351. * @thread_safety This function must only be called from the main thread.
  2352. *
  2353. * @sa @ref window_hints
  2354. * @sa @ref glfwWindowHintString
  2355. * @sa @ref glfwDefaultWindowHints
  2356. *
  2357. * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
  2358. *
  2359. * @ingroup window
  2360. */
  2361. GLFWAPI void glfwWindowHint(int hint, int value);
  2362. /*! @brief Sets the specified window hint to the desired value.
  2363. *
  2364. * This function sets hints for the next call to @ref glfwCreateWindow. The
  2365. * hints, once set, retain their values until changed by a call to this
  2366. * function or @ref glfwDefaultWindowHints, or until the library is terminated.
  2367. *
  2368. * Only string type hints can be set with this function. Integer value hints
  2369. * are set with @ref glfwWindowHint.
  2370. *
  2371. * This function does not check whether the specified hint values are valid.
  2372. * If you set hints to invalid values this will instead be reported by the next
  2373. * call to @ref glfwCreateWindow.
  2374. *
  2375. * Some hints are platform specific. These may be set on any platform but they
  2376. * will only affect their specific platform. Other platforms will ignore them.
  2377. * Setting these hints requires no platform specific headers or functions.
  2378. *
  2379. * @param[in] hint The [window hint](@ref window_hints) to set.
  2380. * @param[in] value The new value of the window hint.
  2381. *
  2382. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2383. * GLFW_INVALID_ENUM.
  2384. *
  2385. * @pointer_lifetime The specified string is copied before this function
  2386. * returns.
  2387. *
  2388. * @thread_safety This function must only be called from the main thread.
  2389. *
  2390. * @sa @ref window_hints
  2391. * @sa @ref glfwWindowHint
  2392. * @sa @ref glfwDefaultWindowHints
  2393. *
  2394. * @since Added in version 3.3.
  2395. *
  2396. * @ingroup window
  2397. */
  2398. GLFWAPI void glfwWindowHintString(int hint, const char* value);
  2399. /*! @brief Creates a window and its associated context.
  2400. *
  2401. * This function creates a window and its associated OpenGL or OpenGL ES
  2402. * context. Most of the options controlling how the window and its context
  2403. * should be created are specified with [window hints](@ref window_hints).
  2404. *
  2405. * Successful creation does not change which context is current. Before you
  2406. * can use the newly created context, you need to
  2407. * [make it current](@ref context_current). For information about the `share`
  2408. * parameter, see @ref context_sharing.
  2409. *
  2410. * The created window, framebuffer and context may differ from what you
  2411. * requested, as not all parameters and hints are
  2412. * [hard constraints](@ref window_hints_hard). This includes the size of the
  2413. * window, especially for full screen windows. To query the actual attributes
  2414. * of the created window, framebuffer and context, see @ref
  2415. * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
  2416. *
  2417. * To create a full screen window, you need to specify the monitor the window
  2418. * will cover. If no monitor is specified, the window will be windowed mode.
  2419. * Unless you have a way for the user to choose a specific monitor, it is
  2420. * recommended that you pick the primary monitor. For more information on how
  2421. * to query connected monitors, see @ref monitor_monitors.
  2422. *
  2423. * For full screen windows, the specified size becomes the resolution of the
  2424. * window's _desired video mode_. As long as a full screen window is not
  2425. * iconified, the supported video mode most closely matching the desired video
  2426. * mode is set for the specified monitor. For more information about full
  2427. * screen windows, including the creation of so called _windowed full screen_
  2428. * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
  2429. *
  2430. * Once you have created the window, you can switch it between windowed and
  2431. * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
  2432. * OpenGL or OpenGL ES context.
  2433. *
  2434. * By default, newly created windows use the placement recommended by the
  2435. * window system. To create the window at a specific position, make it
  2436. * initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
  2437. * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
  2438. * it.
  2439. *
  2440. * As long as at least one full screen window is not iconified, the screensaver
  2441. * is prohibited from starting.
  2442. *
  2443. * Window systems put limits on window sizes. Very large or very small window
  2444. * dimensions may be overridden by the window system on creation. Check the
  2445. * actual [size](@ref window_size) after creation.
  2446. *
  2447. * The [swap interval](@ref buffer_swap) is not set during window creation and
  2448. * the initial value may vary depending on driver settings and defaults.
  2449. *
  2450. * @param[in] width The desired width, in screen coordinates, of the window.
  2451. * This must be greater than zero.
  2452. * @param[in] height The desired height, in screen coordinates, of the window.
  2453. * This must be greater than zero.
  2454. * @param[in] title The initial, UTF-8 encoded window title.
  2455. * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
  2456. * windowed mode.
  2457. * @param[in] share The window whose context to share resources with, or `NULL`
  2458. * to not share resources.
  2459. * @return The handle of the created window, or `NULL` if an
  2460. * [error](@ref error_handling) occurred.
  2461. *
  2462. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2463. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
  2464. * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
  2465. * GLFW_PLATFORM_ERROR.
  2466. *
  2467. * @remark @win32 Window creation will fail if the Microsoft GDI software
  2468. * OpenGL implementation is the only one available.
  2469. *
  2470. * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
  2471. * will be set as the initial icon for the window. If no such icon is present,
  2472. * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
  2473. * see @ref glfwSetWindowIcon.
  2474. *
  2475. * @remark @win32 The context to share resources with must not be current on
  2476. * any other thread.
  2477. *
  2478. * @remark @macos The OS only supports forward-compatible core profile contexts
  2479. * for OpenGL versions 3.2 and later. Before creating an OpenGL context of
  2480. * version 3.2 or later you must set the
  2481. * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and
  2482. * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly.
  2483. * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
  2484. *
  2485. * @remark @macos The GLFW window has no icon, as it is not a document
  2486. * window, but the dock icon will be the same as the application bundle's icon.
  2487. * For more information on bundles, see the
  2488. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  2489. * in the Mac Developer Library.
  2490. *
  2491. * @remark @macos The first time a window is created the menu bar is created.
  2492. * If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu
  2493. * bar. Otherwise a minimal menu bar is created manually with common commands
  2494. * like Hide, Quit and About. The About entry opens a minimal about dialog
  2495. * with information from the application's bundle. Menu bar creation can be
  2496. * disabled entirely with the @ref GLFW_COCOA_MENUBAR init hint.
  2497. *
  2498. * @remark @macos On OS X 10.10 and later the window frame will not be rendered
  2499. * at full resolution on Retina displays unless the
  2500. * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
  2501. * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
  2502. * application bundle's `Info.plist`. For more information, see
  2503. * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
  2504. * in the Mac Developer Library. The GLFW test and example programs use
  2505. * a custom `Info.plist` template for this, which can be found as
  2506. * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
  2507. *
  2508. * @remark @macos When activating frame autosaving with
  2509. * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
  2510. * window size and position may be overridden by previously saved values.
  2511. *
  2512. * @remark @x11 Some window managers will not respect the placement of
  2513. * initially hidden windows.
  2514. *
  2515. * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
  2516. * a window to reach its requested state. This means you may not be able to
  2517. * query the final size, position or other attributes directly after window
  2518. * creation.
  2519. *
  2520. * @remark @x11 The class part of the `WM_CLASS` window property will by
  2521. * default be set to the window title passed to this function. The instance
  2522. * part will use the contents of the `RESOURCE_NAME` environment variable, if
  2523. * present and not empty, or fall back to the window title. Set the
  2524. * [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
  2525. * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
  2526. * override this.
  2527. *
  2528. * @remark @wayland Compositors should implement the xdg-decoration protocol
  2529. * for GLFW to decorate the window properly. If this protocol isn't
  2530. * supported, or if the compositor prefers client-side decorations, a very
  2531. * simple fallback frame will be drawn using the wp_viewporter protocol. A
  2532. * compositor can still emit close, maximize or fullscreen events, using for
  2533. * instance a keybind mechanism. If neither of these protocols is supported,
  2534. * the window won't be decorated.
  2535. *
  2536. * @remark @wayland A full screen window will not attempt to change the mode,
  2537. * no matter what the requested size or refresh rate.
  2538. *
  2539. * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
  2540. * to be implemented in the user's compositor.
  2541. *
  2542. * @thread_safety This function must only be called from the main thread.
  2543. *
  2544. * @sa @ref window_creation
  2545. * @sa @ref glfwDestroyWindow
  2546. *
  2547. * @since Added in version 3.0. Replaces `glfwOpenWindow`.
  2548. *
  2549. * @ingroup window
  2550. */
  2551. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  2552. /*! @brief Destroys the specified window and its context.
  2553. *
  2554. * This function destroys the specified window and its context. On calling
  2555. * this function, no further callbacks will be called for that window.
  2556. *
  2557. * If the context of the specified window is current on the main thread, it is
  2558. * detached before being destroyed.
  2559. *
  2560. * @param[in] window The window to destroy.
  2561. *
  2562. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2563. * GLFW_PLATFORM_ERROR.
  2564. *
  2565. * @note The context of the specified window must not be current on any other
  2566. * thread when this function is called.
  2567. *
  2568. * @reentrancy This function must not be called from a callback.
  2569. *
  2570. * @thread_safety This function must only be called from the main thread.
  2571. *
  2572. * @sa @ref window_creation
  2573. * @sa @ref glfwCreateWindow
  2574. *
  2575. * @since Added in version 3.0. Replaces `glfwCloseWindow`.
  2576. *
  2577. * @ingroup window
  2578. */
  2579. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  2580. /*! @brief Checks the close flag of the specified window.
  2581. *
  2582. * This function returns the value of the close flag of the specified window.
  2583. *
  2584. * @param[in] window The window to query.
  2585. * @return The value of the close flag.
  2586. *
  2587. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2588. *
  2589. * @thread_safety This function may be called from any thread. Access is not
  2590. * synchronized.
  2591. *
  2592. * @sa @ref window_close
  2593. *
  2594. * @since Added in version 3.0.
  2595. *
  2596. * @ingroup window
  2597. */
  2598. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  2599. /*! @brief Sets the close flag of the specified window.
  2600. *
  2601. * This function sets the value of the close flag of the specified window.
  2602. * This can be used to override the user's attempt to close the window, or
  2603. * to signal that it should be closed.
  2604. *
  2605. * @param[in] window The window whose flag to change.
  2606. * @param[in] value The new value.
  2607. *
  2608. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2609. *
  2610. * @thread_safety This function may be called from any thread. Access is not
  2611. * synchronized.
  2612. *
  2613. * @sa @ref window_close
  2614. *
  2615. * @since Added in version 3.0.
  2616. *
  2617. * @ingroup window
  2618. */
  2619. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  2620. /*! @brief Sets the title of the specified window.
  2621. *
  2622. * This function sets the window title, encoded as UTF-8, of the specified
  2623. * window.
  2624. *
  2625. * @param[in] window The window whose title to change.
  2626. * @param[in] title The UTF-8 encoded window title.
  2627. *
  2628. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2629. * GLFW_PLATFORM_ERROR.
  2630. *
  2631. * @remark @macos The window title will not be updated until the next time you
  2632. * process events.
  2633. *
  2634. * @thread_safety This function must only be called from the main thread.
  2635. *
  2636. * @sa @ref window_title
  2637. *
  2638. * @since Added in version 1.0.
  2639. * @glfw3 Added window handle parameter.
  2640. *
  2641. * @ingroup window
  2642. */
  2643. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  2644. /*! @brief Sets the icon for the specified window.
  2645. *
  2646. * This function sets the icon of the specified window. If passed an array of
  2647. * candidate images, those of or closest to the sizes desired by the system are
  2648. * selected. If no images are specified, the window reverts to its default
  2649. * icon.
  2650. *
  2651. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  2652. * bits per channel with the red channel first. They are arranged canonically
  2653. * as packed sequential rows, starting from the top-left corner.
  2654. *
  2655. * The desired image sizes varies depending on platform and system settings.
  2656. * The selected images will be rescaled as needed. Good sizes include 16x16,
  2657. * 32x32 and 48x48.
  2658. *
  2659. * @param[in] window The window whose icon to set.
  2660. * @param[in] count The number of images in the specified array, or zero to
  2661. * revert to the default window icon.
  2662. * @param[in] images The images to create the icon from. This is ignored if
  2663. * count is zero.
  2664. *
  2665. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2666. * GLFW_PLATFORM_ERROR.
  2667. *
  2668. * @pointer_lifetime The specified image data is copied before this function
  2669. * returns.
  2670. *
  2671. * @remark @macos The GLFW window has no icon, as it is not a document
  2672. * window, so this function does nothing. The dock icon will be the same as
  2673. * the application bundle's icon. For more information on bundles, see the
  2674. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  2675. * in the Mac Developer Library.
  2676. *
  2677. * @remark @wayland There is no existing protocol to change an icon, the
  2678. * window will thus inherit the one defined in the application's desktop file.
  2679. * This function always emits @ref GLFW_PLATFORM_ERROR.
  2680. *
  2681. * @thread_safety This function must only be called from the main thread.
  2682. *
  2683. * @sa @ref window_icon
  2684. *
  2685. * @since Added in version 3.2.
  2686. *
  2687. * @ingroup window
  2688. */
  2689. GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
  2690. /*! @brief Retrieves the position of the content area of the specified window.
  2691. *
  2692. * This function retrieves the position, in screen coordinates, of the
  2693. * upper-left corner of the content area of the specified window.
  2694. *
  2695. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  2696. * non-`NULL` position arguments will be set to zero.
  2697. *
  2698. * @param[in] window The window to query.
  2699. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  2700. * the content area, or `NULL`.
  2701. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  2702. * the content area, or `NULL`.
  2703. *
  2704. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2705. * GLFW_PLATFORM_ERROR.
  2706. *
  2707. * @remark @wayland There is no way for an application to retrieve the global
  2708. * position of its windows, this function will always emit @ref
  2709. * GLFW_PLATFORM_ERROR.
  2710. *
  2711. * @thread_safety This function must only be called from the main thread.
  2712. *
  2713. * @sa @ref window_pos
  2714. * @sa @ref glfwSetWindowPos
  2715. *
  2716. * @since Added in version 3.0.
  2717. *
  2718. * @ingroup window
  2719. */
  2720. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  2721. /*! @brief Sets the position of the content area of the specified window.
  2722. *
  2723. * This function sets the position, in screen coordinates, of the upper-left
  2724. * corner of the content area of the specified windowed mode window. If the
  2725. * window is a full screen window, this function does nothing.
  2726. *
  2727. * __Do not use this function__ to move an already visible window unless you
  2728. * have very good reasons for doing so, as it will confuse and annoy the user.
  2729. *
  2730. * The window manager may put limits on what positions are allowed. GLFW
  2731. * cannot and should not override these limits.
  2732. *
  2733. * @param[in] window The window to query.
  2734. * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
  2735. * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
  2736. *
  2737. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2738. * GLFW_PLATFORM_ERROR.
  2739. *
  2740. * @remark @wayland There is no way for an application to set the global
  2741. * position of its windows, this function will always emit @ref
  2742. * GLFW_PLATFORM_ERROR.
  2743. *
  2744. * @thread_safety This function must only be called from the main thread.
  2745. *
  2746. * @sa @ref window_pos
  2747. * @sa @ref glfwGetWindowPos
  2748. *
  2749. * @since Added in version 1.0.
  2750. * @glfw3 Added window handle parameter.
  2751. *
  2752. * @ingroup window
  2753. */
  2754. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  2755. /*! @brief Retrieves the size of the content area of the specified window.
  2756. *
  2757. * This function retrieves the size, in screen coordinates, of the content area
  2758. * of the specified window. If you wish to retrieve the size of the
  2759. * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
  2760. *
  2761. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2762. * non-`NULL` size arguments will be set to zero.
  2763. *
  2764. * @param[in] window The window whose size to retrieve.
  2765. * @param[out] width Where to store the width, in screen coordinates, of the
  2766. * content area, or `NULL`.
  2767. * @param[out] height Where to store the height, in screen coordinates, of the
  2768. * content area, or `NULL`.
  2769. *
  2770. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2771. * GLFW_PLATFORM_ERROR.
  2772. *
  2773. * @thread_safety This function must only be called from the main thread.
  2774. *
  2775. * @sa @ref window_size
  2776. * @sa @ref glfwSetWindowSize
  2777. *
  2778. * @since Added in version 1.0.
  2779. * @glfw3 Added window handle parameter.
  2780. *
  2781. * @ingroup window
  2782. */
  2783. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  2784. /*! @brief Sets the size limits of the specified window.
  2785. *
  2786. * This function sets the size limits of the content area of the specified
  2787. * window. If the window is full screen, the size limits only take effect
  2788. * once it is made windowed. If the window is not resizable, this function
  2789. * does nothing.
  2790. *
  2791. * The size limits are applied immediately to a windowed mode window and may
  2792. * cause it to be resized.
  2793. *
  2794. * The maximum dimensions must be greater than or equal to the minimum
  2795. * dimensions and all must be greater than or equal to zero.
  2796. *
  2797. * @param[in] window The window to set limits for.
  2798. * @param[in] minwidth The minimum width, in screen coordinates, of the content
  2799. * area, or `GLFW_DONT_CARE`.
  2800. * @param[in] minheight The minimum height, in screen coordinates, of the
  2801. * content area, or `GLFW_DONT_CARE`.
  2802. * @param[in] maxwidth The maximum width, in screen coordinates, of the content
  2803. * area, or `GLFW_DONT_CARE`.
  2804. * @param[in] maxheight The maximum height, in screen coordinates, of the
  2805. * content area, or `GLFW_DONT_CARE`.
  2806. *
  2807. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2808. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2809. *
  2810. * @remark If you set size limits and an aspect ratio that conflict, the
  2811. * results are undefined.
  2812. *
  2813. * @remark @wayland The size limits will not be applied until the window is
  2814. * actually resized, either by the user or by the compositor.
  2815. *
  2816. * @thread_safety This function must only be called from the main thread.
  2817. *
  2818. * @sa @ref window_sizelimits
  2819. * @sa @ref glfwSetWindowAspectRatio
  2820. *
  2821. * @since Added in version 3.2.
  2822. *
  2823. * @ingroup window
  2824. */
  2825. GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
  2826. /*! @brief Sets the aspect ratio of the specified window.
  2827. *
  2828. * This function sets the required aspect ratio of the content area of the
  2829. * specified window. If the window is full screen, the aspect ratio only takes
  2830. * effect once it is made windowed. If the window is not resizable, this
  2831. * function does nothing.
  2832. *
  2833. * The aspect ratio is specified as a numerator and a denominator and both
  2834. * values must be greater than zero. For example, the common 16:9 aspect ratio
  2835. * is specified as 16 and 9, respectively.
  2836. *
  2837. * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
  2838. * ratio limit is disabled.
  2839. *
  2840. * The aspect ratio is applied immediately to a windowed mode window and may
  2841. * cause it to be resized.
  2842. *
  2843. * @param[in] window The window to set limits for.
  2844. * @param[in] numer The numerator of the desired aspect ratio, or
  2845. * `GLFW_DONT_CARE`.
  2846. * @param[in] denom The denominator of the desired aspect ratio, or
  2847. * `GLFW_DONT_CARE`.
  2848. *
  2849. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2850. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2851. *
  2852. * @remark If you set size limits and an aspect ratio that conflict, the
  2853. * results are undefined.
  2854. *
  2855. * @remark @wayland The aspect ratio will not be applied until the window is
  2856. * actually resized, either by the user or by the compositor.
  2857. *
  2858. * @thread_safety This function must only be called from the main thread.
  2859. *
  2860. * @sa @ref window_sizelimits
  2861. * @sa @ref glfwSetWindowSizeLimits
  2862. *
  2863. * @since Added in version 3.2.
  2864. *
  2865. * @ingroup window
  2866. */
  2867. GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
  2868. /*! @brief Sets the size of the content area of the specified window.
  2869. *
  2870. * This function sets the size, in screen coordinates, of the content area of
  2871. * the specified window.
  2872. *
  2873. * For full screen windows, this function updates the resolution of its desired
  2874. * video mode and switches to the video mode closest to it, without affecting
  2875. * the window's context. As the context is unaffected, the bit depths of the
  2876. * framebuffer remain unchanged.
  2877. *
  2878. * If you wish to update the refresh rate of the desired video mode in addition
  2879. * to its resolution, see @ref glfwSetWindowMonitor.
  2880. *
  2881. * The window manager may put limits on what sizes are allowed. GLFW cannot
  2882. * and should not override these limits.
  2883. *
  2884. * @param[in] window The window to resize.
  2885. * @param[in] width The desired width, in screen coordinates, of the window
  2886. * content area.
  2887. * @param[in] height The desired height, in screen coordinates, of the window
  2888. * content area.
  2889. *
  2890. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2891. * GLFW_PLATFORM_ERROR.
  2892. *
  2893. * @remark @wayland A full screen window will not attempt to change the mode,
  2894. * no matter what the requested size.
  2895. *
  2896. * @thread_safety This function must only be called from the main thread.
  2897. *
  2898. * @sa @ref window_size
  2899. * @sa @ref glfwGetWindowSize
  2900. * @sa @ref glfwSetWindowMonitor
  2901. *
  2902. * @since Added in version 1.0.
  2903. * @glfw3 Added window handle parameter.
  2904. *
  2905. * @ingroup window
  2906. */
  2907. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  2908. /*! @brief Retrieves the size of the framebuffer of the specified window.
  2909. *
  2910. * This function retrieves the size, in pixels, of the framebuffer of the
  2911. * specified window. If you wish to retrieve the size of the window in screen
  2912. * coordinates, see @ref glfwGetWindowSize.
  2913. *
  2914. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2915. * non-`NULL` size arguments will be set to zero.
  2916. *
  2917. * @param[in] window The window whose framebuffer to query.
  2918. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  2919. * or `NULL`.
  2920. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  2921. * or `NULL`.
  2922. *
  2923. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2924. * GLFW_PLATFORM_ERROR.
  2925. *
  2926. * @thread_safety This function must only be called from the main thread.
  2927. *
  2928. * @sa @ref window_fbsize
  2929. * @sa @ref glfwSetFramebufferSizeCallback
  2930. *
  2931. * @since Added in version 3.0.
  2932. *
  2933. * @ingroup window
  2934. */
  2935. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  2936. /*! @brief Retrieves the size of the frame of the window.
  2937. *
  2938. * This function retrieves the size, in screen coordinates, of each edge of the
  2939. * frame of the specified window. This size includes the title bar, if the
  2940. * window has one. The size of the frame may vary depending on the
  2941. * [window-related hints](@ref window_hints_wnd) used to create it.
  2942. *
  2943. * Because this function retrieves the size of each window frame edge and not
  2944. * the offset along a particular coordinate axis, the retrieved values will
  2945. * always be zero or positive.
  2946. *
  2947. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2948. * non-`NULL` size arguments will be set to zero.
  2949. *
  2950. * @param[in] window The window whose frame size to query.
  2951. * @param[out] left Where to store the size, in screen coordinates, of the left
  2952. * edge of the window frame, or `NULL`.
  2953. * @param[out] top Where to store the size, in screen coordinates, of the top
  2954. * edge of the window frame, or `NULL`.
  2955. * @param[out] right Where to store the size, in screen coordinates, of the
  2956. * right edge of the window frame, or `NULL`.
  2957. * @param[out] bottom Where to store the size, in screen coordinates, of the
  2958. * bottom edge of the window frame, or `NULL`.
  2959. *
  2960. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2961. * GLFW_PLATFORM_ERROR.
  2962. *
  2963. * @thread_safety This function must only be called from the main thread.
  2964. *
  2965. * @sa @ref window_size
  2966. *
  2967. * @since Added in version 3.1.
  2968. *
  2969. * @ingroup window
  2970. */
  2971. GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
  2972. /*! @brief Retrieves the content scale for the specified window.
  2973. *
  2974. * This function retrieves the content scale for the specified window. The
  2975. * content scale is the ratio between the current DPI and the platform's
  2976. * default DPI. This is especially important for text and any UI elements. If
  2977. * the pixel dimensions of your UI scaled by this look appropriate on your
  2978. * machine then it should appear at a reasonable size on other machines
  2979. * regardless of their DPI and scaling settings. This relies on the system DPI
  2980. * and scaling settings being somewhat correct.
  2981. *
  2982. * On systems where each monitors can have its own content scale, the window
  2983. * content scale will depend on which monitor the system considers the window
  2984. * to be on.
  2985. *
  2986. * @param[in] window The window to query.
  2987. * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
  2988. * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
  2989. *
  2990. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2991. * GLFW_PLATFORM_ERROR.
  2992. *
  2993. * @thread_safety This function must only be called from the main thread.
  2994. *
  2995. * @sa @ref window_scale
  2996. * @sa @ref glfwSetWindowContentScaleCallback
  2997. * @sa @ref glfwGetMonitorContentScale
  2998. *
  2999. * @since Added in version 3.3.
  3000. *
  3001. * @ingroup window
  3002. */
  3003. GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
  3004. /*! @brief Returns the opacity of the whole window.
  3005. *
  3006. * This function returns the opacity of the window, including any decorations.
  3007. *
  3008. * The opacity (or alpha) value is a positive finite number between zero and
  3009. * one, where zero is fully transparent and one is fully opaque. If the system
  3010. * does not support whole window transparency, this function always returns one.
  3011. *
  3012. * The initial opacity value for newly created windows is one.
  3013. *
  3014. * @param[in] window The window to query.
  3015. * @return The opacity value of the specified window.
  3016. *
  3017. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3018. * GLFW_PLATFORM_ERROR.
  3019. *
  3020. * @thread_safety This function must only be called from the main thread.
  3021. *
  3022. * @sa @ref window_transparency
  3023. * @sa @ref glfwSetWindowOpacity
  3024. *
  3025. * @since Added in version 3.3.
  3026. *
  3027. * @ingroup window
  3028. */
  3029. GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
  3030. /*! @brief Sets the opacity of the whole window.
  3031. *
  3032. * This function sets the opacity of the window, including any decorations.
  3033. *
  3034. * The opacity (or alpha) value is a positive finite number between zero and
  3035. * one, where zero is fully transparent and one is fully opaque.
  3036. *
  3037. * The initial opacity value for newly created windows is one.
  3038. *
  3039. * A window created with framebuffer transparency may not use whole window
  3040. * transparency. The results of doing this are undefined.
  3041. *
  3042. * @param[in] window The window to set the opacity for.
  3043. * @param[in] opacity The desired opacity of the specified window.
  3044. *
  3045. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3046. * GLFW_PLATFORM_ERROR.
  3047. *
  3048. * @thread_safety This function must only be called from the main thread.
  3049. *
  3050. * @sa @ref window_transparency
  3051. * @sa @ref glfwGetWindowOpacity
  3052. *
  3053. * @since Added in version 3.3.
  3054. *
  3055. * @ingroup window
  3056. */
  3057. GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
  3058. /*! @brief Iconifies the specified window.
  3059. *
  3060. * This function iconifies (minimizes) the specified window if it was
  3061. * previously restored. If the window is already iconified, this function does
  3062. * nothing.
  3063. *
  3064. * If the specified window is a full screen window, the original monitor
  3065. * resolution is restored until the window is restored.
  3066. *
  3067. * @param[in] window The window to iconify.
  3068. *
  3069. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3070. * GLFW_PLATFORM_ERROR.
  3071. *
  3072. * @remark @wayland There is no concept of iconification in wl_shell, this
  3073. * function will emit @ref GLFW_PLATFORM_ERROR when using this deprecated
  3074. * protocol.
  3075. *
  3076. * @thread_safety This function must only be called from the main thread.
  3077. *
  3078. * @sa @ref window_iconify
  3079. * @sa @ref glfwRestoreWindow
  3080. * @sa @ref glfwMaximizeWindow
  3081. *
  3082. * @since Added in version 2.1.
  3083. * @glfw3 Added window handle parameter.
  3084. *
  3085. * @ingroup window
  3086. */
  3087. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  3088. /*! @brief Restores the specified window.
  3089. *
  3090. * This function restores the specified window if it was previously iconified
  3091. * (minimized) or maximized. If the window is already restored, this function
  3092. * does nothing.
  3093. *
  3094. * If the specified window is a full screen window, the resolution chosen for
  3095. * the window is restored on the selected monitor.
  3096. *
  3097. * @param[in] window The window to restore.
  3098. *
  3099. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3100. * GLFW_PLATFORM_ERROR.
  3101. *
  3102. * @thread_safety This function must only be called from the main thread.
  3103. *
  3104. * @sa @ref window_iconify
  3105. * @sa @ref glfwIconifyWindow
  3106. * @sa @ref glfwMaximizeWindow
  3107. *
  3108. * @since Added in version 2.1.
  3109. * @glfw3 Added window handle parameter.
  3110. *
  3111. * @ingroup window
  3112. */
  3113. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  3114. /*! @brief Maximizes the specified window.
  3115. *
  3116. * This function maximizes the specified window if it was previously not
  3117. * maximized. If the window is already maximized, this function does nothing.
  3118. *
  3119. * If the specified window is a full screen window, this function does nothing.
  3120. *
  3121. * @param[in] window The window to maximize.
  3122. *
  3123. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3124. * GLFW_PLATFORM_ERROR.
  3125. *
  3126. * @par Thread Safety
  3127. * This function may only be called from the main thread.
  3128. *
  3129. * @sa @ref window_iconify
  3130. * @sa @ref glfwIconifyWindow
  3131. * @sa @ref glfwRestoreWindow
  3132. *
  3133. * @since Added in GLFW 3.2.
  3134. *
  3135. * @ingroup window
  3136. */
  3137. GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
  3138. /*! @brief Makes the specified window visible.
  3139. *
  3140. * This function makes the specified window visible if it was previously
  3141. * hidden. If the window is already visible or is in full screen mode, this
  3142. * function does nothing.
  3143. *
  3144. * By default, windowed mode windows are focused when shown
  3145. * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
  3146. * to change this behavior for all newly created windows, or change the
  3147. * behavior for an existing window with @ref glfwSetWindowAttrib.
  3148. *
  3149. * @param[in] window The window to make visible.
  3150. *
  3151. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3152. * GLFW_PLATFORM_ERROR.
  3153. *
  3154. * @remark @wayland Because Wayland wants every frame of the desktop to be
  3155. * complete, this function does not immediately make the window visible.
  3156. * Instead it will become visible the next time the window framebuffer is
  3157. * updated after this call.
  3158. *
  3159. * @thread_safety This function must only be called from the main thread.
  3160. *
  3161. * @sa @ref window_hide
  3162. * @sa @ref glfwHideWindow
  3163. *
  3164. * @since Added in version 3.0.
  3165. *
  3166. * @ingroup window
  3167. */
  3168. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  3169. /*! @brief Hides the specified window.
  3170. *
  3171. * This function hides the specified window if it was previously visible. If
  3172. * the window is already hidden or is in full screen mode, this function does
  3173. * nothing.
  3174. *
  3175. * @param[in] window The window to hide.
  3176. *
  3177. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3178. * GLFW_PLATFORM_ERROR.
  3179. *
  3180. * @thread_safety This function must only be called from the main thread.
  3181. *
  3182. * @sa @ref window_hide
  3183. * @sa @ref glfwShowWindow
  3184. *
  3185. * @since Added in version 3.0.
  3186. *
  3187. * @ingroup window
  3188. */
  3189. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  3190. /*! @brief Brings the specified window to front and sets input focus.
  3191. *
  3192. * This function brings the specified window to front and sets input focus.
  3193. * The window should already be visible and not iconified.
  3194. *
  3195. * By default, both windowed and full screen mode windows are focused when
  3196. * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
  3197. * disable this behavior.
  3198. *
  3199. * Also by default, windowed mode windows are focused when shown
  3200. * with @ref glfwShowWindow. Set the
  3201. * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
  3202. *
  3203. * __Do not use this function__ to steal focus from other applications unless
  3204. * you are certain that is what the user wants. Focus stealing can be
  3205. * extremely disruptive.
  3206. *
  3207. * For a less disruptive way of getting the user's attention, see
  3208. * [attention requests](@ref window_attention).
  3209. *
  3210. * @param[in] window The window to give input focus.
  3211. *
  3212. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3213. * GLFW_PLATFORM_ERROR.
  3214. *
  3215. * @remark @wayland It is not possible for an application to bring its windows
  3216. * to front, this function will always emit @ref GLFW_PLATFORM_ERROR.
  3217. *
  3218. * @thread_safety This function must only be called from the main thread.
  3219. *
  3220. * @sa @ref window_focus
  3221. * @sa @ref window_attention
  3222. *
  3223. * @since Added in version 3.2.
  3224. *
  3225. * @ingroup window
  3226. */
  3227. GLFWAPI void glfwFocusWindow(GLFWwindow* window);
  3228. /*! @brief Requests user attention to the specified window.
  3229. *
  3230. * This function requests user attention to the specified window. On
  3231. * platforms where this is not supported, attention is requested to the
  3232. * application as a whole.
  3233. *
  3234. * Once the user has given attention, usually by focusing the window or
  3235. * application, the system will end the request automatically.
  3236. *
  3237. * @param[in] window The window to request attention to.
  3238. *
  3239. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3240. * GLFW_PLATFORM_ERROR.
  3241. *
  3242. * @remark @macos Attention is requested to the application as a whole, not the
  3243. * specific window.
  3244. *
  3245. * @thread_safety This function must only be called from the main thread.
  3246. *
  3247. * @sa @ref window_attention
  3248. *
  3249. * @since Added in version 3.3.
  3250. *
  3251. * @ingroup window
  3252. */
  3253. GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
  3254. /*! @brief Returns the monitor that the window uses for full screen mode.
  3255. *
  3256. * This function returns the handle of the monitor that the specified window is
  3257. * in full screen on.
  3258. *
  3259. * @param[in] window The window to query.
  3260. * @return The monitor, or `NULL` if the window is in windowed mode or an
  3261. * [error](@ref error_handling) occurred.
  3262. *
  3263. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3264. *
  3265. * @thread_safety This function must only be called from the main thread.
  3266. *
  3267. * @sa @ref window_monitor
  3268. * @sa @ref glfwSetWindowMonitor
  3269. *
  3270. * @since Added in version 3.0.
  3271. *
  3272. * @ingroup window
  3273. */
  3274. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  3275. /*! @brief Sets the mode, monitor, video mode and placement of a window.
  3276. *
  3277. * This function sets the monitor that the window uses for full screen mode or,
  3278. * if the monitor is `NULL`, makes it windowed mode.
  3279. *
  3280. * When setting a monitor, this function updates the width, height and refresh
  3281. * rate of the desired video mode and switches to the video mode closest to it.
  3282. * The window position is ignored when setting a monitor.
  3283. *
  3284. * When the monitor is `NULL`, the position, width and height are used to
  3285. * place the window content area. The refresh rate is ignored when no monitor
  3286. * is specified.
  3287. *
  3288. * If you only wish to update the resolution of a full screen window or the
  3289. * size of a windowed mode window, see @ref glfwSetWindowSize.
  3290. *
  3291. * When a window transitions from full screen to windowed mode, this function
  3292. * restores any previous window settings such as whether it is decorated,
  3293. * floating, resizable, has size or aspect ratio limits, etc.
  3294. *
  3295. * @param[in] window The window whose monitor, size or video mode to set.
  3296. * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
  3297. * @param[in] xpos The desired x-coordinate of the upper-left corner of the
  3298. * content area.
  3299. * @param[in] ypos The desired y-coordinate of the upper-left corner of the
  3300. * content area.
  3301. * @param[in] width The desired with, in screen coordinates, of the content
  3302. * area or video mode.
  3303. * @param[in] height The desired height, in screen coordinates, of the content
  3304. * area or video mode.
  3305. * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
  3306. * or `GLFW_DONT_CARE`.
  3307. *
  3308. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3309. * GLFW_PLATFORM_ERROR.
  3310. *
  3311. * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
  3312. * affected by any resizing or mode switching, although you may need to update
  3313. * your viewport if the framebuffer size has changed.
  3314. *
  3315. * @remark @wayland The desired window position is ignored, as there is no way
  3316. * for an application to set this property.
  3317. *
  3318. * @remark @wayland Setting the window to full screen will not attempt to
  3319. * change the mode, no matter what the requested size or refresh rate.
  3320. *
  3321. * @thread_safety This function must only be called from the main thread.
  3322. *
  3323. * @sa @ref window_monitor
  3324. * @sa @ref window_full_screen
  3325. * @sa @ref glfwGetWindowMonitor
  3326. * @sa @ref glfwSetWindowSize
  3327. *
  3328. * @since Added in version 3.2.
  3329. *
  3330. * @ingroup window
  3331. */
  3332. GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
  3333. /*! @brief Returns an attribute of the specified window.
  3334. *
  3335. * This function returns the value of an attribute of the specified window or
  3336. * its OpenGL or OpenGL ES context.
  3337. *
  3338. * @param[in] window The window to query.
  3339. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  3340. * return.
  3341. * @return The value of the attribute, or zero if an
  3342. * [error](@ref error_handling) occurred.
  3343. *
  3344. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3345. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3346. *
  3347. * @remark Framebuffer related hints are not window attributes. See @ref
  3348. * window_attribs_fb for more information.
  3349. *
  3350. * @remark Zero is a valid value for many window and context related
  3351. * attributes so you cannot use a return value of zero as an indication of
  3352. * errors. However, this function should not fail as long as it is passed
  3353. * valid arguments and the library has been [initialized](@ref intro_init).
  3354. *
  3355. * @thread_safety This function must only be called from the main thread.
  3356. *
  3357. * @sa @ref window_attribs
  3358. * @sa @ref glfwSetWindowAttrib
  3359. *
  3360. * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
  3361. * `glfwGetGLVersion`.
  3362. *
  3363. * @ingroup window
  3364. */
  3365. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  3366. /*! @brief Sets an attribute of the specified window.
  3367. *
  3368. * This function sets the value of an attribute of the specified window.
  3369. *
  3370. * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
  3371. * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
  3372. * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
  3373. * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
  3374. * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
  3375. *
  3376. * Some of these attributes are ignored for full screen windows. The new
  3377. * value will take effect if the window is later made windowed.
  3378. *
  3379. * Some of these attributes are ignored for windowed mode windows. The new
  3380. * value will take effect if the window is later made full screen.
  3381. *
  3382. * @param[in] window The window to set the attribute for.
  3383. * @param[in] attrib A supported window attribute.
  3384. * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
  3385. *
  3386. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3387. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  3388. *
  3389. * @remark Calling @ref glfwGetWindowAttrib will always return the latest
  3390. * value, even if that value is ignored by the current mode of the window.
  3391. *
  3392. * @thread_safety This function must only be called from the main thread.
  3393. *
  3394. * @sa @ref window_attribs
  3395. * @sa @ref glfwGetWindowAttrib
  3396. *
  3397. * @since Added in version 3.3.
  3398. *
  3399. * @ingroup window
  3400. */
  3401. GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
  3402. /*! @brief Sets the user pointer of the specified window.
  3403. *
  3404. * This function sets the user-defined pointer of the specified window. The
  3405. * current value is retained until the window is destroyed. The initial value
  3406. * is `NULL`.
  3407. *
  3408. * @param[in] window The window whose pointer to set.
  3409. * @param[in] pointer The new value.
  3410. *
  3411. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3412. *
  3413. * @thread_safety This function may be called from any thread. Access is not
  3414. * synchronized.
  3415. *
  3416. * @sa @ref window_userptr
  3417. * @sa @ref glfwGetWindowUserPointer
  3418. *
  3419. * @since Added in version 3.0.
  3420. *
  3421. * @ingroup window
  3422. */
  3423. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  3424. /*! @brief Returns the user pointer of the specified window.
  3425. *
  3426. * This function returns the current value of the user-defined pointer of the
  3427. * specified window. The initial value is `NULL`.
  3428. *
  3429. * @param[in] window The window whose pointer to return.
  3430. *
  3431. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3432. *
  3433. * @thread_safety This function may be called from any thread. Access is not
  3434. * synchronized.
  3435. *
  3436. * @sa @ref window_userptr
  3437. * @sa @ref glfwSetWindowUserPointer
  3438. *
  3439. * @since Added in version 3.0.
  3440. *
  3441. * @ingroup window
  3442. */
  3443. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  3444. /*! @brief Sets the position callback for the specified window.
  3445. *
  3446. * This function sets the position callback of the specified window, which is
  3447. * called when the window is moved. The callback is provided with the
  3448. * position, in screen coordinates, of the upper-left corner of the content
  3449. * area of the window.
  3450. *
  3451. * @param[in] window The window whose callback to set.
  3452. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3453. * callback.
  3454. * @return The previously set callback, or `NULL` if no callback was set or the
  3455. * library had not been [initialized](@ref intro_init).
  3456. *
  3457. * @callback_signature
  3458. * @code
  3459. * void function_name(GLFWwindow* window, int xpos, int ypos)
  3460. * @endcode
  3461. * For more information about the callback parameters, see the
  3462. * [function pointer type](@ref GLFWwindowposfun).
  3463. *
  3464. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3465. *
  3466. * @remark @wayland This callback will never be called, as there is no way for
  3467. * an application to know its global position.
  3468. *
  3469. * @thread_safety This function must only be called from the main thread.
  3470. *
  3471. * @sa @ref window_pos
  3472. *
  3473. * @since Added in version 3.0.
  3474. *
  3475. * @ingroup window
  3476. */
  3477. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
  3478. /*! @brief Sets the size callback for the specified window.
  3479. *
  3480. * This function sets the size callback of the specified window, which is
  3481. * called when the window is resized. The callback is provided with the size,
  3482. * in screen coordinates, of the content area of the window.
  3483. *
  3484. * @param[in] window The window whose callback to set.
  3485. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3486. * callback.
  3487. * @return The previously set callback, or `NULL` if no callback was set or the
  3488. * library had not been [initialized](@ref intro_init).
  3489. *
  3490. * @callback_signature
  3491. * @code
  3492. * void function_name(GLFWwindow* window, int width, int height)
  3493. * @endcode
  3494. * For more information about the callback parameters, see the
  3495. * [function pointer type](@ref GLFWwindowsizefun).
  3496. *
  3497. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3498. *
  3499. * @thread_safety This function must only be called from the main thread.
  3500. *
  3501. * @sa @ref window_size
  3502. *
  3503. * @since Added in version 1.0.
  3504. * @glfw3 Added window handle parameter and return value.
  3505. *
  3506. * @ingroup window
  3507. */
  3508. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
  3509. /*! @brief Sets the close callback for the specified window.
  3510. *
  3511. * This function sets the close callback of the specified window, which is
  3512. * called when the user attempts to close the window, for example by clicking
  3513. * the close widget in the title bar.
  3514. *
  3515. * The close flag is set before this callback is called, but you can modify it
  3516. * at any time with @ref glfwSetWindowShouldClose.
  3517. *
  3518. * The close callback is not triggered by @ref glfwDestroyWindow.
  3519. *
  3520. * @param[in] window The window whose callback to set.
  3521. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3522. * callback.
  3523. * @return The previously set callback, or `NULL` if no callback was set or the
  3524. * library had not been [initialized](@ref intro_init).
  3525. *
  3526. * @callback_signature
  3527. * @code
  3528. * void function_name(GLFWwindow* window)
  3529. * @endcode
  3530. * For more information about the callback parameters, see the
  3531. * [function pointer type](@ref GLFWwindowclosefun).
  3532. *
  3533. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3534. *
  3535. * @remark @macos Selecting Quit from the application menu will trigger the
  3536. * close callback for all windows.
  3537. *
  3538. * @thread_safety This function must only be called from the main thread.
  3539. *
  3540. * @sa @ref window_close
  3541. *
  3542. * @since Added in version 2.5.
  3543. * @glfw3 Added window handle parameter and return value.
  3544. *
  3545. * @ingroup window
  3546. */
  3547. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
  3548. /*! @brief Sets the refresh callback for the specified window.
  3549. *
  3550. * This function sets the refresh callback of the specified window, which is
  3551. * called when the content area of the window needs to be redrawn, for example
  3552. * if the window has been exposed after having been covered by another window.
  3553. *
  3554. * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
  3555. * the window contents are saved off-screen, this callback may be called only
  3556. * very infrequently or never at all.
  3557. *
  3558. * @param[in] window The window whose callback to set.
  3559. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3560. * callback.
  3561. * @return The previously set callback, or `NULL` if no callback was set or the
  3562. * library had not been [initialized](@ref intro_init).
  3563. *
  3564. * @callback_signature
  3565. * @code
  3566. * void function_name(GLFWwindow* window);
  3567. * @endcode
  3568. * For more information about the callback parameters, see the
  3569. * [function pointer type](@ref GLFWwindowrefreshfun).
  3570. *
  3571. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3572. *
  3573. * @thread_safety This function must only be called from the main thread.
  3574. *
  3575. * @sa @ref window_refresh
  3576. *
  3577. * @since Added in version 2.5.
  3578. * @glfw3 Added window handle parameter and return value.
  3579. *
  3580. * @ingroup window
  3581. */
  3582. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
  3583. /*! @brief Sets the focus callback for the specified window.
  3584. *
  3585. * This function sets the focus callback of the specified window, which is
  3586. * called when the window gains or loses input focus.
  3587. *
  3588. * After the focus callback is called for a window that lost input focus,
  3589. * synthetic key and mouse button release events will be generated for all such
  3590. * that had been pressed. For more information, see @ref glfwSetKeyCallback
  3591. * and @ref glfwSetMouseButtonCallback.
  3592. *
  3593. * @param[in] window The window whose callback to set.
  3594. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3595. * callback.
  3596. * @return The previously set callback, or `NULL` if no callback was set or the
  3597. * library had not been [initialized](@ref intro_init).
  3598. *
  3599. * @callback_signature
  3600. * @code
  3601. * void function_name(GLFWwindow* window, int focused)
  3602. * @endcode
  3603. * For more information about the callback parameters, see the
  3604. * [function pointer type](@ref GLFWwindowfocusfun).
  3605. *
  3606. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3607. *
  3608. * @thread_safety This function must only be called from the main thread.
  3609. *
  3610. * @sa @ref window_focus
  3611. *
  3612. * @since Added in version 3.0.
  3613. *
  3614. * @ingroup window
  3615. */
  3616. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
  3617. /*! @brief Sets the iconify callback for the specified window.
  3618. *
  3619. * This function sets the iconification callback of the specified window, which
  3620. * is called when the window is iconified or restored.
  3621. *
  3622. * @param[in] window The window whose callback to set.
  3623. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3624. * callback.
  3625. * @return The previously set callback, or `NULL` if no callback was set or the
  3626. * library had not been [initialized](@ref intro_init).
  3627. *
  3628. * @callback_signature
  3629. * @code
  3630. * void function_name(GLFWwindow* window, int iconified)
  3631. * @endcode
  3632. * For more information about the callback parameters, see the
  3633. * [function pointer type](@ref GLFWwindowiconifyfun).
  3634. *
  3635. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3636. *
  3637. * @remark @wayland The wl_shell protocol has no concept of iconification,
  3638. * this callback will never be called when using this deprecated protocol.
  3639. *
  3640. * @thread_safety This function must only be called from the main thread.
  3641. *
  3642. * @sa @ref window_iconify
  3643. *
  3644. * @since Added in version 3.0.
  3645. *
  3646. * @ingroup window
  3647. */
  3648. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
  3649. /*! @brief Sets the maximize callback for the specified window.
  3650. *
  3651. * This function sets the maximization callback of the specified window, which
  3652. * is called when the window is maximized or restored.
  3653. *
  3654. * @param[in] window The window whose callback to set.
  3655. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3656. * callback.
  3657. * @return The previously set callback, or `NULL` if no callback was set or the
  3658. * library had not been [initialized](@ref intro_init).
  3659. *
  3660. * @callback_signature
  3661. * @code
  3662. * void function_name(GLFWwindow* window, int maximized)
  3663. * @endcode
  3664. * For more information about the callback parameters, see the
  3665. * [function pointer type](@ref GLFWwindowmaximizefun).
  3666. *
  3667. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3668. *
  3669. * @thread_safety This function must only be called from the main thread.
  3670. *
  3671. * @sa @ref window_maximize
  3672. *
  3673. * @since Added in version 3.3.
  3674. *
  3675. * @ingroup window
  3676. */
  3677. GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
  3678. /*! @brief Sets the framebuffer resize callback for the specified window.
  3679. *
  3680. * This function sets the framebuffer resize callback of the specified window,
  3681. * which is called when the framebuffer of the specified window is resized.
  3682. *
  3683. * @param[in] window The window whose callback to set.
  3684. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3685. * callback.
  3686. * @return The previously set callback, or `NULL` if no callback was set or the
  3687. * library had not been [initialized](@ref intro_init).
  3688. *
  3689. * @callback_signature
  3690. * @code
  3691. * void function_name(GLFWwindow* window, int width, int height)
  3692. * @endcode
  3693. * For more information about the callback parameters, see the
  3694. * [function pointer type](@ref GLFWframebuffersizefun).
  3695. *
  3696. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3697. *
  3698. * @thread_safety This function must only be called from the main thread.
  3699. *
  3700. * @sa @ref window_fbsize
  3701. *
  3702. * @since Added in version 3.0.
  3703. *
  3704. * @ingroup window
  3705. */
  3706. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
  3707. /*! @brief Sets the window content scale callback for the specified window.
  3708. *
  3709. * This function sets the window content scale callback of the specified window,
  3710. * which is called when the content scale of the specified window changes.
  3711. *
  3712. * @param[in] window The window whose callback to set.
  3713. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3714. * callback.
  3715. * @return The previously set callback, or `NULL` if no callback was set or the
  3716. * library had not been [initialized](@ref intro_init).
  3717. *
  3718. * @callback_signature
  3719. * @code
  3720. * void function_name(GLFWwindow* window, float xscale, float yscale)
  3721. * @endcode
  3722. * For more information about the callback parameters, see the
  3723. * [function pointer type](@ref GLFWwindowcontentscalefun).
  3724. *
  3725. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3726. *
  3727. * @thread_safety This function must only be called from the main thread.
  3728. *
  3729. * @sa @ref window_scale
  3730. * @sa @ref glfwGetWindowContentScale
  3731. *
  3732. * @since Added in version 3.3.
  3733. *
  3734. * @ingroup window
  3735. */
  3736. GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
  3737. /*! @brief Processes all pending events.
  3738. *
  3739. * This function processes only those events that are already in the event
  3740. * queue and then returns immediately. Processing events will cause the window
  3741. * and input callbacks associated with those events to be called.
  3742. *
  3743. * On some platforms, a window move, resize or menu operation will cause event
  3744. * processing to block. This is due to how event processing is designed on
  3745. * those platforms. You can use the
  3746. * [window refresh callback](@ref window_refresh) to redraw the contents of
  3747. * your window when necessary during such operations.
  3748. *
  3749. * Do not assume that callbacks you set will _only_ be called in response to
  3750. * event processing functions like this one. While it is necessary to poll for
  3751. * events, window systems that require GLFW to register callbacks of its own
  3752. * can pass events to GLFW in response to many window system function calls.
  3753. * GLFW will pass those events on to the application callbacks before
  3754. * returning.
  3755. *
  3756. * Event processing is not required for joystick input to work.
  3757. *
  3758. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3759. * GLFW_PLATFORM_ERROR.
  3760. *
  3761. * @reentrancy This function must not be called from a callback.
  3762. *
  3763. * @thread_safety This function must only be called from the main thread.
  3764. *
  3765. * @sa @ref events
  3766. * @sa @ref glfwWaitEvents
  3767. * @sa @ref glfwWaitEventsTimeout
  3768. *
  3769. * @since Added in version 1.0.
  3770. *
  3771. * @ingroup window
  3772. */
  3773. GLFWAPI void glfwPollEvents(void);
  3774. /*! @brief Waits until events are queued and processes them.
  3775. *
  3776. * This function puts the calling thread to sleep until at least one event is
  3777. * available in the event queue. Once one or more events are available,
  3778. * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
  3779. * are processed and the function then returns immediately. Processing events
  3780. * will cause the window and input callbacks associated with those events to be
  3781. * called.
  3782. *
  3783. * Since not all events are associated with callbacks, this function may return
  3784. * without a callback having been called even if you are monitoring all
  3785. * callbacks.
  3786. *
  3787. * On some platforms, a window move, resize or menu operation will cause event
  3788. * processing to block. This is due to how event processing is designed on
  3789. * those platforms. You can use the
  3790. * [window refresh callback](@ref window_refresh) to redraw the contents of
  3791. * your window when necessary during such operations.
  3792. *
  3793. * Do not assume that callbacks you set will _only_ be called in response to
  3794. * event processing functions like this one. While it is necessary to poll for
  3795. * events, window systems that require GLFW to register callbacks of its own
  3796. * can pass events to GLFW in response to many window system function calls.
  3797. * GLFW will pass those events on to the application callbacks before
  3798. * returning.
  3799. *
  3800. * Event processing is not required for joystick input to work.
  3801. *
  3802. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3803. * GLFW_PLATFORM_ERROR.
  3804. *
  3805. * @reentrancy This function must not be called from a callback.
  3806. *
  3807. * @thread_safety This function must only be called from the main thread.
  3808. *
  3809. * @sa @ref events
  3810. * @sa @ref glfwPollEvents
  3811. * @sa @ref glfwWaitEventsTimeout
  3812. *
  3813. * @since Added in version 2.5.
  3814. *
  3815. * @ingroup window
  3816. */
  3817. GLFWAPI void glfwWaitEvents(void);
  3818. /*! @brief Waits with timeout until events are queued and processes them.
  3819. *
  3820. * This function puts the calling thread to sleep until at least one event is
  3821. * available in the event queue, or until the specified timeout is reached. If
  3822. * one or more events are available, it behaves exactly like @ref
  3823. * glfwPollEvents, i.e. the events in the queue are processed and the function
  3824. * then returns immediately. Processing events will cause the window and input
  3825. * callbacks associated with those events to be called.
  3826. *
  3827. * The timeout value must be a positive finite number.
  3828. *
  3829. * Since not all events are associated with callbacks, this function may return
  3830. * without a callback having been called even if you are monitoring all
  3831. * callbacks.
  3832. *
  3833. * On some platforms, a window move, resize or menu operation will cause event
  3834. * processing to block. This is due to how event processing is designed on
  3835. * those platforms. You can use the
  3836. * [window refresh callback](@ref window_refresh) to redraw the contents of
  3837. * your window when necessary during such operations.
  3838. *
  3839. * Do not assume that callbacks you set will _only_ be called in response to
  3840. * event processing functions like this one. While it is necessary to poll for
  3841. * events, window systems that require GLFW to register callbacks of its own
  3842. * can pass events to GLFW in response to many window system function calls.
  3843. * GLFW will pass those events on to the application callbacks before
  3844. * returning.
  3845. *
  3846. * Event processing is not required for joystick input to work.
  3847. *
  3848. * @param[in] timeout The maximum amount of time, in seconds, to wait.
  3849. *
  3850. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3851. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  3852. *
  3853. * @reentrancy This function must not be called from a callback.
  3854. *
  3855. * @thread_safety This function must only be called from the main thread.
  3856. *
  3857. * @sa @ref events
  3858. * @sa @ref glfwPollEvents
  3859. * @sa @ref glfwWaitEvents
  3860. *
  3861. * @since Added in version 3.2.
  3862. *
  3863. * @ingroup window
  3864. */
  3865. GLFWAPI void glfwWaitEventsTimeout(double timeout);
  3866. /*! @brief Posts an empty event to the event queue.
  3867. *
  3868. * This function posts an empty event from the current thread to the event
  3869. * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
  3870. *
  3871. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3872. * GLFW_PLATFORM_ERROR.
  3873. *
  3874. * @thread_safety This function may be called from any thread.
  3875. *
  3876. * @sa @ref events
  3877. * @sa @ref glfwWaitEvents
  3878. * @sa @ref glfwWaitEventsTimeout
  3879. *
  3880. * @since Added in version 3.1.
  3881. *
  3882. * @ingroup window
  3883. */
  3884. GLFWAPI void glfwPostEmptyEvent(void);
  3885. /*! @brief Returns the value of an input option for the specified window.
  3886. *
  3887. * This function returns the value of an input option for the specified window.
  3888. * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  3889. * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
  3890. * @ref GLFW_RAW_MOUSE_MOTION.
  3891. *
  3892. * @param[in] window The window to query.
  3893. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  3894. * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
  3895. * `GLFW_RAW_MOUSE_MOTION`.
  3896. *
  3897. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3898. * GLFW_INVALID_ENUM.
  3899. *
  3900. * @thread_safety This function must only be called from the main thread.
  3901. *
  3902. * @sa @ref glfwSetInputMode
  3903. *
  3904. * @since Added in version 3.0.
  3905. *
  3906. * @ingroup input
  3907. */
  3908. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  3909. /*! @brief Sets an input option for the specified window.
  3910. *
  3911. * This function sets an input mode option for the specified window. The mode
  3912. * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  3913. * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
  3914. * @ref GLFW_RAW_MOUSE_MOTION.
  3915. *
  3916. * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  3917. * modes:
  3918. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  3919. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
  3920. * content area of the window but does not restrict the cursor from leaving.
  3921. * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  3922. * and unlimited cursor movement. This is useful for implementing for
  3923. * example 3D camera controls.
  3924. *
  3925. * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
  3926. * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
  3927. * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  3928. * the next time it is called even if the key had been released before the
  3929. * call. This is useful when you are only interested in whether keys have been
  3930. * pressed but not when or in which order.
  3931. *
  3932. * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  3933. * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
  3934. * If sticky mouse buttons are enabled, a mouse button press will ensure that
  3935. * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
  3936. * if the mouse button had been released before the call. This is useful when
  3937. * you are only interested in whether mouse buttons have been pressed but not
  3938. * when or in which order.
  3939. *
  3940. * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
  3941. * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
  3942. * callbacks that receive modifier bits will also have the @ref
  3943. * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
  3944. * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
  3945. *
  3946. * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
  3947. * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
  3948. * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
  3949. * attempting to set this will emit @ref GLFW_PLATFORM_ERROR. Call @ref
  3950. * glfwRawMouseMotionSupported to check for support.
  3951. *
  3952. * @param[in] window The window whose input mode to set.
  3953. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  3954. * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
  3955. * `GLFW_RAW_MOUSE_MOTION`.
  3956. * @param[in] value The new value of the specified input mode.
  3957. *
  3958. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3959. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3960. *
  3961. * @thread_safety This function must only be called from the main thread.
  3962. *
  3963. * @sa @ref glfwGetInputMode
  3964. *
  3965. * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
  3966. *
  3967. * @ingroup input
  3968. */
  3969. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  3970. /*! @brief Returns whether raw mouse motion is supported.
  3971. *
  3972. * This function returns whether raw mouse motion is supported on the current
  3973. * system. This status does not change after GLFW has been initialized so you
  3974. * only need to check this once. If you attempt to enable raw motion on
  3975. * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
  3976. *
  3977. * Raw mouse motion is closer to the actual motion of the mouse across
  3978. * a surface. It is not affected by the scaling and acceleration applied to
  3979. * the motion of the desktop cursor. That processing is suitable for a cursor
  3980. * while raw motion is better for controlling for example a 3D camera. Because
  3981. * of this, raw mouse motion is only provided when the cursor is disabled.
  3982. *
  3983. * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
  3984. * or `GLFW_FALSE` otherwise.
  3985. *
  3986. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3987. *
  3988. * @thread_safety This function must only be called from the main thread.
  3989. *
  3990. * @sa @ref raw_mouse_motion
  3991. * @sa @ref glfwSetInputMode
  3992. *
  3993. * @since Added in version 3.3.
  3994. *
  3995. * @ingroup input
  3996. */
  3997. GLFWAPI int glfwRawMouseMotionSupported(void);
  3998. /*! @brief Returns the layout-specific name of the specified printable key.
  3999. *
  4000. * This function returns the name of the specified printable key, encoded as
  4001. * UTF-8. This is typically the character that key would produce without any
  4002. * modifier keys, intended for displaying key bindings to the user. For dead
  4003. * keys, it is typically the diacritic it would add to a character.
  4004. *
  4005. * __Do not use this function__ for [text input](@ref input_char). You will
  4006. * break text input for many languages even if it happens to work for yours.
  4007. *
  4008. * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
  4009. * otherwise the scancode is ignored. If you specify a non-printable key, or
  4010. * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
  4011. * function returns `NULL` but does not emit an error.
  4012. *
  4013. * This behavior allows you to always pass in the arguments in the
  4014. * [key callback](@ref input_key) without modification.
  4015. *
  4016. * The printable keys are:
  4017. * - `GLFW_KEY_APOSTROPHE`
  4018. * - `GLFW_KEY_COMMA`
  4019. * - `GLFW_KEY_MINUS`
  4020. * - `GLFW_KEY_PERIOD`
  4021. * - `GLFW_KEY_SLASH`
  4022. * - `GLFW_KEY_SEMICOLON`
  4023. * - `GLFW_KEY_EQUAL`
  4024. * - `GLFW_KEY_LEFT_BRACKET`
  4025. * - `GLFW_KEY_RIGHT_BRACKET`
  4026. * - `GLFW_KEY_BACKSLASH`
  4027. * - `GLFW_KEY_WORLD_1`
  4028. * - `GLFW_KEY_WORLD_2`
  4029. * - `GLFW_KEY_0` to `GLFW_KEY_9`
  4030. * - `GLFW_KEY_A` to `GLFW_KEY_Z`
  4031. * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
  4032. * - `GLFW_KEY_KP_DECIMAL`
  4033. * - `GLFW_KEY_KP_DIVIDE`
  4034. * - `GLFW_KEY_KP_MULTIPLY`
  4035. * - `GLFW_KEY_KP_SUBTRACT`
  4036. * - `GLFW_KEY_KP_ADD`
  4037. * - `GLFW_KEY_KP_EQUAL`
  4038. *
  4039. * Names for printable keys depend on keyboard layout, while names for
  4040. * non-printable keys are the same across layouts but depend on the application
  4041. * language and should be localized along with other user interface text.
  4042. *
  4043. * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
  4044. * @param[in] scancode The scancode of the key to query.
  4045. * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
  4046. *
  4047. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4048. * GLFW_PLATFORM_ERROR.
  4049. *
  4050. * @remark The contents of the returned string may change when a keyboard
  4051. * layout change event is received.
  4052. *
  4053. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4054. * should not free it yourself. It is valid until the library is terminated.
  4055. *
  4056. * @thread_safety This function must only be called from the main thread.
  4057. *
  4058. * @sa @ref input_key_name
  4059. *
  4060. * @since Added in version 3.2.
  4061. *
  4062. * @ingroup input
  4063. */
  4064. GLFWAPI const char* glfwGetKeyName(int key, int scancode);
  4065. /*! @brief Returns the platform-specific scancode of the specified key.
  4066. *
  4067. * This function returns the platform-specific scancode of the specified key.
  4068. *
  4069. * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
  4070. * method will return `-1`.
  4071. *
  4072. * @param[in] key Any [named key](@ref keys).
  4073. * @return The platform-specific scancode for the key, or `-1` if an
  4074. * [error](@ref error_handling) occurred.
  4075. *
  4076. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4077. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4078. *
  4079. * @thread_safety This function may be called from any thread.
  4080. *
  4081. * @sa @ref input_key
  4082. *
  4083. * @since Added in version 3.3.
  4084. *
  4085. * @ingroup input
  4086. */
  4087. GLFWAPI int glfwGetKeyScancode(int key);
  4088. /*! @brief Returns the last reported state of a keyboard key for the specified
  4089. * window.
  4090. *
  4091. * This function returns the last state reported for the specified key to the
  4092. * specified window. The returned state is one of `GLFW_PRESS` or
  4093. * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
  4094. * the key callback.
  4095. *
  4096. * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
  4097. * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  4098. * that key has already been released.
  4099. *
  4100. * The key functions deal with physical keys, with [key tokens](@ref keys)
  4101. * named after their use on the standard US keyboard layout. If you want to
  4102. * input text, use the Unicode character callback instead.
  4103. *
  4104. * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  4105. * used with this function.
  4106. *
  4107. * __Do not use this function__ to implement [text input](@ref input_char).
  4108. *
  4109. * @param[in] window The desired window.
  4110. * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
  4111. * not a valid key for this function.
  4112. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  4113. *
  4114. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4115. * GLFW_INVALID_ENUM.
  4116. *
  4117. * @thread_safety This function must only be called from the main thread.
  4118. *
  4119. * @sa @ref input_key
  4120. *
  4121. * @since Added in version 1.0.
  4122. * @glfw3 Added window handle parameter.
  4123. *
  4124. * @ingroup input
  4125. */
  4126. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  4127. /*! @brief Returns the last reported state of a mouse button for the specified
  4128. * window.
  4129. *
  4130. * This function returns the last state reported for the specified mouse button
  4131. * to the specified window. The returned state is one of `GLFW_PRESS` or
  4132. * `GLFW_RELEASE`.
  4133. *
  4134. * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
  4135. * returns `GLFW_PRESS` the first time you call it for a mouse button that was
  4136. * pressed, even if that mouse button has already been released.
  4137. *
  4138. * @param[in] window The desired window.
  4139. * @param[in] button The desired [mouse button](@ref buttons).
  4140. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  4141. *
  4142. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4143. * GLFW_INVALID_ENUM.
  4144. *
  4145. * @thread_safety This function must only be called from the main thread.
  4146. *
  4147. * @sa @ref input_mouse_button
  4148. *
  4149. * @since Added in version 1.0.
  4150. * @glfw3 Added window handle parameter.
  4151. *
  4152. * @ingroup input
  4153. */
  4154. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  4155. /*! @brief Retrieves the position of the cursor relative to the content area of
  4156. * the window.
  4157. *
  4158. * This function returns the position of the cursor, in screen coordinates,
  4159. * relative to the upper-left corner of the content area of the specified
  4160. * window.
  4161. *
  4162. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  4163. * position is unbounded and limited only by the minimum and maximum values of
  4164. * a `double`.
  4165. *
  4166. * The coordinate can be converted to their integer equivalents with the
  4167. * `floor` function. Casting directly to an integer type works for positive
  4168. * coordinates, but fails for negative ones.
  4169. *
  4170. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  4171. * non-`NULL` position arguments will be set to zero.
  4172. *
  4173. * @param[in] window The desired window.
  4174. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  4175. * left edge of the content area, or `NULL`.
  4176. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  4177. * top edge of the content area, or `NULL`.
  4178. *
  4179. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4180. * GLFW_PLATFORM_ERROR.
  4181. *
  4182. * @thread_safety This function must only be called from the main thread.
  4183. *
  4184. * @sa @ref cursor_pos
  4185. * @sa @ref glfwSetCursorPos
  4186. *
  4187. * @since Added in version 3.0. Replaces `glfwGetMousePos`.
  4188. *
  4189. * @ingroup input
  4190. */
  4191. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  4192. /*! @brief Sets the position of the cursor, relative to the content area of the
  4193. * window.
  4194. *
  4195. * This function sets the position, in screen coordinates, of the cursor
  4196. * relative to the upper-left corner of the content area of the specified
  4197. * window. The window must have input focus. If the window does not have
  4198. * input focus when this function is called, it fails silently.
  4199. *
  4200. * __Do not use this function__ to implement things like camera controls. GLFW
  4201. * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  4202. * cursor, transparently re-centers it and provides unconstrained cursor
  4203. * motion. See @ref glfwSetInputMode for more information.
  4204. *
  4205. * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  4206. * unconstrained and limited only by the minimum and maximum values of
  4207. * a `double`.
  4208. *
  4209. * @param[in] window The desired window.
  4210. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  4211. * content area.
  4212. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  4213. * content area.
  4214. *
  4215. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4216. * GLFW_PLATFORM_ERROR.
  4217. *
  4218. * @remark @wayland This function will only work when the cursor mode is
  4219. * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
  4220. *
  4221. * @thread_safety This function must only be called from the main thread.
  4222. *
  4223. * @sa @ref cursor_pos
  4224. * @sa @ref glfwGetCursorPos
  4225. *
  4226. * @since Added in version 3.0. Replaces `glfwSetMousePos`.
  4227. *
  4228. * @ingroup input
  4229. */
  4230. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  4231. /*! @brief Creates a custom cursor.
  4232. *
  4233. * Creates a new custom cursor image that can be set for a window with @ref
  4234. * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
  4235. * Any remaining cursors are destroyed by @ref glfwTerminate.
  4236. *
  4237. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  4238. * bits per channel with the red channel first. They are arranged canonically
  4239. * as packed sequential rows, starting from the top-left corner.
  4240. *
  4241. * The cursor hotspot is specified in pixels, relative to the upper-left corner
  4242. * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
  4243. * points to the right and the Y-axis points down.
  4244. *
  4245. * @param[in] image The desired cursor image.
  4246. * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
  4247. * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
  4248. * @return The handle of the created cursor, or `NULL` if an
  4249. * [error](@ref error_handling) occurred.
  4250. *
  4251. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4252. * GLFW_PLATFORM_ERROR.
  4253. *
  4254. * @pointer_lifetime The specified image data is copied before this function
  4255. * returns.
  4256. *
  4257. * @thread_safety This function must only be called from the main thread.
  4258. *
  4259. * @sa @ref cursor_object
  4260. * @sa @ref glfwDestroyCursor
  4261. * @sa @ref glfwCreateStandardCursor
  4262. *
  4263. * @since Added in version 3.1.
  4264. *
  4265. * @ingroup input
  4266. */
  4267. GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
  4268. /*! @brief Creates a cursor with a standard shape.
  4269. *
  4270. * Returns a cursor with a [standard shape](@ref shapes), that can be set for
  4271. * a window with @ref glfwSetCursor.
  4272. *
  4273. * @param[in] shape One of the [standard shapes](@ref shapes).
  4274. * @return A new cursor ready to use or `NULL` if an
  4275. * [error](@ref error_handling) occurred.
  4276. *
  4277. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4278. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4279. *
  4280. * @thread_safety This function must only be called from the main thread.
  4281. *
  4282. * @sa @ref cursor_object
  4283. * @sa @ref glfwCreateCursor
  4284. *
  4285. * @since Added in version 3.1.
  4286. *
  4287. * @ingroup input
  4288. */
  4289. GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
  4290. /*! @brief Destroys a cursor.
  4291. *
  4292. * This function destroys a cursor previously created with @ref
  4293. * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
  4294. * glfwTerminate.
  4295. *
  4296. * If the specified cursor is current for any window, that window will be
  4297. * reverted to the default cursor. This does not affect the cursor mode.
  4298. *
  4299. * @param[in] cursor The cursor object to destroy.
  4300. *
  4301. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4302. * GLFW_PLATFORM_ERROR.
  4303. *
  4304. * @reentrancy This function must not be called from a callback.
  4305. *
  4306. * @thread_safety This function must only be called from the main thread.
  4307. *
  4308. * @sa @ref cursor_object
  4309. * @sa @ref glfwCreateCursor
  4310. *
  4311. * @since Added in version 3.1.
  4312. *
  4313. * @ingroup input
  4314. */
  4315. GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
  4316. /*! @brief Sets the cursor for the window.
  4317. *
  4318. * This function sets the cursor image to be used when the cursor is over the
  4319. * content area of the specified window. The set cursor will only be visible
  4320. * when the [cursor mode](@ref cursor_mode) of the window is
  4321. * `GLFW_CURSOR_NORMAL`.
  4322. *
  4323. * On some platforms, the set cursor may not be visible unless the window also
  4324. * has input focus.
  4325. *
  4326. * @param[in] window The window to set the cursor for.
  4327. * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  4328. * arrow cursor.
  4329. *
  4330. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4331. * GLFW_PLATFORM_ERROR.
  4332. *
  4333. * @thread_safety This function must only be called from the main thread.
  4334. *
  4335. * @sa @ref cursor_object
  4336. *
  4337. * @since Added in version 3.1.
  4338. *
  4339. * @ingroup input
  4340. */
  4341. GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
  4342. /*! @brief Sets the key callback.
  4343. *
  4344. * This function sets the key callback of the specified window, which is called
  4345. * when a key is pressed, repeated or released.
  4346. *
  4347. * The key functions deal with physical keys, with layout independent
  4348. * [key tokens](@ref keys) named after their values in the standard US keyboard
  4349. * layout. If you want to input text, use the
  4350. * [character callback](@ref glfwSetCharCallback) instead.
  4351. *
  4352. * When a window loses input focus, it will generate synthetic key release
  4353. * events for all pressed keys. You can tell these events from user-generated
  4354. * events by the fact that the synthetic ones are generated after the focus
  4355. * loss event has been processed, i.e. after the
  4356. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  4357. *
  4358. * The scancode of a key is specific to that platform or sometimes even to that
  4359. * machine. Scancodes are intended to allow users to bind keys that don't have
  4360. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  4361. * state is not saved and so it cannot be queried with @ref glfwGetKey.
  4362. *
  4363. * Sometimes GLFW needs to generate synthetic key events, in which case the
  4364. * scancode may be zero.
  4365. *
  4366. * @param[in] window The window whose callback to set.
  4367. * @param[in] callback The new key callback, or `NULL` to remove the currently
  4368. * set callback.
  4369. * @return The previously set callback, or `NULL` if no callback was set or the
  4370. * library had not been [initialized](@ref intro_init).
  4371. *
  4372. * @callback_signature
  4373. * @code
  4374. * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
  4375. * @endcode
  4376. * For more information about the callback parameters, see the
  4377. * [function pointer type](@ref GLFWkeyfun).
  4378. *
  4379. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4380. *
  4381. * @thread_safety This function must only be called from the main thread.
  4382. *
  4383. * @sa @ref input_key
  4384. *
  4385. * @since Added in version 1.0.
  4386. * @glfw3 Added window handle parameter and return value.
  4387. *
  4388. * @ingroup input
  4389. */
  4390. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
  4391. /*! @brief Sets the Unicode character callback.
  4392. *
  4393. * This function sets the character callback of the specified window, which is
  4394. * called when a Unicode character is input.
  4395. *
  4396. * The character callback is intended for Unicode text input. As it deals with
  4397. * characters, it is keyboard layout dependent, whereas the
  4398. * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
  4399. * to physical keys, as a key may produce zero, one or more characters. If you
  4400. * want to know whether a specific physical key was pressed or released, see
  4401. * the key callback instead.
  4402. *
  4403. * The character callback behaves as system text input normally does and will
  4404. * not be called if modifier keys are held down that would prevent normal text
  4405. * input on that platform, for example a Super (Command) key on macOS or Alt key
  4406. * on Windows.
  4407. *
  4408. * @param[in] window The window whose callback to set.
  4409. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4410. * callback.
  4411. * @return The previously set callback, or `NULL` if no callback was set or the
  4412. * library had not been [initialized](@ref intro_init).
  4413. *
  4414. * @callback_signature
  4415. * @code
  4416. * void function_name(GLFWwindow* window, unsigned int codepoint)
  4417. * @endcode
  4418. * For more information about the callback parameters, see the
  4419. * [function pointer type](@ref GLFWcharfun).
  4420. *
  4421. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4422. *
  4423. * @thread_safety This function must only be called from the main thread.
  4424. *
  4425. * @sa @ref input_char
  4426. *
  4427. * @since Added in version 2.4.
  4428. * @glfw3 Added window handle parameter and return value.
  4429. *
  4430. * @ingroup input
  4431. */
  4432. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
  4433. /*! @brief Sets the Unicode character with modifiers callback.
  4434. *
  4435. * This function sets the character with modifiers callback of the specified
  4436. * window, which is called when a Unicode character is input regardless of what
  4437. * modifier keys are used.
  4438. *
  4439. * The character with modifiers callback is intended for implementing custom
  4440. * Unicode character input. For regular Unicode text input, see the
  4441. * [character callback](@ref glfwSetCharCallback). Like the character
  4442. * callback, the character with modifiers callback deals with characters and is
  4443. * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
  4444. * a key may produce zero, one or more characters. If you want to know whether
  4445. * a specific physical key was pressed or released, see the
  4446. * [key callback](@ref glfwSetKeyCallback) instead.
  4447. *
  4448. * @param[in] window The window whose callback to set.
  4449. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4450. * callback.
  4451. * @return The previously set callback, or `NULL` if no callback was set or an
  4452. * [error](@ref error_handling) occurred.
  4453. *
  4454. * @callback_signature
  4455. * @code
  4456. * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
  4457. * @endcode
  4458. * For more information about the callback parameters, see the
  4459. * [function pointer type](@ref GLFWcharmodsfun).
  4460. *
  4461. * @deprecated Scheduled for removal in version 4.0.
  4462. *
  4463. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4464. *
  4465. * @thread_safety This function must only be called from the main thread.
  4466. *
  4467. * @sa @ref input_char
  4468. *
  4469. * @since Added in version 3.1.
  4470. *
  4471. * @ingroup input
  4472. */
  4473. GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
  4474. /*! @brief Sets the mouse button callback.
  4475. *
  4476. * This function sets the mouse button callback of the specified window, which
  4477. * is called when a mouse button is pressed or released.
  4478. *
  4479. * When a window loses input focus, it will generate synthetic mouse button
  4480. * release events for all pressed mouse buttons. You can tell these events
  4481. * from user-generated events by the fact that the synthetic ones are generated
  4482. * after the focus loss event has been processed, i.e. after the
  4483. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  4484. *
  4485. * @param[in] window The window whose callback to set.
  4486. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4487. * callback.
  4488. * @return The previously set callback, or `NULL` if no callback was set or the
  4489. * library had not been [initialized](@ref intro_init).
  4490. *
  4491. * @callback_signature
  4492. * @code
  4493. * void function_name(GLFWwindow* window, int button, int action, int mods)
  4494. * @endcode
  4495. * For more information about the callback parameters, see the
  4496. * [function pointer type](@ref GLFWmousebuttonfun).
  4497. *
  4498. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4499. *
  4500. * @thread_safety This function must only be called from the main thread.
  4501. *
  4502. * @sa @ref input_mouse_button
  4503. *
  4504. * @since Added in version 1.0.
  4505. * @glfw3 Added window handle parameter and return value.
  4506. *
  4507. * @ingroup input
  4508. */
  4509. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
  4510. /*! @brief Sets the cursor position callback.
  4511. *
  4512. * This function sets the cursor position callback of the specified window,
  4513. * which is called when the cursor is moved. The callback is provided with the
  4514. * position, in screen coordinates, relative to the upper-left corner of the
  4515. * content area of the window.
  4516. *
  4517. * @param[in] window The window whose callback to set.
  4518. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4519. * callback.
  4520. * @return The previously set callback, or `NULL` if no callback was set or the
  4521. * library had not been [initialized](@ref intro_init).
  4522. *
  4523. * @callback_signature
  4524. * @code
  4525. * void function_name(GLFWwindow* window, double xpos, double ypos);
  4526. * @endcode
  4527. * For more information about the callback parameters, see the
  4528. * [function pointer type](@ref GLFWcursorposfun).
  4529. *
  4530. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4531. *
  4532. * @thread_safety This function must only be called from the main thread.
  4533. *
  4534. * @sa @ref cursor_pos
  4535. *
  4536. * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
  4537. *
  4538. * @ingroup input
  4539. */
  4540. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
  4541. /*! @brief Sets the cursor enter/leave callback.
  4542. *
  4543. * This function sets the cursor boundary crossing callback of the specified
  4544. * window, which is called when the cursor enters or leaves the content area of
  4545. * the window.
  4546. *
  4547. * @param[in] window The window whose callback to set.
  4548. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4549. * callback.
  4550. * @return The previously set callback, or `NULL` if no callback was set or the
  4551. * library had not been [initialized](@ref intro_init).
  4552. *
  4553. * @callback_signature
  4554. * @code
  4555. * void function_name(GLFWwindow* window, int entered)
  4556. * @endcode
  4557. * For more information about the callback parameters, see the
  4558. * [function pointer type](@ref GLFWcursorenterfun).
  4559. *
  4560. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4561. *
  4562. * @thread_safety This function must only be called from the main thread.
  4563. *
  4564. * @sa @ref cursor_enter
  4565. *
  4566. * @since Added in version 3.0.
  4567. *
  4568. * @ingroup input
  4569. */
  4570. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
  4571. /*! @brief Sets the scroll callback.
  4572. *
  4573. * This function sets the scroll callback of the specified window, which is
  4574. * called when a scrolling device is used, such as a mouse wheel or scrolling
  4575. * area of a touchpad.
  4576. *
  4577. * The scroll callback receives all scrolling input, like that from a mouse
  4578. * wheel or a touchpad scrolling area.
  4579. *
  4580. * @param[in] window The window whose callback to set.
  4581. * @param[in] callback The new scroll callback, or `NULL` to remove the
  4582. * currently set callback.
  4583. * @return The previously set callback, or `NULL` if no callback was set or the
  4584. * library had not been [initialized](@ref intro_init).
  4585. *
  4586. * @callback_signature
  4587. * @code
  4588. * void function_name(GLFWwindow* window, double xoffset, double yoffset)
  4589. * @endcode
  4590. * For more information about the callback parameters, see the
  4591. * [function pointer type](@ref GLFWscrollfun).
  4592. *
  4593. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4594. *
  4595. * @thread_safety This function must only be called from the main thread.
  4596. *
  4597. * @sa @ref scrolling
  4598. *
  4599. * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
  4600. *
  4601. * @ingroup input
  4602. */
  4603. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
  4604. /*! @brief Sets the path drop callback.
  4605. *
  4606. * This function sets the path drop callback of the specified window, which is
  4607. * called when one or more dragged paths are dropped on the window.
  4608. *
  4609. * Because the path array and its strings may have been generated specifically
  4610. * for that event, they are not guaranteed to be valid after the callback has
  4611. * returned. If you wish to use them after the callback returns, you need to
  4612. * make a deep copy.
  4613. *
  4614. * @param[in] window The window whose callback to set.
  4615. * @param[in] callback The new file drop callback, or `NULL` to remove the
  4616. * currently set callback.
  4617. * @return The previously set callback, or `NULL` if no callback was set or the
  4618. * library had not been [initialized](@ref intro_init).
  4619. *
  4620. * @callback_signature
  4621. * @code
  4622. * void function_name(GLFWwindow* window, int path_count, const char* paths[])
  4623. * @endcode
  4624. * For more information about the callback parameters, see the
  4625. * [function pointer type](@ref GLFWdropfun).
  4626. *
  4627. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4628. *
  4629. * @remark @wayland File drop is currently unimplemented.
  4630. *
  4631. * @thread_safety This function must only be called from the main thread.
  4632. *
  4633. * @sa @ref path_drop
  4634. *
  4635. * @since Added in version 3.1.
  4636. *
  4637. * @ingroup input
  4638. */
  4639. GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
  4640. /*! @brief Returns whether the specified joystick is present.
  4641. *
  4642. * This function returns whether the specified joystick is present.
  4643. *
  4644. * There is no need to call this function before other functions that accept
  4645. * a joystick ID, as they all check for presence before performing any other
  4646. * work.
  4647. *
  4648. * @param[in] jid The [joystick](@ref joysticks) to query.
  4649. * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
  4650. *
  4651. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4652. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4653. *
  4654. * @thread_safety This function must only be called from the main thread.
  4655. *
  4656. * @sa @ref joystick
  4657. *
  4658. * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
  4659. *
  4660. * @ingroup input
  4661. */
  4662. GLFWAPI int glfwJoystickPresent(int jid);
  4663. /*! @brief Returns the values of all axes of the specified joystick.
  4664. *
  4665. * This function returns the values of all axes of the specified joystick.
  4666. * Each element in the array is a value between -1.0 and 1.0.
  4667. *
  4668. * If the specified joystick is not present this function will return `NULL`
  4669. * but will not generate an error. This can be used instead of first calling
  4670. * @ref glfwJoystickPresent.
  4671. *
  4672. * @param[in] jid The [joystick](@ref joysticks) to query.
  4673. * @param[out] count Where to store the number of axis values in the returned
  4674. * array. This is set to zero if the joystick is not present or an error
  4675. * occurred.
  4676. * @return An array of axis values, or `NULL` if the joystick is not present or
  4677. * an [error](@ref error_handling) occurred.
  4678. *
  4679. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4680. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4681. *
  4682. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4683. * should not free it yourself. It is valid until the specified joystick is
  4684. * disconnected or the library is terminated.
  4685. *
  4686. * @thread_safety This function must only be called from the main thread.
  4687. *
  4688. * @sa @ref joystick_axis
  4689. *
  4690. * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
  4691. *
  4692. * @ingroup input
  4693. */
  4694. GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
  4695. /*! @brief Returns the state of all buttons of the specified joystick.
  4696. *
  4697. * This function returns the state of all buttons of the specified joystick.
  4698. * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
  4699. *
  4700. * For backward compatibility with earlier versions that did not have @ref
  4701. * glfwGetJoystickHats, the button array also includes all hats, each
  4702. * represented as four buttons. The hats are in the same order as returned by
  4703. * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
  4704. * _left_. To disable these extra buttons, set the @ref
  4705. * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
  4706. *
  4707. * If the specified joystick is not present this function will return `NULL`
  4708. * but will not generate an error. This can be used instead of first calling
  4709. * @ref glfwJoystickPresent.
  4710. *
  4711. * @param[in] jid The [joystick](@ref joysticks) to query.
  4712. * @param[out] count Where to store the number of button states in the returned
  4713. * array. This is set to zero if the joystick is not present or an error
  4714. * occurred.
  4715. * @return An array of button states, or `NULL` if the joystick is not present
  4716. * or an [error](@ref error_handling) occurred.
  4717. *
  4718. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4719. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4720. *
  4721. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4722. * should not free it yourself. It is valid until the specified joystick is
  4723. * disconnected or the library is terminated.
  4724. *
  4725. * @thread_safety This function must only be called from the main thread.
  4726. *
  4727. * @sa @ref joystick_button
  4728. *
  4729. * @since Added in version 2.2.
  4730. * @glfw3 Changed to return a dynamic array.
  4731. *
  4732. * @ingroup input
  4733. */
  4734. GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
  4735. /*! @brief Returns the state of all hats of the specified joystick.
  4736. *
  4737. * This function returns the state of all hats of the specified joystick.
  4738. * Each element in the array is one of the following values:
  4739. *
  4740. * Name | Value
  4741. * ---- | -----
  4742. * `GLFW_HAT_CENTERED` | 0
  4743. * `GLFW_HAT_UP` | 1
  4744. * `GLFW_HAT_RIGHT` | 2
  4745. * `GLFW_HAT_DOWN` | 4
  4746. * `GLFW_HAT_LEFT` | 8
  4747. * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
  4748. * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
  4749. * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
  4750. * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
  4751. *
  4752. * The diagonal directions are bitwise combinations of the primary (up, right,
  4753. * down and left) directions and you can test for these individually by ANDing
  4754. * it with the corresponding direction.
  4755. *
  4756. * @code
  4757. * if (hats[2] & GLFW_HAT_RIGHT)
  4758. * {
  4759. * // State of hat 2 could be right-up, right or right-down
  4760. * }
  4761. * @endcode
  4762. *
  4763. * If the specified joystick is not present this function will return `NULL`
  4764. * but will not generate an error. This can be used instead of first calling
  4765. * @ref glfwJoystickPresent.
  4766. *
  4767. * @param[in] jid The [joystick](@ref joysticks) to query.
  4768. * @param[out] count Where to store the number of hat states in the returned
  4769. * array. This is set to zero if the joystick is not present or an error
  4770. * occurred.
  4771. * @return An array of hat states, or `NULL` if the joystick is not present
  4772. * or an [error](@ref error_handling) occurred.
  4773. *
  4774. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4775. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4776. *
  4777. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4778. * should not free it yourself. It is valid until the specified joystick is
  4779. * disconnected, this function is called again for that joystick or the library
  4780. * is terminated.
  4781. *
  4782. * @thread_safety This function must only be called from the main thread.
  4783. *
  4784. * @sa @ref joystick_hat
  4785. *
  4786. * @since Added in version 3.3.
  4787. *
  4788. * @ingroup input
  4789. */
  4790. GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
  4791. /*! @brief Returns the name of the specified joystick.
  4792. *
  4793. * This function returns the name, encoded as UTF-8, of the specified joystick.
  4794. * The returned string is allocated and freed by GLFW. You should not free it
  4795. * yourself.
  4796. *
  4797. * If the specified joystick is not present this function will return `NULL`
  4798. * but will not generate an error. This can be used instead of first calling
  4799. * @ref glfwJoystickPresent.
  4800. *
  4801. * @param[in] jid The [joystick](@ref joysticks) to query.
  4802. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  4803. * is not present or an [error](@ref error_handling) occurred.
  4804. *
  4805. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4806. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4807. *
  4808. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4809. * should not free it yourself. It is valid until the specified joystick is
  4810. * disconnected or the library is terminated.
  4811. *
  4812. * @thread_safety This function must only be called from the main thread.
  4813. *
  4814. * @sa @ref joystick_name
  4815. *
  4816. * @since Added in version 3.0.
  4817. *
  4818. * @ingroup input
  4819. */
  4820. GLFWAPI const char* glfwGetJoystickName(int jid);
  4821. /*! @brief Returns the SDL compatible GUID of the specified joystick.
  4822. *
  4823. * This function returns the SDL compatible GUID, as a UTF-8 encoded
  4824. * hexadecimal string, of the specified joystick. The returned string is
  4825. * allocated and freed by GLFW. You should not free it yourself.
  4826. *
  4827. * The GUID is what connects a joystick to a gamepad mapping. A connected
  4828. * joystick will always have a GUID even if there is no gamepad mapping
  4829. * assigned to it.
  4830. *
  4831. * If the specified joystick is not present this function will return `NULL`
  4832. * but will not generate an error. This can be used instead of first calling
  4833. * @ref glfwJoystickPresent.
  4834. *
  4835. * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
  4836. * uniquely identify the make and model of a joystick but does not identify
  4837. * a specific unit, e.g. all wired Xbox 360 controllers will have the same
  4838. * GUID on that platform. The GUID for a unit may vary between platforms
  4839. * depending on what hardware information the platform specific APIs provide.
  4840. *
  4841. * @param[in] jid The [joystick](@ref joysticks) to query.
  4842. * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
  4843. * is not present or an [error](@ref error_handling) occurred.
  4844. *
  4845. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4846. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4847. *
  4848. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4849. * should not free it yourself. It is valid until the specified joystick is
  4850. * disconnected or the library is terminated.
  4851. *
  4852. * @thread_safety This function must only be called from the main thread.
  4853. *
  4854. * @sa @ref gamepad
  4855. *
  4856. * @since Added in version 3.3.
  4857. *
  4858. * @ingroup input
  4859. */
  4860. GLFWAPI const char* glfwGetJoystickGUID(int jid);
  4861. /*! @brief Sets the user pointer of the specified joystick.
  4862. *
  4863. * This function sets the user-defined pointer of the specified joystick. The
  4864. * current value is retained until the joystick is disconnected. The initial
  4865. * value is `NULL`.
  4866. *
  4867. * This function may be called from the joystick callback, even for a joystick
  4868. * that is being disconnected.
  4869. *
  4870. * @param[in] jid The joystick whose pointer to set.
  4871. * @param[in] pointer The new value.
  4872. *
  4873. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4874. *
  4875. * @thread_safety This function may be called from any thread. Access is not
  4876. * synchronized.
  4877. *
  4878. * @sa @ref joystick_userptr
  4879. * @sa @ref glfwGetJoystickUserPointer
  4880. *
  4881. * @since Added in version 3.3.
  4882. *
  4883. * @ingroup input
  4884. */
  4885. GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
  4886. /*! @brief Returns the user pointer of the specified joystick.
  4887. *
  4888. * This function returns the current value of the user-defined pointer of the
  4889. * specified joystick. The initial value is `NULL`.
  4890. *
  4891. * This function may be called from the joystick callback, even for a joystick
  4892. * that is being disconnected.
  4893. *
  4894. * @param[in] jid The joystick whose pointer to return.
  4895. *
  4896. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4897. *
  4898. * @thread_safety This function may be called from any thread. Access is not
  4899. * synchronized.
  4900. *
  4901. * @sa @ref joystick_userptr
  4902. * @sa @ref glfwSetJoystickUserPointer
  4903. *
  4904. * @since Added in version 3.3.
  4905. *
  4906. * @ingroup input
  4907. */
  4908. GLFWAPI void* glfwGetJoystickUserPointer(int jid);
  4909. /*! @brief Returns whether the specified joystick has a gamepad mapping.
  4910. *
  4911. * This function returns whether the specified joystick is both present and has
  4912. * a gamepad mapping.
  4913. *
  4914. * If the specified joystick is present but does not have a gamepad mapping
  4915. * this function will return `GLFW_FALSE` but will not generate an error. Call
  4916. * @ref glfwJoystickPresent to check if a joystick is present regardless of
  4917. * whether it has a mapping.
  4918. *
  4919. * @param[in] jid The [joystick](@ref joysticks) to query.
  4920. * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
  4921. * or `GLFW_FALSE` otherwise.
  4922. *
  4923. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4924. * GLFW_INVALID_ENUM.
  4925. *
  4926. * @thread_safety This function must only be called from the main thread.
  4927. *
  4928. * @sa @ref gamepad
  4929. * @sa @ref glfwGetGamepadState
  4930. *
  4931. * @since Added in version 3.3.
  4932. *
  4933. * @ingroup input
  4934. */
  4935. GLFWAPI int glfwJoystickIsGamepad(int jid);
  4936. /*! @brief Sets the joystick configuration callback.
  4937. *
  4938. * This function sets the joystick configuration callback, or removes the
  4939. * currently set callback. This is called when a joystick is connected to or
  4940. * disconnected from the system.
  4941. *
  4942. * For joystick connection and disconnection events to be delivered on all
  4943. * platforms, you need to call one of the [event processing](@ref events)
  4944. * functions. Joystick disconnection may also be detected and the callback
  4945. * called by joystick functions. The function will then return whatever it
  4946. * returns if the joystick is not present.
  4947. *
  4948. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4949. * callback.
  4950. * @return The previously set callback, or `NULL` if no callback was set or the
  4951. * library had not been [initialized](@ref intro_init).
  4952. *
  4953. * @callback_signature
  4954. * @code
  4955. * void function_name(int jid, int event)
  4956. * @endcode
  4957. * For more information about the callback parameters, see the
  4958. * [function pointer type](@ref GLFWjoystickfun).
  4959. *
  4960. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4961. *
  4962. * @thread_safety This function must only be called from the main thread.
  4963. *
  4964. * @sa @ref joystick_event
  4965. *
  4966. * @since Added in version 3.2.
  4967. *
  4968. * @ingroup input
  4969. */
  4970. GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
  4971. /*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
  4972. *
  4973. * This function parses the specified ASCII encoded string and updates the
  4974. * internal list with any gamepad mappings it finds. This string may
  4975. * contain either a single gamepad mapping or many mappings separated by
  4976. * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
  4977. * source file including empty lines and comments.
  4978. *
  4979. * See @ref gamepad_mapping for a description of the format.
  4980. *
  4981. * If there is already a gamepad mapping for a given GUID in the internal list,
  4982. * it will be replaced by the one passed to this function. If the library is
  4983. * terminated and re-initialized the internal list will revert to the built-in
  4984. * default.
  4985. *
  4986. * @param[in] string The string containing the gamepad mappings.
  4987. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  4988. * [error](@ref error_handling) occurred.
  4989. *
  4990. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4991. * GLFW_INVALID_VALUE.
  4992. *
  4993. * @thread_safety This function must only be called from the main thread.
  4994. *
  4995. * @sa @ref gamepad
  4996. * @sa @ref glfwJoystickIsGamepad
  4997. * @sa @ref glfwGetGamepadName
  4998. *
  4999. * @since Added in version 3.3.
  5000. *
  5001. * @ingroup input
  5002. */
  5003. GLFWAPI int glfwUpdateGamepadMappings(const char* string);
  5004. /*! @brief Returns the human-readable gamepad name for the specified joystick.
  5005. *
  5006. * This function returns the human-readable name of the gamepad from the
  5007. * gamepad mapping assigned to the specified joystick.
  5008. *
  5009. * If the specified joystick is not present or does not have a gamepad mapping
  5010. * this function will return `NULL` but will not generate an error. Call
  5011. * @ref glfwJoystickPresent to check whether it is present regardless of
  5012. * whether it has a mapping.
  5013. *
  5014. * @param[in] jid The [joystick](@ref joysticks) to query.
  5015. * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
  5016. * joystick is not present, does not have a mapping or an
  5017. * [error](@ref error_handling) occurred.
  5018. *
  5019. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
  5020. *
  5021. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  5022. * should not free it yourself. It is valid until the specified joystick is
  5023. * disconnected, the gamepad mappings are updated or the library is terminated.
  5024. *
  5025. * @thread_safety This function must only be called from the main thread.
  5026. *
  5027. * @sa @ref gamepad
  5028. * @sa @ref glfwJoystickIsGamepad
  5029. *
  5030. * @since Added in version 3.3.
  5031. *
  5032. * @ingroup input
  5033. */
  5034. GLFWAPI const char* glfwGetGamepadName(int jid);
  5035. /*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
  5036. *
  5037. * This function retrieves the state of the specified joystick remapped to
  5038. * an Xbox-like gamepad.
  5039. *
  5040. * If the specified joystick is not present or does not have a gamepad mapping
  5041. * this function will return `GLFW_FALSE` but will not generate an error. Call
  5042. * @ref glfwJoystickPresent to check whether it is present regardless of
  5043. * whether it has a mapping.
  5044. *
  5045. * The Guide button may not be available for input as it is often hooked by the
  5046. * system or the Steam client.
  5047. *
  5048. * Not all devices have all the buttons or axes provided by @ref
  5049. * GLFWgamepadstate. Unavailable buttons and axes will always report
  5050. * `GLFW_RELEASE` and 0.0 respectively.
  5051. *
  5052. * @param[in] jid The [joystick](@ref joysticks) to query.
  5053. * @param[out] state The gamepad input state of the joystick.
  5054. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
  5055. * connected, it has no gamepad mapping or an [error](@ref error_handling)
  5056. * occurred.
  5057. *
  5058. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5059. * GLFW_INVALID_ENUM.
  5060. *
  5061. * @thread_safety This function must only be called from the main thread.
  5062. *
  5063. * @sa @ref gamepad
  5064. * @sa @ref glfwUpdateGamepadMappings
  5065. * @sa @ref glfwJoystickIsGamepad
  5066. *
  5067. * @since Added in version 3.3.
  5068. *
  5069. * @ingroup input
  5070. */
  5071. GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
  5072. /*! @brief Sets the clipboard to the specified string.
  5073. *
  5074. * This function sets the system clipboard to the specified, UTF-8 encoded
  5075. * string.
  5076. *
  5077. * @param[in] window Deprecated. Any valid window or `NULL`.
  5078. * @param[in] string A UTF-8 encoded string.
  5079. *
  5080. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5081. * GLFW_PLATFORM_ERROR.
  5082. *
  5083. * @pointer_lifetime The specified string is copied before this function
  5084. * returns.
  5085. *
  5086. * @thread_safety This function must only be called from the main thread.
  5087. *
  5088. * @sa @ref clipboard
  5089. * @sa @ref glfwGetClipboardString
  5090. *
  5091. * @since Added in version 3.0.
  5092. *
  5093. * @ingroup input
  5094. */
  5095. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  5096. /*! @brief Returns the contents of the clipboard as a string.
  5097. *
  5098. * This function returns the contents of the system clipboard, if it contains
  5099. * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
  5100. * if its contents cannot be converted, `NULL` is returned and a @ref
  5101. * GLFW_FORMAT_UNAVAILABLE error is generated.
  5102. *
  5103. * @param[in] window Deprecated. Any valid window or `NULL`.
  5104. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  5105. * if an [error](@ref error_handling) occurred.
  5106. *
  5107. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5108. * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  5109. *
  5110. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  5111. * should not free it yourself. It is valid until the next call to @ref
  5112. * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
  5113. * is terminated.
  5114. *
  5115. * @thread_safety This function must only be called from the main thread.
  5116. *
  5117. * @sa @ref clipboard
  5118. * @sa @ref glfwSetClipboardString
  5119. *
  5120. * @since Added in version 3.0.
  5121. *
  5122. * @ingroup input
  5123. */
  5124. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  5125. /*! @brief Returns the GLFW time.
  5126. *
  5127. * This function returns the current GLFW time, in seconds. Unless the time
  5128. * has been set using @ref glfwSetTime it measures time elapsed since GLFW was
  5129. * initialized.
  5130. *
  5131. * This function and @ref glfwSetTime are helper functions on top of @ref
  5132. * glfwGetTimerFrequency and @ref glfwGetTimerValue.
  5133. *
  5134. * The resolution of the timer is system dependent, but is usually on the order
  5135. * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
  5136. * time source on each supported platform.
  5137. *
  5138. * @return The current time, in seconds, or zero if an
  5139. * [error](@ref error_handling) occurred.
  5140. *
  5141. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5142. *
  5143. * @thread_safety This function may be called from any thread. Reading and
  5144. * writing of the internal base time is not atomic, so it needs to be
  5145. * externally synchronized with calls to @ref glfwSetTime.
  5146. *
  5147. * @sa @ref time
  5148. *
  5149. * @since Added in version 1.0.
  5150. *
  5151. * @ingroup input
  5152. */
  5153. GLFWAPI double glfwGetTime(void);
  5154. /*! @brief Sets the GLFW time.
  5155. *
  5156. * This function sets the current GLFW time, in seconds. The value must be
  5157. * a positive finite number less than or equal to 18446744073.0, which is
  5158. * approximately 584.5 years.
  5159. *
  5160. * This function and @ref glfwGetTime are helper functions on top of @ref
  5161. * glfwGetTimerFrequency and @ref glfwGetTimerValue.
  5162. *
  5163. * @param[in] time The new value, in seconds.
  5164. *
  5165. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5166. * GLFW_INVALID_VALUE.
  5167. *
  5168. * @remark The upper limit of GLFW time is calculated as
  5169. * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
  5170. * storing nanoseconds in 64 bits. The limit may be increased in the future.
  5171. *
  5172. * @thread_safety This function may be called from any thread. Reading and
  5173. * writing of the internal base time is not atomic, so it needs to be
  5174. * externally synchronized with calls to @ref glfwGetTime.
  5175. *
  5176. * @sa @ref time
  5177. *
  5178. * @since Added in version 2.2.
  5179. *
  5180. * @ingroup input
  5181. */
  5182. GLFWAPI void glfwSetTime(double time);
  5183. /*! @brief Returns the current value of the raw timer.
  5184. *
  5185. * This function returns the current value of the raw timer, measured in
  5186. * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
  5187. * glfwGetTimerFrequency.
  5188. *
  5189. * @return The value of the timer, or zero if an
  5190. * [error](@ref error_handling) occurred.
  5191. *
  5192. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5193. *
  5194. * @thread_safety This function may be called from any thread.
  5195. *
  5196. * @sa @ref time
  5197. * @sa @ref glfwGetTimerFrequency
  5198. *
  5199. * @since Added in version 3.2.
  5200. *
  5201. * @ingroup input
  5202. */
  5203. GLFWAPI uint64_t glfwGetTimerValue(void);
  5204. /*! @brief Returns the frequency, in Hz, of the raw timer.
  5205. *
  5206. * This function returns the frequency, in Hz, of the raw timer.
  5207. *
  5208. * @return The frequency of the timer, in Hz, or zero if an
  5209. * [error](@ref error_handling) occurred.
  5210. *
  5211. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5212. *
  5213. * @thread_safety This function may be called from any thread.
  5214. *
  5215. * @sa @ref time
  5216. * @sa @ref glfwGetTimerValue
  5217. *
  5218. * @since Added in version 3.2.
  5219. *
  5220. * @ingroup input
  5221. */
  5222. GLFWAPI uint64_t glfwGetTimerFrequency(void);
  5223. /*! @brief Makes the context of the specified window current for the calling
  5224. * thread.
  5225. *
  5226. * This function makes the OpenGL or OpenGL ES context of the specified window
  5227. * current on the calling thread. A context must only be made current on
  5228. * a single thread at a time and each thread can have only a single current
  5229. * context at a time.
  5230. *
  5231. * When moving a context between threads, you must make it non-current on the
  5232. * old thread before making it current on the new one.
  5233. *
  5234. * By default, making a context non-current implicitly forces a pipeline flush.
  5235. * On machines that support `GL_KHR_context_flush_control`, you can control
  5236. * whether a context performs this flush by setting the
  5237. * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
  5238. * hint.
  5239. *
  5240. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  5241. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  5242. * error.
  5243. *
  5244. * @param[in] window The window whose context to make current, or `NULL` to
  5245. * detach the current context.
  5246. *
  5247. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5248. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5249. *
  5250. * @thread_safety This function may be called from any thread.
  5251. *
  5252. * @sa @ref context_current
  5253. * @sa @ref glfwGetCurrentContext
  5254. *
  5255. * @since Added in version 3.0.
  5256. *
  5257. * @ingroup context
  5258. */
  5259. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  5260. /*! @brief Returns the window whose context is current on the calling thread.
  5261. *
  5262. * This function returns the window whose OpenGL or OpenGL ES context is
  5263. * current on the calling thread.
  5264. *
  5265. * @return The window whose context is current, or `NULL` if no window's
  5266. * context is current.
  5267. *
  5268. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5269. *
  5270. * @thread_safety This function may be called from any thread.
  5271. *
  5272. * @sa @ref context_current
  5273. * @sa @ref glfwMakeContextCurrent
  5274. *
  5275. * @since Added in version 3.0.
  5276. *
  5277. * @ingroup context
  5278. */
  5279. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  5280. /*! @brief Swaps the front and back buffers of the specified window.
  5281. *
  5282. * This function swaps the front and back buffers of the specified window when
  5283. * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
  5284. * zero, the GPU driver waits the specified number of screen updates before
  5285. * swapping the buffers.
  5286. *
  5287. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  5288. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  5289. * error.
  5290. *
  5291. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5292. * see `vkQueuePresentKHR` instead.
  5293. *
  5294. * @param[in] window The window whose buffers to swap.
  5295. *
  5296. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5297. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5298. *
  5299. * @remark __EGL:__ The context of the specified window must be current on the
  5300. * calling thread.
  5301. *
  5302. * @thread_safety This function may be called from any thread.
  5303. *
  5304. * @sa @ref buffer_swap
  5305. * @sa @ref glfwSwapInterval
  5306. *
  5307. * @since Added in version 1.0.
  5308. * @glfw3 Added window handle parameter.
  5309. *
  5310. * @ingroup window
  5311. */
  5312. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  5313. /*! @brief Sets the swap interval for the current context.
  5314. *
  5315. * This function sets the swap interval for the current OpenGL or OpenGL ES
  5316. * context, i.e. the number of screen updates to wait from the time @ref
  5317. * glfwSwapBuffers was called before swapping the buffers and returning. This
  5318. * is sometimes called _vertical synchronization_, _vertical retrace
  5319. * synchronization_ or just _vsync_.
  5320. *
  5321. * A context that supports either of the `WGL_EXT_swap_control_tear` and
  5322. * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
  5323. * intervals, which allows the driver to swap immediately even if a frame
  5324. * arrives a little bit late. You can check for these extensions with @ref
  5325. * glfwExtensionSupported.
  5326. *
  5327. * A context must be current on the calling thread. Calling this function
  5328. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5329. *
  5330. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5331. * see the present mode of your swapchain instead.
  5332. *
  5333. * @param[in] interval The minimum number of screen updates to wait for
  5334. * until the buffers are swapped by @ref glfwSwapBuffers.
  5335. *
  5336. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5337. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5338. *
  5339. * @remark This function is not called during context creation, leaving the
  5340. * swap interval set to whatever is the default on that platform. This is done
  5341. * because some swap interval extensions used by GLFW do not allow the swap
  5342. * interval to be reset to zero once it has been set to a non-zero value.
  5343. *
  5344. * @remark Some GPU drivers do not honor the requested swap interval, either
  5345. * because of a user setting that overrides the application's request or due to
  5346. * bugs in the driver.
  5347. *
  5348. * @thread_safety This function may be called from any thread.
  5349. *
  5350. * @sa @ref buffer_swap
  5351. * @sa @ref glfwSwapBuffers
  5352. *
  5353. * @since Added in version 1.0.
  5354. *
  5355. * @ingroup context
  5356. */
  5357. GLFWAPI void glfwSwapInterval(int interval);
  5358. /*! @brief Returns whether the specified extension is available.
  5359. *
  5360. * This function returns whether the specified
  5361. * [API extension](@ref context_glext) is supported by the current OpenGL or
  5362. * OpenGL ES context. It searches both for client API extension and context
  5363. * creation API extensions.
  5364. *
  5365. * A context must be current on the calling thread. Calling this function
  5366. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5367. *
  5368. * As this functions retrieves and searches one or more extension strings each
  5369. * call, it is recommended that you cache its results if it is going to be used
  5370. * frequently. The extension strings will not change during the lifetime of
  5371. * a context, so there is no danger in doing this.
  5372. *
  5373. * This function does not apply to Vulkan. If you are using Vulkan, see @ref
  5374. * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
  5375. * and `vkEnumerateDeviceExtensionProperties` instead.
  5376. *
  5377. * @param[in] extension The ASCII encoded name of the extension.
  5378. * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
  5379. * otherwise.
  5380. *
  5381. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5382. * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
  5383. * GLFW_PLATFORM_ERROR.
  5384. *
  5385. * @thread_safety This function may be called from any thread.
  5386. *
  5387. * @sa @ref context_glext
  5388. * @sa @ref glfwGetProcAddress
  5389. *
  5390. * @since Added in version 1.0.
  5391. *
  5392. * @ingroup context
  5393. */
  5394. GLFWAPI int glfwExtensionSupported(const char* extension);
  5395. /*! @brief Returns the address of the specified function for the current
  5396. * context.
  5397. *
  5398. * This function returns the address of the specified OpenGL or OpenGL ES
  5399. * [core or extension function](@ref context_glext), if it is supported
  5400. * by the current context.
  5401. *
  5402. * A context must be current on the calling thread. Calling this function
  5403. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5404. *
  5405. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5406. * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
  5407. * `vkGetDeviceProcAddr` instead.
  5408. *
  5409. * @param[in] procname The ASCII encoded name of the function.
  5410. * @return The address of the function, or `NULL` if an
  5411. * [error](@ref error_handling) occurred.
  5412. *
  5413. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5414. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5415. *
  5416. * @remark The address of a given function is not guaranteed to be the same
  5417. * between contexts.
  5418. *
  5419. * @remark This function may return a non-`NULL` address despite the
  5420. * associated version or extension not being available. Always check the
  5421. * context version or extension string first.
  5422. *
  5423. * @pointer_lifetime The returned function pointer is valid until the context
  5424. * is destroyed or the library is terminated.
  5425. *
  5426. * @thread_safety This function may be called from any thread.
  5427. *
  5428. * @sa @ref context_glext
  5429. * @sa @ref glfwExtensionSupported
  5430. *
  5431. * @since Added in version 1.0.
  5432. *
  5433. * @ingroup context
  5434. */
  5435. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  5436. /*! @brief Returns whether the Vulkan loader and an ICD have been found.
  5437. *
  5438. * This function returns whether the Vulkan loader and any minimally functional
  5439. * ICD have been found.
  5440. *
  5441. * The availability of a Vulkan loader and even an ICD does not by itself guarantee that
  5442. * surface creation or even instance creation is possible. Call @ref
  5443. * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
  5444. * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
  5445. * check whether a queue family of a physical device supports image presentation.
  5446. *
  5447. * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
  5448. * otherwise.
  5449. *
  5450. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5451. *
  5452. * @thread_safety This function may be called from any thread.
  5453. *
  5454. * @sa @ref vulkan_support
  5455. *
  5456. * @since Added in version 3.2.
  5457. *
  5458. * @ingroup vulkan
  5459. */
  5460. GLFWAPI int glfwVulkanSupported(void);
  5461. /*! @brief Returns the Vulkan instance extensions required by GLFW.
  5462. *
  5463. * This function returns an array of names of Vulkan instance extensions required
  5464. * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
  5465. * list will always contain `VK_KHR_surface`, so if you don't require any
  5466. * additional extensions you can pass this list directly to the
  5467. * `VkInstanceCreateInfo` struct.
  5468. *
  5469. * If Vulkan is not available on the machine, this function returns `NULL` and
  5470. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5471. * to check whether Vulkan is at least minimally available.
  5472. *
  5473. * If Vulkan is available but no set of extensions allowing window surface
  5474. * creation was found, this function returns `NULL`. You may still use Vulkan
  5475. * for off-screen rendering and compute work.
  5476. *
  5477. * @param[out] count Where to store the number of extensions in the returned
  5478. * array. This is set to zero if an error occurred.
  5479. * @return An array of ASCII encoded extension names, or `NULL` if an
  5480. * [error](@ref error_handling) occurred.
  5481. *
  5482. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5483. * GLFW_API_UNAVAILABLE.
  5484. *
  5485. * @remark Additional extensions may be required by future versions of GLFW.
  5486. * You should check if any extensions you wish to enable are already in the
  5487. * returned array, as it is an error to specify an extension more than once in
  5488. * the `VkInstanceCreateInfo` struct.
  5489. *
  5490. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  5491. * should not free it yourself. It is guaranteed to be valid only until the
  5492. * library is terminated.
  5493. *
  5494. * @thread_safety This function may be called from any thread.
  5495. *
  5496. * @sa @ref vulkan_ext
  5497. * @sa @ref glfwCreateWindowSurface
  5498. *
  5499. * @since Added in version 3.2.
  5500. *
  5501. * @ingroup vulkan
  5502. */
  5503. GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
  5504. #if defined(VK_VERSION_1_0)
  5505. /*! @brief Returns the address of the specified Vulkan instance function.
  5506. *
  5507. * This function returns the address of the specified Vulkan core or extension
  5508. * function for the specified instance. If instance is set to `NULL` it can
  5509. * return any function exported from the Vulkan loader, including at least the
  5510. * following functions:
  5511. *
  5512. * - `vkEnumerateInstanceExtensionProperties`
  5513. * - `vkEnumerateInstanceLayerProperties`
  5514. * - `vkCreateInstance`
  5515. * - `vkGetInstanceProcAddr`
  5516. *
  5517. * If Vulkan is not available on the machine, this function returns `NULL` and
  5518. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5519. * to check whether Vulkan is at least minimally available.
  5520. *
  5521. * This function is equivalent to calling `vkGetInstanceProcAddr` with
  5522. * a platform-specific query of the Vulkan loader as a fallback.
  5523. *
  5524. * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
  5525. * functions related to instance creation.
  5526. * @param[in] procname The ASCII encoded name of the function.
  5527. * @return The address of the function, or `NULL` if an
  5528. * [error](@ref error_handling) occurred.
  5529. *
  5530. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5531. * GLFW_API_UNAVAILABLE.
  5532. *
  5533. * @pointer_lifetime The returned function pointer is valid until the library
  5534. * is terminated.
  5535. *
  5536. * @thread_safety This function may be called from any thread.
  5537. *
  5538. * @sa @ref vulkan_proc
  5539. *
  5540. * @since Added in version 3.2.
  5541. *
  5542. * @ingroup vulkan
  5543. */
  5544. GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
  5545. /*! @brief Returns whether the specified queue family can present images.
  5546. *
  5547. * This function returns whether the specified queue family of the specified
  5548. * physical device supports presentation to the platform GLFW was built for.
  5549. *
  5550. * If Vulkan or the required window surface creation instance extensions are
  5551. * not available on the machine, or if the specified instance was not created
  5552. * with the required extensions, this function returns `GLFW_FALSE` and
  5553. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5554. * to check whether Vulkan is at least minimally available and @ref
  5555. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  5556. * required.
  5557. *
  5558. * @param[in] instance The instance that the physical device belongs to.
  5559. * @param[in] device The physical device that the queue family belongs to.
  5560. * @param[in] queuefamily The index of the queue family to query.
  5561. * @return `GLFW_TRUE` if the queue family supports presentation, or
  5562. * `GLFW_FALSE` otherwise.
  5563. *
  5564. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5565. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  5566. *
  5567. * @remark @macos This function currently always returns `GLFW_TRUE`, as the
  5568. * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
  5569. * a `vkGetPhysicalDevice*PresentationSupport` type function.
  5570. *
  5571. * @thread_safety This function may be called from any thread. For
  5572. * synchronization details of Vulkan objects, see the Vulkan specification.
  5573. *
  5574. * @sa @ref vulkan_present
  5575. *
  5576. * @since Added in version 3.2.
  5577. *
  5578. * @ingroup vulkan
  5579. */
  5580. GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
  5581. /*! @brief Creates a Vulkan surface for the specified window.
  5582. *
  5583. * This function creates a Vulkan surface for the specified window.
  5584. *
  5585. * If the Vulkan loader or at least one minimally functional ICD were not found,
  5586. * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
  5587. * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
  5588. * Vulkan is at least minimally available.
  5589. *
  5590. * If the required window surface creation instance extensions are not
  5591. * available or if the specified instance was not created with these extensions
  5592. * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
  5593. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
  5594. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  5595. * required.
  5596. *
  5597. * The window surface cannot be shared with another API so the window must
  5598. * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
  5599. * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
  5600. * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
  5601. *
  5602. * The window surface must be destroyed before the specified Vulkan instance.
  5603. * It is the responsibility of the caller to destroy the window surface. GLFW
  5604. * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
  5605. * surface.
  5606. *
  5607. * @param[in] instance The Vulkan instance to create the surface in.
  5608. * @param[in] window The window to create the surface for.
  5609. * @param[in] allocator The allocator to use, or `NULL` to use the default
  5610. * allocator.
  5611. * @param[out] surface Where to store the handle of the surface. This is set
  5612. * to `VK_NULL_HANDLE` if an error occurred.
  5613. * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
  5614. * [error](@ref error_handling) occurred.
  5615. *
  5616. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5617. * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
  5618. *
  5619. * @remark If an error occurs before the creation call is made, GLFW returns
  5620. * the Vulkan error code most appropriate for the error. Appropriate use of
  5621. * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
  5622. * eliminate almost all occurrences of these errors.
  5623. *
  5624. * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
  5625. * `VK_MVK_macos_surface` extension as a fallback. The name of the selected
  5626. * extension, if any, is included in the array returned by @ref
  5627. * glfwGetRequiredInstanceExtensions.
  5628. *
  5629. * @remark @macos This function creates and sets a `CAMetalLayer` instance for
  5630. * the window content view, which is required for MoltenVK to function.
  5631. *
  5632. * @thread_safety This function may be called from any thread. For
  5633. * synchronization details of Vulkan objects, see the Vulkan specification.
  5634. *
  5635. * @sa @ref vulkan_surface
  5636. * @sa @ref glfwGetRequiredInstanceExtensions
  5637. *
  5638. * @since Added in version 3.2.
  5639. *
  5640. * @ingroup vulkan
  5641. */
  5642. GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
  5643. #endif /*VK_VERSION_1_0*/
  5644. /*************************************************************************
  5645. * Global definition cleanup
  5646. *************************************************************************/
  5647. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  5648. #ifdef GLFW_WINGDIAPI_DEFINED
  5649. #undef WINGDIAPI
  5650. #undef GLFW_WINGDIAPI_DEFINED
  5651. #endif
  5652. #ifdef GLFW_CALLBACK_DEFINED
  5653. #undef CALLBACK
  5654. #undef GLFW_CALLBACK_DEFINED
  5655. #endif
  5656. /* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
  5657. * defined by some gl.h variants (OpenBSD) so define it after if needed.
  5658. */
  5659. #ifndef GLAPIENTRY
  5660. #define GLAPIENTRY APIENTRY
  5661. #endif
  5662. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  5663. #ifdef __cplusplus
  5664. }
  5665. #endif
  5666. #endif /* _glfw3_h_ */