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.

5523 lines
196KB

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