Platformer in OpenGL
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.

4248 lines
149 KiB

5 years ago
  1. /*************************************************************************
  2. * GLFW 3.2 - 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 Berglund <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. *
  46. * This is the reference documentation for OpenGL and OpenGL ES context related
  47. * functions. For more task-oriented information, see the @ref context_guide.
  48. */
  49. /*! @defgroup vulkan Vulkan reference
  50. *
  51. * This is the reference documentation for Vulkan related functions and types.
  52. * For more task-oriented information, see the @ref vulkan_guide.
  53. */
  54. /*! @defgroup init Initialization, version and error reference
  55. *
  56. * This is the reference documentation for initialization and termination of
  57. * the library, version management and error handling. For more task-oriented
  58. * information, see the @ref intro_guide.
  59. */
  60. /*! @defgroup input Input reference
  61. *
  62. * This is the reference documentation for input related functions and types.
  63. * For more task-oriented information, see the @ref input_guide.
  64. */
  65. /*! @defgroup monitor Monitor reference
  66. *
  67. * This is the reference documentation for monitor related functions and types.
  68. * For more task-oriented information, see the @ref monitor_guide.
  69. */
  70. /*! @defgroup window Window reference
  71. *
  72. * This is the reference documentation for window related functions and types,
  73. * including creation, deletion and event polling. For more task-oriented
  74. * information, see the @ref window_guide.
  75. */
  76. /*************************************************************************
  77. * Compiler- and platform-specific preprocessor work
  78. *************************************************************************/
  79. /* If we are we on Windows, we want a single define for it.
  80. */
  81. #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
  82. #define _WIN32
  83. #endif /* _WIN32 */
  84. /* It is customary to use APIENTRY for OpenGL function pointer declarations on
  85. * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
  86. */
  87. #ifndef APIENTRY
  88. #ifdef _WIN32
  89. #define APIENTRY __stdcall
  90. #else
  91. #define APIENTRY
  92. #endif
  93. #endif /* APIENTRY */
  94. /* Some Windows OpenGL headers need this.
  95. */
  96. #if !defined(WINGDIAPI) && defined(_WIN32)
  97. #define WINGDIAPI __declspec(dllimport)
  98. #define GLFW_WINGDIAPI_DEFINED
  99. #endif /* WINGDIAPI */
  100. /* Some Windows GLU headers need this.
  101. */
  102. #if !defined(CALLBACK) && defined(_WIN32)
  103. #define CALLBACK __stdcall
  104. #define GLFW_CALLBACK_DEFINED
  105. #endif /* CALLBACK */
  106. /* Include because most Windows GLU headers need wchar_t and
  107. * the OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.
  108. * Include it unconditionally to avoid surprising side-effects.
  109. */
  110. #include <stddef.h>
  111. /* Include because it is needed by Vulkan and related functions.
  112. */
  113. #include <stdint.h>
  114. /* Include the chosen client API headers.
  115. */
  116. #if defined(__APPLE__)
  117. #if defined(GLFW_INCLUDE_GLCOREARB)
  118. #include <OpenGL/gl3.h>
  119. #if defined(GLFW_INCLUDE_GLEXT)
  120. #include <OpenGL/gl3ext.h>
  121. #endif
  122. #elif !defined(GLFW_INCLUDE_NONE)
  123. #if !defined(GLFW_INCLUDE_GLEXT)
  124. #define GL_GLEXT_LEGACY
  125. #endif
  126. #include <OpenGL/gl.h>
  127. #endif
  128. #if defined(GLFW_INCLUDE_GLU)
  129. #include <OpenGL/glu.h>
  130. #endif
  131. #else
  132. #if defined(GLFW_INCLUDE_GLCOREARB)
  133. #include <GL/glcorearb.h>
  134. #elif defined(GLFW_INCLUDE_ES1)
  135. #include <GLES/gl.h>
  136. #if defined(GLFW_INCLUDE_GLEXT)
  137. #include <GLES/glext.h>
  138. #endif
  139. #elif defined(GLFW_INCLUDE_ES2)
  140. #include <GLES2/gl2.h>
  141. #if defined(GLFW_INCLUDE_GLEXT)
  142. #include <GLES2/gl2ext.h>
  143. #endif
  144. #elif defined(GLFW_INCLUDE_ES3)
  145. #include <GLES3/gl3.h>
  146. #if defined(GLFW_INCLUDE_GLEXT)
  147. #include <GLES2/gl2ext.h>
  148. #endif
  149. #elif defined(GLFW_INCLUDE_ES31)
  150. #include <GLES3/gl31.h>
  151. #if defined(GLFW_INCLUDE_GLEXT)
  152. #include <GLES2/gl2ext.h>
  153. #endif
  154. #elif defined(GLFW_INCLUDE_VULKAN)
  155. #include <vulkan/vulkan.h>
  156. #elif !defined(GLFW_INCLUDE_NONE)
  157. #include <GL/gl.h>
  158. #if defined(GLFW_INCLUDE_GLEXT)
  159. #include <GL/glext.h>
  160. #endif
  161. #endif
  162. #if defined(GLFW_INCLUDE_GLU)
  163. #include <GL/glu.h>
  164. #endif
  165. #endif
  166. #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
  167. /* GLFW_DLL must be defined by applications that are linking against the DLL
  168. * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
  169. * configuration header when compiling the DLL version of the library.
  170. */
  171. #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
  172. #endif
  173. /* GLFWAPI is used to declare public API functions for export
  174. * from the DLL / shared library / dynamic library.
  175. */
  176. #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
  177. /* We are building GLFW as a Win32 DLL */
  178. #define GLFWAPI __declspec(dllexport)
  179. #elif defined(_WIN32) && defined(GLFW_DLL)
  180. /* We are calling GLFW as a Win32 DLL */
  181. #define GLFWAPI __declspec(dllimport)
  182. #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
  183. /* We are building GLFW as a shared / dynamic library */
  184. #define GLFWAPI __attribute__((visibility("default")))
  185. #else
  186. /* We are building or calling GLFW as a static library */
  187. #define GLFWAPI
  188. #endif
  189. /*************************************************************************
  190. * GLFW API tokens
  191. *************************************************************************/
  192. /*! @name GLFW version macros
  193. * @{ */
  194. /*! @brief The major version number of the GLFW library.
  195. *
  196. * This is incremented when the API is changed in non-compatible ways.
  197. * @ingroup init
  198. */
  199. #define GLFW_VERSION_MAJOR 3
  200. /*! @brief The minor version number of the GLFW library.
  201. *
  202. * This is incremented when features are added to the API but it remains
  203. * backward-compatible.
  204. * @ingroup init
  205. */
  206. #define GLFW_VERSION_MINOR 2
  207. /*! @brief The revision number of the GLFW library.
  208. *
  209. * This is incremented when a bug fix release is made that does not contain any
  210. * API changes.
  211. * @ingroup init
  212. */
  213. #define GLFW_VERSION_REVISION 1
  214. /*! @} */
  215. /*! @name Boolean values
  216. * @{ */
  217. /*! @brief One.
  218. *
  219. * One. Seriously. You don't _need_ to use this symbol in your code. It's
  220. * just semantic sugar for the number 1. You can use `1` or `true` or `_True`
  221. * or `GL_TRUE` or whatever you want.
  222. */
  223. #define GLFW_TRUE 1
  224. /*! @brief Zero.
  225. *
  226. * Zero. Seriously. You don't _need_ to use this symbol in your code. It's
  227. * just just semantic sugar for the number 0. You can use `0` or `false` or
  228. * `_False` or `GL_FALSE` or whatever you want.
  229. */
  230. #define GLFW_FALSE 0
  231. /*! @} */
  232. /*! @name Key and button actions
  233. * @{ */
  234. /*! @brief The key or mouse button was released.
  235. *
  236. * The key or mouse button was released.
  237. *
  238. * @ingroup input
  239. */
  240. #define GLFW_RELEASE 0
  241. /*! @brief The key or mouse button was pressed.
  242. *
  243. * The key or mouse button was pressed.
  244. *
  245. * @ingroup input
  246. */
  247. #define GLFW_PRESS 1
  248. /*! @brief The key was held down until it repeated.
  249. *
  250. * The key was held down until it repeated.
  251. *
  252. * @ingroup input
  253. */
  254. #define GLFW_REPEAT 2
  255. /*! @} */
  256. /*! @defgroup keys Keyboard keys
  257. *
  258. * See [key input](@ref input_key) for how these are used.
  259. *
  260. * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
  261. * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
  262. * put in the 256+ range).
  263. *
  264. * The naming of the key codes follow these rules:
  265. * - The US keyboard layout is used
  266. * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
  267. * "3", etc.)
  268. * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
  269. * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
  270. * correspond to the Unicode standard (usually for brevity)
  271. * - Keys that lack a clear US mapping are named "WORLD_x"
  272. * - For non-printable keys, custom names are used (e.g. "F4",
  273. * "BACKSPACE", etc.)
  274. *
  275. * @ingroup input
  276. * @{
  277. */
  278. /* The unknown key */
  279. #define GLFW_KEY_UNKNOWN -1
  280. /* Printable keys */
  281. #define GLFW_KEY_SPACE 32
  282. #define GLFW_KEY_APOSTROPHE 39 /* ' */
  283. #define GLFW_KEY_COMMA 44 /* , */
  284. #define GLFW_KEY_MINUS 45 /* - */
  285. #define GLFW_KEY_PERIOD 46 /* . */
  286. #define GLFW_KEY_SLASH 47 /* / */
  287. #define GLFW_KEY_0 48
  288. #define GLFW_KEY_1 49
  289. #define GLFW_KEY_2 50
  290. #define GLFW_KEY_3 51
  291. #define GLFW_KEY_4 52
  292. #define GLFW_KEY_5 53
  293. #define GLFW_KEY_6 54
  294. #define GLFW_KEY_7 55
  295. #define GLFW_KEY_8 56
  296. #define GLFW_KEY_9 57
  297. #define GLFW_KEY_SEMICOLON 59 /* ; */
  298. #define GLFW_KEY_EQUAL 61 /* = */
  299. #define GLFW_KEY_A 65
  300. #define GLFW_KEY_B 66
  301. #define GLFW_KEY_C 67
  302. #define GLFW_KEY_D 68
  303. #define GLFW_KEY_E 69
  304. #define GLFW_KEY_F 70
  305. #define GLFW_KEY_G 71
  306. #define GLFW_KEY_H 72
  307. #define GLFW_KEY_I 73
  308. #define GLFW_KEY_J 74
  309. #define GLFW_KEY_K 75
  310. #define GLFW_KEY_L 76
  311. #define GLFW_KEY_M 77
  312. #define GLFW_KEY_N 78
  313. #define GLFW_KEY_O 79
  314. #define GLFW_KEY_P 80
  315. #define GLFW_KEY_Q 81
  316. #define GLFW_KEY_R 82
  317. #define GLFW_KEY_S 83
  318. #define GLFW_KEY_T 84
  319. #define GLFW_KEY_U 85
  320. #define GLFW_KEY_V 86
  321. #define GLFW_KEY_W 87
  322. #define GLFW_KEY_X 88
  323. #define GLFW_KEY_Y 89
  324. #define GLFW_KEY_Z 90
  325. #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
  326. #define GLFW_KEY_BACKSLASH 92 /* \ */
  327. #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
  328. #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
  329. #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
  330. #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
  331. /* Function keys */
  332. #define GLFW_KEY_ESCAPE 256
  333. #define GLFW_KEY_ENTER 257
  334. #define GLFW_KEY_TAB 258
  335. #define GLFW_KEY_BACKSPACE 259
  336. #define GLFW_KEY_INSERT 260
  337. #define GLFW_KEY_DELETE 261
  338. #define GLFW_KEY_RIGHT 262
  339. #define GLFW_KEY_LEFT 263
  340. #define GLFW_KEY_DOWN 264
  341. #define GLFW_KEY_UP 265
  342. #define GLFW_KEY_PAGE_UP 266
  343. #define GLFW_KEY_PAGE_DOWN 267
  344. #define GLFW_KEY_HOME 268
  345. #define GLFW_KEY_END 269
  346. #define GLFW_KEY_CAPS_LOCK 280
  347. #define GLFW_KEY_SCROLL_LOCK 281
  348. #define GLFW_KEY_NUM_LOCK 282
  349. #define GLFW_KEY_PRINT_SCREEN 283
  350. #define GLFW_KEY_PAUSE 284
  351. #define GLFW_KEY_F1 290
  352. #define GLFW_KEY_F2 291
  353. #define GLFW_KEY_F3 292
  354. #define GLFW_KEY_F4 293
  355. #define GLFW_KEY_F5 294
  356. #define GLFW_KEY_F6 295
  357. #define GLFW_KEY_F7 296
  358. #define GLFW_KEY_F8 297
  359. #define GLFW_KEY_F9 298
  360. #define GLFW_KEY_F10 299
  361. #define GLFW_KEY_F11 300
  362. #define GLFW_KEY_F12 301
  363. #define GLFW_KEY_F13 302
  364. #define GLFW_KEY_F14 303
  365. #define GLFW_KEY_F15 304
  366. #define GLFW_KEY_F16 305
  367. #define GLFW_KEY_F17 306
  368. #define GLFW_KEY_F18 307
  369. #define GLFW_KEY_F19 308
  370. #define GLFW_KEY_F20 309
  371. #define GLFW_KEY_F21 310
  372. #define GLFW_KEY_F22 311
  373. #define GLFW_KEY_F23 312
  374. #define GLFW_KEY_F24 313
  375. #define GLFW_KEY_F25 314
  376. #define GLFW_KEY_KP_0 320
  377. #define GLFW_KEY_KP_1 321
  378. #define GLFW_KEY_KP_2 322
  379. #define GLFW_KEY_KP_3 323
  380. #define GLFW_KEY_KP_4 324
  381. #define GLFW_KEY_KP_5 325
  382. #define GLFW_KEY_KP_6 326
  383. #define GLFW_KEY_KP_7 327
  384. #define GLFW_KEY_KP_8 328
  385. #define GLFW_KEY_KP_9 329
  386. #define GLFW_KEY_KP_DECIMAL 330
  387. #define GLFW_KEY_KP_DIVIDE 331
  388. #define GLFW_KEY_KP_MULTIPLY 332
  389. #define GLFW_KEY_KP_SUBTRACT 333
  390. #define GLFW_KEY_KP_ADD 334
  391. #define GLFW_KEY_KP_ENTER 335
  392. #define GLFW_KEY_KP_EQUAL 336
  393. #define GLFW_KEY_LEFT_SHIFT 340
  394. #define GLFW_KEY_LEFT_CONTROL 341
  395. #define GLFW_KEY_LEFT_ALT 342
  396. #define GLFW_KEY_LEFT_SUPER 343
  397. #define GLFW_KEY_RIGHT_SHIFT 344
  398. #define GLFW_KEY_RIGHT_CONTROL 345
  399. #define GLFW_KEY_RIGHT_ALT 346
  400. #define GLFW_KEY_RIGHT_SUPER 347
  401. #define GLFW_KEY_MENU 348
  402. #define GLFW_KEY_LAST GLFW_KEY_MENU
  403. /*! @} */
  404. /*! @defgroup mods Modifier key flags
  405. *
  406. * See [key input](@ref input_key) for how these are used.
  407. *
  408. * @ingroup input
  409. * @{ */
  410. /*! @brief If this bit is set one or more Shift keys were held down.
  411. */
  412. #define GLFW_MOD_SHIFT 0x0001
  413. /*! @brief If this bit is set one or more Control keys were held down.
  414. */
  415. #define GLFW_MOD_CONTROL 0x0002
  416. /*! @brief If this bit is set one or more Alt keys were held down.
  417. */
  418. #define GLFW_MOD_ALT 0x0004
  419. /*! @brief If this bit is set one or more Super keys were held down.
  420. */
  421. #define GLFW_MOD_SUPER 0x0008
  422. /*! @} */
  423. /*! @defgroup buttons Mouse buttons
  424. *
  425. * See [mouse button input](@ref input_mouse_button) for how these are used.
  426. *
  427. * @ingroup input
  428. * @{ */
  429. #define GLFW_MOUSE_BUTTON_1 0
  430. #define GLFW_MOUSE_BUTTON_2 1
  431. #define GLFW_MOUSE_BUTTON_3 2
  432. #define GLFW_MOUSE_BUTTON_4 3
  433. #define GLFW_MOUSE_BUTTON_5 4
  434. #define GLFW_MOUSE_BUTTON_6 5
  435. #define GLFW_MOUSE_BUTTON_7 6
  436. #define GLFW_MOUSE_BUTTON_8 7
  437. #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
  438. #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
  439. #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
  440. #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
  441. /*! @} */
  442. /*! @defgroup joysticks Joysticks
  443. *
  444. * See [joystick input](@ref joystick) for how these are used.
  445. *
  446. * @ingroup input
  447. * @{ */
  448. #define GLFW_JOYSTICK_1 0
  449. #define GLFW_JOYSTICK_2 1
  450. #define GLFW_JOYSTICK_3 2
  451. #define GLFW_JOYSTICK_4 3
  452. #define GLFW_JOYSTICK_5 4
  453. #define GLFW_JOYSTICK_6 5
  454. #define GLFW_JOYSTICK_7 6
  455. #define GLFW_JOYSTICK_8 7
  456. #define GLFW_JOYSTICK_9 8
  457. #define GLFW_JOYSTICK_10 9
  458. #define GLFW_JOYSTICK_11 10
  459. #define GLFW_JOYSTICK_12 11
  460. #define GLFW_JOYSTICK_13 12
  461. #define GLFW_JOYSTICK_14 13
  462. #define GLFW_JOYSTICK_15 14
  463. #define GLFW_JOYSTICK_16 15
  464. #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
  465. /*! @} */
  466. /*! @defgroup errors Error codes
  467. *
  468. * See [error handling](@ref error_handling) for how these are used.
  469. *
  470. * @ingroup init
  471. * @{ */
  472. /*! @brief GLFW has not been initialized.
  473. *
  474. * This occurs if a GLFW function was called that must not be called unless the
  475. * library is [initialized](@ref intro_init).
  476. *
  477. * @analysis Application programmer error. Initialize GLFW before calling any
  478. * function that requires initialization.
  479. */
  480. #define GLFW_NOT_INITIALIZED 0x00010001
  481. /*! @brief No context is current for this thread.
  482. *
  483. * This occurs if a GLFW function was called that needs and operates on the
  484. * current OpenGL or OpenGL ES context but no context is current on the calling
  485. * thread. One such function is @ref glfwSwapInterval.
  486. *
  487. * @analysis Application programmer error. Ensure a context is current before
  488. * calling functions that require a current context.
  489. */
  490. #define GLFW_NO_CURRENT_CONTEXT 0x00010002
  491. /*! @brief One of the arguments to the function was an invalid enum value.
  492. *
  493. * One of the arguments to the function was an invalid enum value, for example
  494. * requesting [GLFW_RED_BITS](@ref window_hints_fb) with @ref
  495. * glfwGetWindowAttrib.
  496. *
  497. * @analysis Application programmer error. Fix the offending call.
  498. */
  499. #define GLFW_INVALID_ENUM 0x00010003
  500. /*! @brief One of the arguments to the function was an invalid value.
  501. *
  502. * One of the arguments to the function was an invalid value, for example
  503. * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
  504. *
  505. * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
  506. * result in a @ref GLFW_VERSION_UNAVAILABLE error.
  507. *
  508. * @analysis Application programmer error. Fix the offending call.
  509. */
  510. #define GLFW_INVALID_VALUE 0x00010004
  511. /*! @brief A memory allocation failed.
  512. *
  513. * A memory allocation failed.
  514. *
  515. * @analysis A bug in GLFW or the underlying operating system. Report the bug
  516. * to our [issue tracker](https://github.com/glfw/glfw/issues).
  517. */
  518. #define GLFW_OUT_OF_MEMORY 0x00010005
  519. /*! @brief GLFW could not find support for the requested API on the system.
  520. *
  521. * GLFW could not find support for the requested API on the system.
  522. *
  523. * @analysis The installed graphics driver does not support the requested
  524. * API, or does not support it via the chosen context creation backend.
  525. * Below are a few examples.
  526. *
  527. * @par
  528. * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
  529. * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
  530. * a WGL or GLX extension. OS X does not provide OpenGL ES at all. The Mesa
  531. * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
  532. * driver. Older graphics drivers do not support Vulkan.
  533. */
  534. #define GLFW_API_UNAVAILABLE 0x00010006
  535. /*! @brief The requested OpenGL or OpenGL ES version is not available.
  536. *
  537. * The requested OpenGL or OpenGL ES version (including any requested context
  538. * or framebuffer hints) is not available on this machine.
  539. *
  540. * @analysis The machine does not support your requirements. If your
  541. * application is sufficiently flexible, downgrade your requirements and try
  542. * again. Otherwise, inform the user that their machine does not match your
  543. * requirements.
  544. *
  545. * @par
  546. * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
  547. * comes out before the 4.x series gets that far, also fail with this error and
  548. * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
  549. * will exist.
  550. */
  551. #define GLFW_VERSION_UNAVAILABLE 0x00010007
  552. /*! @brief A platform-specific error occurred that does not match any of the
  553. * more specific categories.
  554. *
  555. * A platform-specific error occurred that does not match any of the more
  556. * specific categories.
  557. *
  558. * @analysis A bug or configuration error in GLFW, the underlying operating
  559. * system or its drivers, or a lack of required resources. Report the issue to
  560. * our [issue tracker](https://github.com/glfw/glfw/issues).
  561. */
  562. #define GLFW_PLATFORM_ERROR 0x00010008
  563. /*! @brief The requested format is not supported or available.
  564. *
  565. * If emitted during window creation, the requested pixel format is not
  566. * supported.
  567. *
  568. * If emitted when querying the clipboard, the contents of the clipboard could
  569. * not be converted to the requested format.
  570. *
  571. * @analysis If emitted during window creation, one or more
  572. * [hard constraints](@ref window_hints_hard) did not match any of the
  573. * available pixel formats. If your application is sufficiently flexible,
  574. * downgrade your requirements and try again. Otherwise, inform the user that
  575. * their machine does not match your requirements.
  576. *
  577. * @par
  578. * If emitted when querying the clipboard, ignore the error or report it to
  579. * the user, as appropriate.
  580. */
  581. #define GLFW_FORMAT_UNAVAILABLE 0x00010009
  582. /*! @brief The specified window does not have an OpenGL or OpenGL ES context.
  583. *
  584. * A window that does not have an OpenGL or OpenGL ES context was passed to
  585. * a function that requires it to have one.
  586. *
  587. * @analysis Application programmer error. Fix the offending call.
  588. */
  589. #define GLFW_NO_WINDOW_CONTEXT 0x0001000A
  590. /*! @} */
  591. #define GLFW_FOCUSED 0x00020001
  592. #define GLFW_ICONIFIED 0x00020002
  593. #define GLFW_RESIZABLE 0x00020003
  594. #define GLFW_VISIBLE 0x00020004
  595. #define GLFW_DECORATED 0x00020005
  596. #define GLFW_AUTO_ICONIFY 0x00020006
  597. #define GLFW_FLOATING 0x00020007
  598. #define GLFW_MAXIMIZED 0x00020008
  599. #define GLFW_RED_BITS 0x00021001
  600. #define GLFW_GREEN_BITS 0x00021002
  601. #define GLFW_BLUE_BITS 0x00021003
  602. #define GLFW_ALPHA_BITS 0x00021004
  603. #define GLFW_DEPTH_BITS 0x00021005
  604. #define GLFW_STENCIL_BITS 0x00021006
  605. #define GLFW_ACCUM_RED_BITS 0x00021007
  606. #define GLFW_ACCUM_GREEN_BITS 0x00021008
  607. #define GLFW_ACCUM_BLUE_BITS 0x00021009
  608. #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
  609. #define GLFW_AUX_BUFFERS 0x0002100B
  610. #define GLFW_STEREO 0x0002100C
  611. #define GLFW_SAMPLES 0x0002100D
  612. #define GLFW_SRGB_CAPABLE 0x0002100E
  613. #define GLFW_REFRESH_RATE 0x0002100F
  614. #define GLFW_DOUBLEBUFFER 0x00021010
  615. #define GLFW_CLIENT_API 0x00022001
  616. #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
  617. #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
  618. #define GLFW_CONTEXT_REVISION 0x00022004
  619. #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
  620. #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
  621. #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
  622. #define GLFW_OPENGL_PROFILE 0x00022008
  623. #define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
  624. #define GLFW_CONTEXT_NO_ERROR 0x0002200A
  625. #define GLFW_CONTEXT_CREATION_API 0x0002200B
  626. #define GLFW_NO_API 0
  627. #define GLFW_OPENGL_API 0x00030001
  628. #define GLFW_OPENGL_ES_API 0x00030002
  629. #define GLFW_NO_ROBUSTNESS 0
  630. #define GLFW_NO_RESET_NOTIFICATION 0x00031001
  631. #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
  632. #define GLFW_OPENGL_ANY_PROFILE 0
  633. #define GLFW_OPENGL_CORE_PROFILE 0x00032001
  634. #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
  635. #define GLFW_CURSOR 0x00033001
  636. #define GLFW_STICKY_KEYS 0x00033002
  637. #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
  638. #define GLFW_CURSOR_NORMAL 0x00034001
  639. #define GLFW_CURSOR_HIDDEN 0x00034002
  640. #define GLFW_CURSOR_DISABLED 0x00034003
  641. #define GLFW_ANY_RELEASE_BEHAVIOR 0
  642. #define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
  643. #define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
  644. #define GLFW_NATIVE_CONTEXT_API 0x00036001
  645. #define GLFW_EGL_CONTEXT_API 0x00036002
  646. /*! @defgroup shapes Standard cursor shapes
  647. *
  648. * See [standard cursor creation](@ref cursor_standard) for how these are used.
  649. *
  650. * @ingroup input
  651. * @{ */
  652. /*! @brief The regular arrow cursor shape.
  653. *
  654. * The regular arrow cursor.
  655. */
  656. #define GLFW_ARROW_CURSOR 0x00036001
  657. /*! @brief The text input I-beam cursor shape.
  658. *
  659. * The text input I-beam cursor shape.
  660. */
  661. #define GLFW_IBEAM_CURSOR 0x00036002
  662. /*! @brief The crosshair shape.
  663. *
  664. * The crosshair shape.
  665. */
  666. #define GLFW_CROSSHAIR_CURSOR 0x00036003
  667. /*! @brief The hand shape.
  668. *
  669. * The hand shape.
  670. */
  671. #define GLFW_HAND_CURSOR 0x00036004
  672. /*! @brief The horizontal resize arrow shape.
  673. *
  674. * The horizontal resize arrow shape.
  675. */
  676. #define GLFW_HRESIZE_CURSOR 0x00036005
  677. /*! @brief The vertical resize arrow shape.
  678. *
  679. * The vertical resize arrow shape.
  680. */
  681. #define GLFW_VRESIZE_CURSOR 0x00036006
  682. /*! @} */
  683. #define GLFW_CONNECTED 0x00040001
  684. #define GLFW_DISCONNECTED 0x00040002
  685. #define GLFW_DONT_CARE -1
  686. /*************************************************************************
  687. * GLFW API types
  688. *************************************************************************/
  689. /*! @brief Client API function pointer type.
  690. *
  691. * Generic function pointer used for returning client API function pointers
  692. * without forcing a cast from a regular pointer.
  693. *
  694. * @sa @ref context_glext
  695. * @sa glfwGetProcAddress
  696. *
  697. * @since Added in version 3.0.
  698. * @ingroup context
  699. */
  700. typedef void (*GLFWglproc)(void);
  701. /*! @brief Vulkan API function pointer type.
  702. *
  703. * Generic function pointer used for returning Vulkan API function pointers
  704. * without forcing a cast from a regular pointer.
  705. *
  706. * @sa @ref vulkan_proc
  707. * @sa glfwGetInstanceProcAddress
  708. *
  709. * @since Added in version 3.2.
  710. *
  711. * @ingroup vulkan
  712. */
  713. typedef void (*GLFWvkproc)(void);
  714. /*! @brief Opaque monitor object.
  715. *
  716. * Opaque monitor object.
  717. *
  718. * @see @ref monitor_object
  719. *
  720. * @since Added in version 3.0.
  721. *
  722. * @ingroup monitor
  723. */
  724. typedef struct GLFWmonitor GLFWmonitor;
  725. /*! @brief Opaque window object.
  726. *
  727. * Opaque window object.
  728. *
  729. * @see @ref window_object
  730. *
  731. * @since Added in version 3.0.
  732. *
  733. * @ingroup window
  734. */
  735. typedef struct GLFWwindow GLFWwindow;
  736. /*! @brief Opaque cursor object.
  737. *
  738. * Opaque cursor object.
  739. *
  740. * @see @ref cursor_object
  741. *
  742. * @since Added in version 3.1.
  743. *
  744. * @ingroup cursor
  745. */
  746. typedef struct GLFWcursor GLFWcursor;
  747. /*! @brief The function signature for error callbacks.
  748. *
  749. * This is the function signature for error callback functions.
  750. *
  751. * @param[in] error An [error code](@ref errors).
  752. * @param[in] description A UTF-8 encoded string describing the error.
  753. *
  754. * @sa @ref error_handling
  755. * @sa glfwSetErrorCallback
  756. *
  757. * @since Added in version 3.0.
  758. *
  759. * @ingroup init
  760. */
  761. typedef void (* GLFWerrorfun)(int,const char*);
  762. /*! @brief The function signature for window position callbacks.
  763. *
  764. * This is the function signature for window position callback functions.
  765. *
  766. * @param[in] window The window that was moved.
  767. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  768. * upper-left corner of the client area of the window.
  769. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  770. * upper-left corner of the client area of the window.
  771. *
  772. * @sa @ref window_pos
  773. * @sa glfwSetWindowPosCallback
  774. *
  775. * @since Added in version 3.0.
  776. *
  777. * @ingroup window
  778. */
  779. typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
  780. /*! @brief The function signature for window resize callbacks.
  781. *
  782. * This is the function signature for window size callback functions.
  783. *
  784. * @param[in] window The window that was resized.
  785. * @param[in] width The new width, in screen coordinates, of the window.
  786. * @param[in] height The new height, in screen coordinates, of the window.
  787. *
  788. * @sa @ref window_size
  789. * @sa glfwSetWindowSizeCallback
  790. *
  791. * @since Added in version 1.0.
  792. * @glfw3 Added window handle parameter.
  793. *
  794. * @ingroup window
  795. */
  796. typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
  797. /*! @brief The function signature for window close callbacks.
  798. *
  799. * This is the function signature for window close callback functions.
  800. *
  801. * @param[in] window The window that the user attempted to close.
  802. *
  803. * @sa @ref window_close
  804. * @sa glfwSetWindowCloseCallback
  805. *
  806. * @since Added in version 2.5.
  807. * @glfw3 Added window handle parameter.
  808. *
  809. * @ingroup window
  810. */
  811. typedef void (* GLFWwindowclosefun)(GLFWwindow*);
  812. /*! @brief The function signature for window content refresh callbacks.
  813. *
  814. * This is the function signature for window refresh callback functions.
  815. *
  816. * @param[in] window The window whose content needs to be refreshed.
  817. *
  818. * @sa @ref window_refresh
  819. * @sa glfwSetWindowRefreshCallback
  820. *
  821. * @since Added in version 2.5.
  822. * @glfw3 Added window handle parameter.
  823. *
  824. * @ingroup window
  825. */
  826. typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
  827. /*! @brief The function signature for window focus/defocus callbacks.
  828. *
  829. * This is the function signature for window focus callback functions.
  830. *
  831. * @param[in] window The window that gained or lost input focus.
  832. * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
  833. * `GLFW_FALSE` if it lost it.
  834. *
  835. * @sa @ref window_focus
  836. * @sa glfwSetWindowFocusCallback
  837. *
  838. * @since Added in version 3.0.
  839. *
  840. * @ingroup window
  841. */
  842. typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
  843. /*! @brief The function signature for window iconify/restore callbacks.
  844. *
  845. * This is the function signature for window iconify/restore callback
  846. * functions.
  847. *
  848. * @param[in] window The window that was iconified or restored.
  849. * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
  850. * `GLFW_FALSE` if it was restored.
  851. *
  852. * @sa @ref window_iconify
  853. * @sa glfwSetWindowIconifyCallback
  854. *
  855. * @since Added in version 3.0.
  856. *
  857. * @ingroup window
  858. */
  859. typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
  860. /*! @brief The function signature for framebuffer resize callbacks.
  861. *
  862. * This is the function signature for framebuffer resize callback
  863. * functions.
  864. *
  865. * @param[in] window The window whose framebuffer was resized.
  866. * @param[in] width The new width, in pixels, of the framebuffer.
  867. * @param[in] height The new height, in pixels, of the framebuffer.
  868. *
  869. * @sa @ref window_fbsize
  870. * @sa glfwSetFramebufferSizeCallback
  871. *
  872. * @since Added in version 3.0.
  873. *
  874. * @ingroup window
  875. */
  876. typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
  877. /*! @brief The function signature for mouse button callbacks.
  878. *
  879. * This is the function signature for mouse button callback functions.
  880. *
  881. * @param[in] window The window that received the event.
  882. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  883. * released.
  884. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
  885. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  886. * held down.
  887. *
  888. * @sa @ref input_mouse_button
  889. * @sa glfwSetMouseButtonCallback
  890. *
  891. * @since Added in version 1.0.
  892. * @glfw3 Added window handle and modifier mask parameters.
  893. *
  894. * @ingroup input
  895. */
  896. typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
  897. /*! @brief The function signature for cursor position callbacks.
  898. *
  899. * This is the function signature for cursor position callback functions.
  900. *
  901. * @param[in] window The window that received the event.
  902. * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
  903. * the client area.
  904. * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
  905. * client area.
  906. *
  907. * @sa @ref cursor_pos
  908. * @sa glfwSetCursorPosCallback
  909. *
  910. * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
  911. *
  912. * @ingroup input
  913. */
  914. typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
  915. /*! @brief The function signature for cursor enter/leave callbacks.
  916. *
  917. * This is the function signature for cursor enter/leave callback functions.
  918. *
  919. * @param[in] window The window that received the event.
  920. * @param[in] entered `GLFW_TRUE` if the cursor entered the window's client
  921. * area, or `GLFW_FALSE` if it left it.
  922. *
  923. * @sa @ref cursor_enter
  924. * @sa glfwSetCursorEnterCallback
  925. *
  926. * @since Added in version 3.0.
  927. *
  928. * @ingroup input
  929. */
  930. typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
  931. /*! @brief The function signature for scroll callbacks.
  932. *
  933. * This is the function signature for scroll callback functions.
  934. *
  935. * @param[in] window The window that received the event.
  936. * @param[in] xoffset The scroll offset along the x-axis.
  937. * @param[in] yoffset The scroll offset along the y-axis.
  938. *
  939. * @sa @ref scrolling
  940. * @sa glfwSetScrollCallback
  941. *
  942. * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
  943. *
  944. * @ingroup input
  945. */
  946. typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
  947. /*! @brief The function signature for keyboard key callbacks.
  948. *
  949. * This is the function signature for keyboard key callback functions.
  950. *
  951. * @param[in] window The window that received the event.
  952. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
  953. * @param[in] scancode The system-specific scancode of the key.
  954. * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.
  955. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  956. * held down.
  957. *
  958. * @sa @ref input_key
  959. * @sa glfwSetKeyCallback
  960. *
  961. * @since Added in version 1.0.
  962. * @glfw3 Added window handle, scancode and modifier mask parameters.
  963. *
  964. * @ingroup input
  965. */
  966. typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
  967. /*! @brief The function signature for Unicode character callbacks.
  968. *
  969. * This is the function signature for Unicode character callback functions.
  970. *
  971. * @param[in] window The window that received the event.
  972. * @param[in] codepoint The Unicode code point of the character.
  973. *
  974. * @sa @ref input_char
  975. * @sa glfwSetCharCallback
  976. *
  977. * @since Added in version 2.4.
  978. * @glfw3 Added window handle parameter.
  979. *
  980. * @ingroup input
  981. */
  982. typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
  983. /*! @brief The function signature for Unicode character with modifiers
  984. * callbacks.
  985. *
  986. * This is the function signature for Unicode character with modifiers callback
  987. * functions. It is called for each input character, regardless of what
  988. * modifier keys are held down.
  989. *
  990. * @param[in] window The window that received the event.
  991. * @param[in] codepoint The Unicode code point of the character.
  992. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  993. * held down.
  994. *
  995. * @sa @ref input_char
  996. * @sa glfwSetCharModsCallback
  997. *
  998. * @since Added in version 3.1.
  999. *
  1000. * @ingroup input
  1001. */
  1002. typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
  1003. /*! @brief The function signature for file drop callbacks.
  1004. *
  1005. * This is the function signature for file drop callbacks.
  1006. *
  1007. * @param[in] window The window that received the event.
  1008. * @param[in] count The number of dropped files.
  1009. * @param[in] paths The UTF-8 encoded file and/or directory path names.
  1010. *
  1011. * @sa @ref path_drop
  1012. * @sa glfwSetDropCallback
  1013. *
  1014. * @since Added in version 3.1.
  1015. *
  1016. * @ingroup input
  1017. */
  1018. typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);
  1019. /*! @brief The function signature for monitor configuration callbacks.
  1020. *
  1021. * This is the function signature for monitor configuration callback functions.
  1022. *
  1023. * @param[in] monitor The monitor that was connected or disconnected.
  1024. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
  1025. *
  1026. * @sa @ref monitor_event
  1027. * @sa glfwSetMonitorCallback
  1028. *
  1029. * @since Added in version 3.0.
  1030. *
  1031. * @ingroup monitor
  1032. */
  1033. typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
  1034. /*! @brief The function signature for joystick configuration callbacks.
  1035. *
  1036. * This is the function signature for joystick configuration callback
  1037. * functions.
  1038. *
  1039. * @param[in] joy The joystick that was connected or disconnected.
  1040. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
  1041. *
  1042. * @sa @ref joystick_event
  1043. * @sa glfwSetJoystickCallback
  1044. *
  1045. * @since Added in version 3.2.
  1046. *
  1047. * @ingroup input
  1048. */
  1049. typedef void (* GLFWjoystickfun)(int,int);
  1050. /*! @brief Video mode type.
  1051. *
  1052. * This describes a single video mode.
  1053. *
  1054. * @sa @ref monitor_modes
  1055. * @sa glfwGetVideoMode glfwGetVideoModes
  1056. *
  1057. * @since Added in version 1.0.
  1058. * @glfw3 Added refresh rate member.
  1059. *
  1060. * @ingroup monitor
  1061. */
  1062. typedef struct GLFWvidmode
  1063. {
  1064. /*! The width, in screen coordinates, of the video mode.
  1065. */
  1066. int width;
  1067. /*! The height, in screen coordinates, of the video mode.
  1068. */
  1069. int height;
  1070. /*! The bit depth of the red channel of the video mode.
  1071. */
  1072. int redBits;
  1073. /*! The bit depth of the green channel of the video mode.
  1074. */
  1075. int greenBits;
  1076. /*! The bit depth of the blue channel of the video mode.
  1077. */
  1078. int blueBits;
  1079. /*! The refresh rate, in Hz, of the video mode.
  1080. */
  1081. int refreshRate;
  1082. } GLFWvidmode;
  1083. /*! @brief Gamma ramp.
  1084. *
  1085. * This describes the gamma ramp for a monitor.
  1086. *
  1087. * @sa @ref monitor_gamma
  1088. * @sa glfwGetGammaRamp glfwSetGammaRamp
  1089. *
  1090. * @since Added in version 3.0.
  1091. *
  1092. * @ingroup monitor
  1093. */
  1094. typedef struct GLFWgammaramp
  1095. {
  1096. /*! An array of value describing the response of the red channel.
  1097. */
  1098. unsigned short* red;
  1099. /*! An array of value describing the response of the green channel.
  1100. */
  1101. unsigned short* green;
  1102. /*! An array of value describing the response of the blue channel.
  1103. */
  1104. unsigned short* blue;
  1105. /*! The number of elements in each array.
  1106. */
  1107. unsigned int size;
  1108. } GLFWgammaramp;
  1109. /*! @brief Image data.
  1110. *
  1111. * @sa @ref cursor_custom
  1112. * @sa @ref window_icon
  1113. *
  1114. * @since Added in version 2.1.
  1115. * @glfw3 Removed format and bytes-per-pixel members.
  1116. */
  1117. typedef struct GLFWimage
  1118. {
  1119. /*! The width, in pixels, of this image.
  1120. */
  1121. int width;
  1122. /*! The height, in pixels, of this image.
  1123. */
  1124. int height;
  1125. /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
  1126. */
  1127. unsigned char* pixels;
  1128. } GLFWimage;
  1129. /*************************************************************************
  1130. * GLFW API functions
  1131. *************************************************************************/
  1132. /*! @brief Initializes the GLFW library.
  1133. *
  1134. * This function initializes the GLFW library. Before most GLFW functions can
  1135. * be used, GLFW must be initialized, and before an application terminates GLFW
  1136. * should be terminated in order to free any resources allocated during or
  1137. * after initialization.
  1138. *
  1139. * If this function fails, it calls @ref glfwTerminate before returning. If it
  1140. * succeeds, you should call @ref glfwTerminate before the application exits.
  1141. *
  1142. * Additional calls to this function after successful initialization but before
  1143. * termination will return `GLFW_TRUE` immediately.
  1144. *
  1145. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  1146. * [error](@ref error_handling) occurred.
  1147. *
  1148. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1149. *
  1150. * @remark @osx This function will change the current directory of the
  1151. * application to the `Contents/Resources` subdirectory of the application's
  1152. * bundle, if present. This can be disabled with a
  1153. * [compile-time option](@ref compile_options_osx).
  1154. *
  1155. * @thread_safety This function must only be called from the main thread.
  1156. *
  1157. * @sa @ref intro_init
  1158. * @sa glfwTerminate
  1159. *
  1160. * @since Added in version 1.0.
  1161. *
  1162. * @ingroup init
  1163. */
  1164. GLFWAPI int glfwInit(void);
  1165. /*! @brief Terminates the GLFW library.
  1166. *
  1167. * This function destroys all remaining windows and cursors, restores any
  1168. * modified gamma ramps and frees any other allocated resources. Once this
  1169. * function is called, you must again call @ref glfwInit successfully before
  1170. * you will be able to use most GLFW functions.
  1171. *
  1172. * If GLFW has been successfully initialized, this function should be called
  1173. * before the application exits. If initialization fails, there is no need to
  1174. * call this function, as it is called by @ref glfwInit before it returns
  1175. * failure.
  1176. *
  1177. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1178. *
  1179. * @remark This function may be called before @ref glfwInit.
  1180. *
  1181. * @warning The contexts of any remaining windows must not be current on any
  1182. * other thread when this function is called.
  1183. *
  1184. * @reentrancy This function must not be called from a callback.
  1185. *
  1186. * @thread_safety This function must only be called from the main thread.
  1187. *
  1188. * @sa @ref intro_init
  1189. * @sa glfwInit
  1190. *
  1191. * @since Added in version 1.0.
  1192. *
  1193. * @ingroup init
  1194. */
  1195. GLFWAPI void glfwTerminate(void);
  1196. /*! @brief Retrieves the version of the GLFW library.
  1197. *
  1198. * This function retrieves the major, minor and revision numbers of the GLFW
  1199. * library. It is intended for when you are using GLFW as a shared library and
  1200. * want to ensure that you are using the minimum required version.
  1201. *
  1202. * Any or all of the version arguments may be `NULL`.
  1203. *
  1204. * @param[out] major Where to store the major version number, or `NULL`.
  1205. * @param[out] minor Where to store the minor version number, or `NULL`.
  1206. * @param[out] rev Where to store the revision number, or `NULL`.
  1207. *
  1208. * @errors None.
  1209. *
  1210. * @remark This function may be called before @ref glfwInit.
  1211. *
  1212. * @thread_safety This function may be called from any thread.
  1213. *
  1214. * @sa @ref intro_version
  1215. * @sa glfwGetVersionString
  1216. *
  1217. * @since Added in version 1.0.
  1218. *
  1219. * @ingroup init
  1220. */
  1221. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  1222. /*! @brief Returns a string describing the compile-time configuration.
  1223. *
  1224. * This function returns the compile-time generated
  1225. * [version string](@ref intro_version_string) of the GLFW library binary. It
  1226. * describes the version, platform, compiler and any platform-specific
  1227. * compile-time options. It should not be confused with the OpenGL or OpenGL
  1228. * ES version string, queried with `glGetString`.
  1229. *
  1230. * __Do not use the version string__ to parse the GLFW library version. The
  1231. * @ref glfwGetVersion function provides the version of the running library
  1232. * binary in numerical format.
  1233. *
  1234. * @return The ASCII encoded GLFW version string.
  1235. *
  1236. * @errors None.
  1237. *
  1238. * @remark This function may be called before @ref glfwInit.
  1239. *
  1240. * @pointer_lifetime The returned string is static and compile-time generated.
  1241. *
  1242. * @thread_safety This function may be called from any thread.
  1243. *
  1244. * @sa @ref intro_version
  1245. * @sa glfwGetVersion
  1246. *
  1247. * @since Added in version 3.0.
  1248. *
  1249. * @ingroup init
  1250. */
  1251. GLFWAPI const char* glfwGetVersionString(void);
  1252. /*! @brief Sets the error callback.
  1253. *
  1254. * This function sets the error callback, which is called with an error code
  1255. * and a human-readable description each time a GLFW error occurs.
  1256. *
  1257. * The error callback is called on the thread where the error occurred. If you
  1258. * are using GLFW from multiple threads, your error callback needs to be
  1259. * written accordingly.
  1260. *
  1261. * Because the description string may have been generated specifically for that
  1262. * error, it is not guaranteed to be valid after the callback has returned. If
  1263. * you wish to use it after the callback returns, you need to make a copy.
  1264. *
  1265. * Once set, the error callback remains set even after the library has been
  1266. * terminated.
  1267. *
  1268. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1269. * callback.
  1270. * @return The previously set callback, or `NULL` if no callback was set.
  1271. *
  1272. * @errors None.
  1273. *
  1274. * @remark This function may be called before @ref glfwInit.
  1275. *
  1276. * @thread_safety This function must only be called from the main thread.
  1277. *
  1278. * @sa @ref error_handling
  1279. *
  1280. * @since Added in version 3.0.
  1281. *
  1282. * @ingroup init
  1283. */
  1284. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
  1285. /*! @brief Returns the currently connected monitors.
  1286. *
  1287. * This function returns an array of handles for all currently connected
  1288. * monitors. The primary monitor is always first in the returned array. If no
  1289. * monitors were found, this function returns `NULL`.
  1290. *
  1291. * @param[out] count Where to store the number of monitors in the returned
  1292. * array. This is set to zero if an error occurred.
  1293. * @return An array of monitor handles, or `NULL` if no monitors were found or
  1294. * if an [error](@ref error_handling) occurred.
  1295. *
  1296. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1297. *
  1298. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1299. * should not free it yourself. It is guaranteed to be valid only until the
  1300. * monitor configuration changes or the library is terminated.
  1301. *
  1302. * @thread_safety This function must only be called from the main thread.
  1303. *
  1304. * @sa @ref monitor_monitors
  1305. * @sa @ref monitor_event
  1306. * @sa glfwGetPrimaryMonitor
  1307. *
  1308. * @since Added in version 3.0.
  1309. *
  1310. * @ingroup monitor
  1311. */
  1312. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  1313. /*! @brief Returns the primary monitor.
  1314. *
  1315. * This function returns the primary monitor. This is usually the monitor
  1316. * where elements like the task bar or global menu bar are located.
  1317. *
  1318. * @return The primary monitor, or `NULL` if no monitors were found or if an
  1319. * [error](@ref error_handling) occurred.
  1320. *
  1321. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1322. *
  1323. * @thread_safety This function must only be called from the main thread.
  1324. *
  1325. * @remark The primary monitor is always first in the array returned by @ref
  1326. * glfwGetMonitors.
  1327. *
  1328. * @sa @ref monitor_monitors
  1329. * @sa glfwGetMonitors
  1330. *
  1331. * @since Added in version 3.0.
  1332. *
  1333. * @ingroup monitor
  1334. */
  1335. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  1336. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  1337. *
  1338. * This function returns the position, in screen coordinates, of the upper-left
  1339. * corner of the specified monitor.
  1340. *
  1341. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1342. * non-`NULL` position arguments will be set to zero.
  1343. *
  1344. * @param[in] monitor The monitor to query.
  1345. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  1346. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  1347. *
  1348. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1349. * GLFW_PLATFORM_ERROR.
  1350. *
  1351. * @thread_safety This function must only be called from the main thread.
  1352. *
  1353. * @sa @ref monitor_properties
  1354. *
  1355. * @since Added in version 3.0.
  1356. *
  1357. * @ingroup monitor
  1358. */
  1359. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  1360. /*! @brief Returns the physical size of the monitor.
  1361. *
  1362. * This function returns the size, in millimetres, of the display area of the
  1363. * specified monitor.
  1364. *
  1365. * Some systems do not provide accurate monitor size information, either
  1366. * because the monitor
  1367. * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
  1368. * data is incorrect or because the driver does not report it accurately.
  1369. *
  1370. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1371. * non-`NULL` size arguments will be set to zero.
  1372. *
  1373. * @param[in] monitor The monitor to query.
  1374. * @param[out] widthMM Where to store the width, in millimetres, of the
  1375. * monitor's display area, or `NULL`.
  1376. * @param[out] heightMM Where to store the height, in millimetres, of the
  1377. * monitor's display area, or `NULL`.
  1378. *
  1379. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1380. *
  1381. * @remark @win32 calculates the returned physical size from the
  1382. * current resolution and system DPI instead of querying the monitor EDID data.
  1383. *
  1384. * @thread_safety This function must only be called from the main thread.
  1385. *
  1386. * @sa @ref monitor_properties
  1387. *
  1388. * @since Added in version 3.0.
  1389. *
  1390. * @ingroup monitor
  1391. */
  1392. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
  1393. /*! @brief Returns the name of the specified monitor.
  1394. *
  1395. * This function returns a human-readable name, encoded as UTF-8, of the
  1396. * specified monitor. The name typically reflects the make and model of the
  1397. * monitor and is not guaranteed to be unique among the connected monitors.
  1398. *
  1399. * @param[in] monitor The monitor to query.
  1400. * @return The UTF-8 encoded name of the monitor, or `NULL` if an
  1401. * [error](@ref error_handling) occurred.
  1402. *
  1403. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1404. *
  1405. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  1406. * should not free it yourself. It is valid until the specified monitor is
  1407. * disconnected or the library is terminated.
  1408. *
  1409. * @thread_safety This function must only be called from the main thread.
  1410. *
  1411. * @sa @ref monitor_properties
  1412. *
  1413. * @since Added in version 3.0.
  1414. *
  1415. * @ingroup monitor
  1416. */
  1417. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  1418. /*! @brief Sets the monitor configuration callback.
  1419. *
  1420. * This function sets the monitor configuration callback, or removes the
  1421. * currently set callback. This is called when a monitor is connected to or
  1422. * disconnected from the system.
  1423. *
  1424. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1425. * callback.
  1426. * @return The previously set callback, or `NULL` if no callback was set or the
  1427. * library had not been [initialized](@ref intro_init).
  1428. *
  1429. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1430. *
  1431. * @thread_safety This function must only be called from the main thread.
  1432. *
  1433. * @sa @ref monitor_event
  1434. *
  1435. * @since Added in version 3.0.
  1436. *
  1437. * @ingroup monitor
  1438. */
  1439. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
  1440. /*! @brief Returns the available video modes for the specified monitor.
  1441. *
  1442. * This function returns an array of all video modes supported by the specified
  1443. * monitor. The returned array is sorted in ascending order, first by color
  1444. * bit depth (the sum of all channel depths) and then by resolution area (the
  1445. * product of width and height).
  1446. *
  1447. * @param[in] monitor The monitor to query.
  1448. * @param[out] count Where to store the number of video modes in the returned
  1449. * array. This is set to zero if an error occurred.
  1450. * @return An array of video modes, or `NULL` if an
  1451. * [error](@ref error_handling) occurred.
  1452. *
  1453. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1454. * GLFW_PLATFORM_ERROR.
  1455. *
  1456. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1457. * should not free it yourself. It is valid until the specified monitor is
  1458. * disconnected, this function is called again for that monitor or the library
  1459. * is terminated.
  1460. *
  1461. * @thread_safety This function must only be called from the main thread.
  1462. *
  1463. * @sa @ref monitor_modes
  1464. * @sa glfwGetVideoMode
  1465. *
  1466. * @since Added in version 1.0.
  1467. * @glfw3 Changed to return an array of modes for a specific monitor.
  1468. *
  1469. * @ingroup monitor
  1470. */
  1471. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  1472. /*! @brief Returns the current mode of the specified monitor.
  1473. *
  1474. * This function returns the current video mode of the specified monitor. If
  1475. * you have created a full screen window for that monitor, the return value
  1476. * will depend on whether that window is iconified.
  1477. *
  1478. * @param[in] monitor The monitor to query.
  1479. * @return The current mode of the monitor, or `NULL` if an
  1480. * [error](@ref error_handling) occurred.
  1481. *
  1482. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1483. * GLFW_PLATFORM_ERROR.
  1484. *
  1485. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1486. * should not free it yourself. It is valid until the specified monitor is
  1487. * disconnected or the library is terminated.
  1488. *
  1489. * @thread_safety This function must only be called from the main thread.
  1490. *
  1491. * @sa @ref monitor_modes
  1492. * @sa glfwGetVideoModes
  1493. *
  1494. * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
  1495. *
  1496. * @ingroup monitor
  1497. */
  1498. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  1499. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  1500. *
  1501. * This function generates a 256-element gamma ramp from the specified exponent
  1502. * and then calls @ref glfwSetGammaRamp with it. The value must be a finite
  1503. * number greater than zero.
  1504. *
  1505. * @param[in] monitor The monitor whose gamma ramp to set.
  1506. * @param[in] gamma The desired exponent.
  1507. *
  1508. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  1509. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  1510. *
  1511. * @thread_safety This function must only be called from the main thread.
  1512. *
  1513. * @sa @ref monitor_gamma
  1514. *
  1515. * @since Added in version 3.0.
  1516. *
  1517. * @ingroup monitor
  1518. */
  1519. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  1520. /*! @brief Returns the current gamma ramp for the specified monitor.
  1521. *
  1522. * This function returns the current gamma ramp of the specified monitor.
  1523. *
  1524. * @param[in] monitor The monitor to query.
  1525. * @return The current gamma ramp, or `NULL` if an
  1526. * [error](@ref error_handling) occurred.
  1527. *
  1528. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1529. * GLFW_PLATFORM_ERROR.
  1530. *
  1531. * @pointer_lifetime The returned structure and its arrays are allocated and
  1532. * freed by GLFW. You should not free them yourself. They are valid until the
  1533. * specified monitor is disconnected, this function is called again for that
  1534. * monitor or the library is terminated.
  1535. *
  1536. * @thread_safety This function must only be called from the main thread.
  1537. *
  1538. * @sa @ref monitor_gamma
  1539. *
  1540. * @since Added in version 3.0.
  1541. *
  1542. * @ingroup monitor
  1543. */
  1544. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  1545. /*! @brief Sets the current gamma ramp for the specified monitor.
  1546. *
  1547. * This function sets the current gamma ramp for the specified monitor. The
  1548. * original gamma ramp for that monitor is saved by GLFW the first time this
  1549. * function is called and is restored by @ref glfwTerminate.
  1550. *
  1551. * @param[in] monitor The monitor whose gamma ramp to set.
  1552. * @param[in] ramp The gamma ramp to use.
  1553. *
  1554. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1555. * GLFW_PLATFORM_ERROR.
  1556. *
  1557. * @remark Gamma ramp sizes other than 256 are not supported by all platforms
  1558. * or graphics hardware.
  1559. *
  1560. * @remark @win32 The gamma ramp size must be 256.
  1561. *
  1562. * @pointer_lifetime The specified gamma ramp is copied before this function
  1563. * returns.
  1564. *
  1565. * @thread_safety This function must only be called from the main thread.
  1566. *
  1567. * @sa @ref monitor_gamma
  1568. *
  1569. * @since Added in version 3.0.
  1570. *
  1571. * @ingroup monitor
  1572. */
  1573. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  1574. /*! @brief Resets all window hints to their default values.
  1575. *
  1576. * This function resets all window hints to their
  1577. * [default values](@ref window_hints_values).
  1578. *
  1579. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1580. *
  1581. * @thread_safety This function must only be called from the main thread.
  1582. *
  1583. * @sa @ref window_hints
  1584. * @sa glfwWindowHint
  1585. *
  1586. * @since Added in version 3.0.
  1587. *
  1588. * @ingroup window
  1589. */
  1590. GLFWAPI void glfwDefaultWindowHints(void);
  1591. /*! @brief Sets the specified window hint to the desired value.
  1592. *
  1593. * This function sets hints for the next call to @ref glfwCreateWindow. The
  1594. * hints, once set, retain their values until changed by a call to @ref
  1595. * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
  1596. * terminated.
  1597. *
  1598. * This function does not check whether the specified hint values are valid.
  1599. * If you set hints to invalid values this will instead be reported by the next
  1600. * call to @ref glfwCreateWindow.
  1601. *
  1602. * @param[in] hint The [window hint](@ref window_hints) to set.
  1603. * @param[in] value The new value of the window hint.
  1604. *
  1605. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1606. * GLFW_INVALID_ENUM.
  1607. *
  1608. * @thread_safety This function must only be called from the main thread.
  1609. *
  1610. * @sa @ref window_hints
  1611. * @sa glfwDefaultWindowHints
  1612. *
  1613. * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
  1614. *
  1615. * @ingroup window
  1616. */
  1617. GLFWAPI void glfwWindowHint(int hint, int value);
  1618. /*! @brief Creates a window and its associated context.
  1619. *
  1620. * This function creates a window and its associated OpenGL or OpenGL ES
  1621. * context. Most of the options controlling how the window and its context
  1622. * should be created are specified with [window hints](@ref window_hints).
  1623. *
  1624. * Successful creation does not change which context is current. Before you
  1625. * can use the newly created context, you need to
  1626. * [make it current](@ref context_current). For information about the `share`
  1627. * parameter, see @ref context_sharing.
  1628. *
  1629. * The created window, framebuffer and context may differ from what you
  1630. * requested, as not all parameters and hints are
  1631. * [hard constraints](@ref window_hints_hard). This includes the size of the
  1632. * window, especially for full screen windows. To query the actual attributes
  1633. * of the created window, framebuffer and context, see @ref
  1634. * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
  1635. *
  1636. * To create a full screen window, you need to specify the monitor the window
  1637. * will cover. If no monitor is specified, the window will be windowed mode.
  1638. * Unless you have a way for the user to choose a specific monitor, it is
  1639. * recommended that you pick the primary monitor. For more information on how
  1640. * to query connected monitors, see @ref monitor_monitors.
  1641. *
  1642. * For full screen windows, the specified size becomes the resolution of the
  1643. * window's _desired video mode_. As long as a full screen window is not
  1644. * iconified, the supported video mode most closely matching the desired video
  1645. * mode is set for the specified monitor. For more information about full
  1646. * screen windows, including the creation of so called _windowed full screen_
  1647. * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
  1648. *
  1649. * Once you have created the window, you can switch it between windowed and
  1650. * full screen mode with @ref glfwSetWindowMonitor. If the window has an
  1651. * OpenGL or OpenGL ES context, it will be unaffected.
  1652. *
  1653. * By default, newly created windows use the placement recommended by the
  1654. * window system. To create the window at a specific position, make it
  1655. * initially invisible using the [GLFW_VISIBLE](@ref window_hints_wnd) window
  1656. * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
  1657. * it.
  1658. *
  1659. * As long as at least one full screen window is not iconified, the screensaver
  1660. * is prohibited from starting.
  1661. *
  1662. * Window systems put limits on window sizes. Very large or very small window
  1663. * dimensions may be overridden by the window system on creation. Check the
  1664. * actual [size](@ref window_size) after creation.
  1665. *
  1666. * The [swap interval](@ref buffer_swap) is not set during window creation and
  1667. * the initial value may vary depending on driver settings and defaults.
  1668. *
  1669. * @param[in] width The desired width, in screen coordinates, of the window.
  1670. * This must be greater than zero.
  1671. * @param[in] height The desired height, in screen coordinates, of the window.
  1672. * This must be greater than zero.
  1673. * @param[in] title The initial, UTF-8 encoded window title.
  1674. * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
  1675. * windowed mode.
  1676. * @param[in] share The window whose context to share resources with, or `NULL`
  1677. * to not share resources.
  1678. * @return The handle of the created window, or `NULL` if an
  1679. * [error](@ref error_handling) occurred.
  1680. *
  1681. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  1682. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
  1683. * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
  1684. * GLFW_PLATFORM_ERROR.
  1685. *
  1686. * @remark @win32 Window creation will fail if the Microsoft GDI software
  1687. * OpenGL implementation is the only one available.
  1688. *
  1689. * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
  1690. * will be set as the initial icon for the window. If no such icon is present,
  1691. * the `IDI_WINLOGO` icon will be used instead. To set a different icon, see
  1692. * @ref glfwSetWindowIcon.
  1693. *
  1694. * @remark @win32 The context to share resources with must not be current on
  1695. * any other thread.
  1696. *
  1697. * @remark @osx The GLFW window has no icon, as it is not a document
  1698. * window, but the dock icon will be the same as the application bundle's icon.
  1699. * For more information on bundles, see the
  1700. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  1701. * in the Mac Developer Library.
  1702. *
  1703. * @remark @osx The first time a window is created the menu bar is populated
  1704. * with common commands like Hide, Quit and About. The About entry opens
  1705. * a minimal about dialog with information from the application's bundle. The
  1706. * menu bar can be disabled with a
  1707. * [compile-time option](@ref compile_options_osx).
  1708. *
  1709. * @remark @osx On OS X 10.10 and later the window frame will not be rendered
  1710. * at full resolution on Retina displays unless the `NSHighResolutionCapable`
  1711. * key is enabled in the application bundle's `Info.plist`. For more
  1712. * information, see
  1713. * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
  1714. * in the Mac Developer Library. The GLFW test and example programs use
  1715. * a custom `Info.plist` template for this, which can be found as
  1716. * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
  1717. *
  1718. * @remark @x11 Some window managers will not respect the placement of
  1719. * initially hidden windows.
  1720. *
  1721. * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
  1722. * a window to reach its requested state. This means you may not be able to
  1723. * query the final size, position or other attributes directly after window
  1724. * creation.
  1725. *
  1726. * @reentrancy This function must not be called from a callback.
  1727. *
  1728. * @thread_safety This function must only be called from the main thread.
  1729. *
  1730. * @sa @ref window_creation
  1731. * @sa glfwDestroyWindow
  1732. *
  1733. * @since Added in version 3.0. Replaces `glfwOpenWindow`.
  1734. *
  1735. * @ingroup window
  1736. */
  1737. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  1738. /*! @brief Destroys the specified window and its context.
  1739. *
  1740. * This function destroys the specified window and its context. On calling
  1741. * this function, no further callbacks will be called for that window.
  1742. *
  1743. * If the context of the specified window is current on the main thread, it is
  1744. * detached before being destroyed.
  1745. *
  1746. * @param[in] window The window to destroy.
  1747. *
  1748. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1749. * GLFW_PLATFORM_ERROR.
  1750. *
  1751. * @note The context of the specified window must not be current on any other
  1752. * thread when this function is called.
  1753. *
  1754. * @reentrancy This function must not be called from a callback.
  1755. *
  1756. * @thread_safety This function must only be called from the main thread.
  1757. *
  1758. * @sa @ref window_creation
  1759. * @sa glfwCreateWindow
  1760. *
  1761. * @since Added in version 3.0. Replaces `glfwCloseWindow`.
  1762. *
  1763. * @ingroup window
  1764. */
  1765. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  1766. /*! @brief Checks the close flag of the specified window.
  1767. *
  1768. * This function returns the value of the close flag of the specified window.
  1769. *
  1770. * @param[in] window The window to query.
  1771. * @return The value of the close flag.
  1772. *
  1773. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1774. *
  1775. * @thread_safety This function may be called from any thread. Access is not
  1776. * synchronized.
  1777. *
  1778. * @sa @ref window_close
  1779. *
  1780. * @since Added in version 3.0.
  1781. *
  1782. * @ingroup window
  1783. */
  1784. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  1785. /*! @brief Sets the close flag of the specified window.
  1786. *
  1787. * This function sets the value of the close flag of the specified window.
  1788. * This can be used to override the user's attempt to close the window, or
  1789. * to signal that it should be closed.
  1790. *
  1791. * @param[in] window The window whose flag to change.
  1792. * @param[in] value The new value.
  1793. *
  1794. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1795. *
  1796. * @thread_safety This function may be called from any thread. Access is not
  1797. * synchronized.
  1798. *
  1799. * @sa @ref window_close
  1800. *
  1801. * @since Added in version 3.0.
  1802. *
  1803. * @ingroup window
  1804. */
  1805. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  1806. /*! @brief Sets the title of the specified window.
  1807. *
  1808. * This function sets the window title, encoded as UTF-8, of the specified
  1809. * window.
  1810. *
  1811. * @param[in] window The window whose title to change.
  1812. * @param[in] title The UTF-8 encoded window title.
  1813. *
  1814. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1815. * GLFW_PLATFORM_ERROR.
  1816. *
  1817. * @remark @osx The window title will not be updated until the next time you
  1818. * process events.
  1819. *
  1820. * @thread_safety This function must only be called from the main thread.
  1821. *
  1822. * @sa @ref window_title
  1823. *
  1824. * @since Added in version 1.0.
  1825. * @glfw3 Added window handle parameter.
  1826. *
  1827. * @ingroup window
  1828. */
  1829. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  1830. /*! @brief Sets the icon for the specified window.
  1831. *
  1832. * This function sets the icon of the specified window. If passed an array of
  1833. * candidate images, those of or closest to the sizes desired by the system are
  1834. * selected. If no images are specified, the window reverts to its default
  1835. * icon.
  1836. *
  1837. * The desired image sizes varies depending on platform and system settings.
  1838. * The selected images will be rescaled as needed. Good sizes include 16x16,
  1839. * 32x32 and 48x48.
  1840. *
  1841. * @param[in] window The window whose icon to set.
  1842. * @param[in] count The number of images in the specified array, or zero to
  1843. * revert to the default window icon.
  1844. * @param[in] images The images to create the icon from. This is ignored if
  1845. * count is zero.
  1846. *
  1847. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1848. * GLFW_PLATFORM_ERROR.
  1849. *
  1850. * @pointer_lifetime The specified image data is copied before this function
  1851. * returns.
  1852. *
  1853. * @remark @osx The GLFW window has no icon, as it is not a document
  1854. * window, so this function does nothing. The dock icon will be the same as
  1855. * the application bundle's icon. For more information on bundles, see the
  1856. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  1857. * in the Mac Developer Library.
  1858. *
  1859. * @thread_safety This function must only be called from the main thread.
  1860. *
  1861. * @sa @ref window_icon
  1862. *
  1863. * @since Added in version 3.2.
  1864. *
  1865. * @ingroup window
  1866. */
  1867. GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
  1868. /*! @brief Retrieves the position of the client area of the specified window.
  1869. *
  1870. * This function retrieves the position, in screen coordinates, of the
  1871. * upper-left corner of the client area of the specified window.
  1872. *
  1873. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1874. * non-`NULL` position arguments will be set to zero.
  1875. *
  1876. * @param[in] window The window to query.
  1877. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  1878. * the client area, or `NULL`.
  1879. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  1880. * the client area, or `NULL`.
  1881. *
  1882. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1883. * GLFW_PLATFORM_ERROR.
  1884. *
  1885. * @thread_safety This function must only be called from the main thread.
  1886. *
  1887. * @sa @ref window_pos
  1888. * @sa glfwSetWindowPos
  1889. *
  1890. * @since Added in version 3.0.
  1891. *
  1892. * @ingroup window
  1893. */
  1894. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  1895. /*! @brief Sets the position of the client area of the specified window.
  1896. *
  1897. * This function sets the position, in screen coordinates, of the upper-left
  1898. * corner of the client area of the specified windowed mode window. If the
  1899. * window is a full screen window, this function does nothing.
  1900. *
  1901. * __Do not use this function__ to move an already visible window unless you
  1902. * have very good reasons for doing so, as it will confuse and annoy the user.
  1903. *
  1904. * The window manager may put limits on what positions are allowed. GLFW
  1905. * cannot and should not override these limits.
  1906. *
  1907. * @param[in] window The window to query.
  1908. * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
  1909. * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
  1910. *
  1911. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1912. * GLFW_PLATFORM_ERROR.
  1913. *
  1914. * @thread_safety This function must only be called from the main thread.
  1915. *
  1916. * @sa @ref window_pos
  1917. * @sa glfwGetWindowPos
  1918. *
  1919. * @since Added in version 1.0.
  1920. * @glfw3 Added window handle parameter.
  1921. *
  1922. * @ingroup window
  1923. */
  1924. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  1925. /*! @brief Retrieves the size of the client area of the specified window.
  1926. *
  1927. * This function retrieves the size, in screen coordinates, of the client area
  1928. * of the specified window. If you wish to retrieve the size of the
  1929. * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
  1930. *
  1931. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1932. * non-`NULL` size arguments will be set to zero.
  1933. *
  1934. * @param[in] window The window whose size to retrieve.
  1935. * @param[out] width Where to store the width, in screen coordinates, of the
  1936. * client area, or `NULL`.
  1937. * @param[out] height Where to store the height, in screen coordinates, of the
  1938. * client area, or `NULL`.
  1939. *
  1940. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1941. * GLFW_PLATFORM_ERROR.
  1942. *
  1943. * @thread_safety This function must only be called from the main thread.
  1944. *
  1945. * @sa @ref window_size
  1946. * @sa glfwSetWindowSize
  1947. *
  1948. * @since Added in version 1.0.
  1949. * @glfw3 Added window handle parameter.
  1950. *
  1951. * @ingroup window
  1952. */
  1953. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  1954. /*! @brief Sets the size limits of the specified window.
  1955. *
  1956. * This function sets the size limits of the client area of the specified
  1957. * window. If the window is full screen, the size limits only take effect
  1958. * once it is made windowed. If the window is not resizable, this function
  1959. * does nothing.
  1960. *
  1961. * The size limits are applied immediately to a windowed mode window and may
  1962. * cause it to be resized.
  1963. *
  1964. * The maximum dimensions must be greater than or equal to the minimum
  1965. * dimensions and all must be greater than or equal to zero.
  1966. *
  1967. * @param[in] window The window to set limits for.
  1968. * @param[in] minwidth The minimum width, in screen coordinates, of the client
  1969. * area, or `GLFW_DONT_CARE`.
  1970. * @param[in] minheight The minimum height, in screen coordinates, of the
  1971. * client area, or `GLFW_DONT_CARE`.
  1972. * @param[in] maxwidth The maximum width, in screen coordinates, of the client
  1973. * area, or `GLFW_DONT_CARE`.
  1974. * @param[in] maxheight The maximum height, in screen coordinates, of the
  1975. * client area, or `GLFW_DONT_CARE`.
  1976. *
  1977. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  1978. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  1979. *
  1980. * @remark If you set size limits and an aspect ratio that conflict, the
  1981. * results are undefined.
  1982. *
  1983. * @thread_safety This function must only be called from the main thread.
  1984. *
  1985. * @sa @ref window_sizelimits
  1986. * @sa glfwSetWindowAspectRatio
  1987. *
  1988. * @since Added in version 3.2.
  1989. *
  1990. * @ingroup window
  1991. */
  1992. GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
  1993. /*! @brief Sets the aspect ratio of the specified window.
  1994. *
  1995. * This function sets the required aspect ratio of the client area of the
  1996. * specified window. If the window is full screen, the aspect ratio only takes
  1997. * effect once it is made windowed. If the window is not resizable, this
  1998. * function does nothing.
  1999. *
  2000. * The aspect ratio is specified as a numerator and a denominator and both
  2001. * values must be greater than zero. For example, the common 16:9 aspect ratio
  2002. * is specified as 16 and 9, respectively.
  2003. *
  2004. * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
  2005. * ratio limit is disabled.
  2006. *
  2007. * The aspect ratio is applied immediately to a windowed mode window and may
  2008. * cause it to be resized.
  2009. *
  2010. * @param[in] window The window to set limits for.
  2011. * @param[in] numer The numerator of the desired aspect ratio, or
  2012. * `GLFW_DONT_CARE`.
  2013. * @param[in] denom The denominator of the desired aspect ratio, or
  2014. * `GLFW_DONT_CARE`.
  2015. *
  2016. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2017. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2018. *
  2019. * @remark If you set size limits and an aspect ratio that conflict, the
  2020. * results are undefined.
  2021. *
  2022. * @thread_safety This function must only be called from the main thread.
  2023. *
  2024. * @sa @ref window_sizelimits
  2025. * @sa glfwSetWindowSizeLimits
  2026. *
  2027. * @since Added in version 3.2.
  2028. *
  2029. * @ingroup window
  2030. */
  2031. GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
  2032. /*! @brief Sets the size of the client area of the specified window.
  2033. *
  2034. * This function sets the size, in screen coordinates, of the client area of
  2035. * the specified window.
  2036. *
  2037. * For full screen windows, this function updates the resolution of its desired
  2038. * video mode and switches to the video mode closest to it, without affecting
  2039. * the window's context. As the context is unaffected, the bit depths of the
  2040. * framebuffer remain unchanged.
  2041. *
  2042. * If you wish to update the refresh rate of the desired video mode in addition
  2043. * to its resolution, see @ref glfwSetWindowMonitor.
  2044. *
  2045. * The window manager may put limits on what sizes are allowed. GLFW cannot
  2046. * and should not override these limits.
  2047. *
  2048. * @param[in] window The window to resize.
  2049. * @param[in] width The desired width, in screen coordinates, of the window
  2050. * client area.
  2051. * @param[in] height The desired height, in screen coordinates, of the window
  2052. * client area.
  2053. *
  2054. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2055. * GLFW_PLATFORM_ERROR.
  2056. *
  2057. * @thread_safety This function must only be called from the main thread.
  2058. *
  2059. * @sa @ref window_size
  2060. * @sa glfwGetWindowSize
  2061. * @sa glfwSetWindowMonitor
  2062. *
  2063. * @since Added in version 1.0.
  2064. * @glfw3 Added window handle parameter.
  2065. *
  2066. * @ingroup window
  2067. */
  2068. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  2069. /*! @brief Retrieves the size of the framebuffer of the specified window.
  2070. *
  2071. * This function retrieves the size, in pixels, of the framebuffer of the
  2072. * specified window. If you wish to retrieve the size of the window in screen
  2073. * coordinates, see @ref glfwGetWindowSize.
  2074. *
  2075. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2076. * non-`NULL` size arguments will be set to zero.
  2077. *
  2078. * @param[in] window The window whose framebuffer to query.
  2079. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  2080. * or `NULL`.
  2081. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  2082. * or `NULL`.
  2083. *
  2084. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2085. * GLFW_PLATFORM_ERROR.
  2086. *
  2087. * @thread_safety This function must only be called from the main thread.
  2088. *
  2089. * @sa @ref window_fbsize
  2090. * @sa glfwSetFramebufferSizeCallback
  2091. *
  2092. * @since Added in version 3.0.
  2093. *
  2094. * @ingroup window
  2095. */
  2096. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  2097. /*! @brief Retrieves the size of the frame of the window.
  2098. *
  2099. * This function retrieves the size, in screen coordinates, of each edge of the
  2100. * frame of the specified window. This size includes the title bar, if the
  2101. * window has one. The size of the frame may vary depending on the
  2102. * [window-related hints](@ref window_hints_wnd) used to create it.
  2103. *
  2104. * Because this function retrieves the size of each window frame edge and not
  2105. * the offset along a particular coordinate axis, the retrieved values will
  2106. * always be zero or positive.
  2107. *
  2108. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2109. * non-`NULL` size arguments will be set to zero.
  2110. *
  2111. * @param[in] window The window whose frame size to query.
  2112. * @param[out] left Where to store the size, in screen coordinates, of the left
  2113. * edge of the window frame, or `NULL`.
  2114. * @param[out] top Where to store the size, in screen coordinates, of the top
  2115. * edge of the window frame, or `NULL`.
  2116. * @param[out] right Where to store the size, in screen coordinates, of the
  2117. * right edge of the window frame, or `NULL`.
  2118. * @param[out] bottom Where to store the size, in screen coordinates, of the
  2119. * bottom edge of the window frame, or `NULL`.
  2120. *
  2121. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2122. * GLFW_PLATFORM_ERROR.
  2123. *
  2124. * @thread_safety This function must only be called from the main thread.
  2125. *
  2126. * @sa @ref window_size
  2127. *
  2128. * @since Added in version 3.1.
  2129. *
  2130. * @ingroup window
  2131. */
  2132. GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
  2133. /*! @brief Iconifies the specified window.
  2134. *
  2135. * This function iconifies (minimizes) the specified window if it was
  2136. * previously restored. If the window is already iconified, this function does
  2137. * nothing.
  2138. *
  2139. * If the specified window is a full screen window, the original monitor
  2140. * resolution is restored until the window is restored.
  2141. *
  2142. * @param[in] window The window to iconify.
  2143. *
  2144. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2145. * GLFW_PLATFORM_ERROR.
  2146. *
  2147. * @thread_safety This function must only be called from the main thread.
  2148. *
  2149. * @sa @ref window_iconify
  2150. * @sa glfwRestoreWindow
  2151. * @sa glfwMaximizeWindow
  2152. *
  2153. * @since Added in version 2.1.
  2154. * @glfw3 Added window handle parameter.
  2155. *
  2156. * @ingroup window
  2157. */
  2158. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  2159. /*! @brief Restores the specified window.
  2160. *
  2161. * This function restores the specified window if it was previously iconified
  2162. * (minimized) or maximized. If the window is already restored, this function
  2163. * does nothing.
  2164. *
  2165. * If the specified window is a full screen window, the resolution chosen for
  2166. * the window is restored on the selected monitor.
  2167. *
  2168. * @param[in] window The window to restore.
  2169. *
  2170. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2171. * GLFW_PLATFORM_ERROR.
  2172. *
  2173. * @thread_safety This function must only be called from the main thread.
  2174. *
  2175. * @sa @ref window_iconify
  2176. * @sa glfwIconifyWindow
  2177. * @sa glfwMaximizeWindow
  2178. *
  2179. * @since Added in version 2.1.
  2180. * @glfw3 Added window handle parameter.
  2181. *
  2182. * @ingroup window
  2183. */
  2184. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  2185. /*! @brief Maximizes the specified window.
  2186. *
  2187. * This function maximizes the specified window if it was previously not
  2188. * maximized. If the window is already maximized, this function does nothing.
  2189. *
  2190. * If the specified window is a full screen window, this function does nothing.
  2191. *
  2192. * @param[in] window The window to maximize.
  2193. *
  2194. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2195. * GLFW_PLATFORM_ERROR.
  2196. *
  2197. * @par Thread Safety
  2198. * This function may only be called from the main thread.
  2199. *
  2200. * @sa @ref window_iconify
  2201. * @sa glfwIconifyWindow
  2202. * @sa glfwRestoreWindow
  2203. *
  2204. * @since Added in GLFW 3.2.
  2205. *
  2206. * @ingroup window
  2207. */
  2208. GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
  2209. /*! @brief Makes the specified window visible.
  2210. *
  2211. * This function makes the specified window visible if it was previously
  2212. * hidden. If the window is already visible or is in full screen mode, this
  2213. * function does nothing.
  2214. *
  2215. * @param[in] window The window to make visible.
  2216. *
  2217. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2218. * GLFW_PLATFORM_ERROR.
  2219. *
  2220. * @thread_safety This function must only be called from the main thread.
  2221. *
  2222. * @sa @ref window_hide
  2223. * @sa glfwHideWindow
  2224. *
  2225. * @since Added in version 3.0.
  2226. *
  2227. * @ingroup window
  2228. */
  2229. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  2230. /*! @brief Hides the specified window.
  2231. *
  2232. * This function hides the specified window if it was previously visible. If
  2233. * the window is already hidden or is in full screen mode, this function does
  2234. * nothing.
  2235. *
  2236. * @param[in] window The window to hide.
  2237. *
  2238. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2239. * GLFW_PLATFORM_ERROR.
  2240. *
  2241. * @thread_safety This function must only be called from the main thread.
  2242. *
  2243. * @sa @ref window_hide
  2244. * @sa glfwShowWindow
  2245. *
  2246. * @since Added in version 3.0.
  2247. *
  2248. * @ingroup window
  2249. */
  2250. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  2251. /*! @brief Brings the specified window to front and sets input focus.
  2252. *
  2253. * This function brings the specified window to front and sets input focus.
  2254. * The window should already be visible and not iconified.
  2255. *
  2256. * By default, both windowed and full screen mode windows are focused when
  2257. * initially created. Set the [GLFW_FOCUSED](@ref window_hints_wnd) to disable
  2258. * this behavior.
  2259. *
  2260. * __Do not use this function__ to steal focus from other applications unless
  2261. * you are certain that is what the user wants. Focus stealing can be
  2262. * extremely disruptive.
  2263. *
  2264. * @param[in] window The window to give input focus.
  2265. *
  2266. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2267. * GLFW_PLATFORM_ERROR.
  2268. *
  2269. * @thread_safety This function must only be called from the main thread.
  2270. *
  2271. * @sa @ref window_focus
  2272. *
  2273. * @since Added in version 3.2.
  2274. *
  2275. * @ingroup window
  2276. */
  2277. GLFWAPI void glfwFocusWindow(GLFWwindow* window);
  2278. /*! @brief Returns the monitor that the window uses for full screen mode.
  2279. *
  2280. * This function returns the handle of the monitor that the specified window is
  2281. * in full screen on.
  2282. *
  2283. * @param[in] window The window to query.
  2284. * @return The monitor, or `NULL` if the window is in windowed mode or an
  2285. * [error](@ref error_handling) occurred.
  2286. *
  2287. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2288. *
  2289. * @thread_safety This function must only be called from the main thread.
  2290. *
  2291. * @sa @ref window_monitor
  2292. * @sa glfwSetWindowMonitor
  2293. *
  2294. * @since Added in version 3.0.
  2295. *
  2296. * @ingroup window
  2297. */
  2298. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  2299. /*! @brief Sets the mode, monitor, video mode and placement of a window.
  2300. *
  2301. * This function sets the monitor that the window uses for full screen mode or,
  2302. * if the monitor is `NULL`, makes it windowed mode.
  2303. *
  2304. * When setting a monitor, this function updates the width, height and refresh
  2305. * rate of the desired video mode and switches to the video mode closest to it.
  2306. * The window position is ignored when setting a monitor.
  2307. *
  2308. * When the monitor is `NULL`, the position, width and height are used to
  2309. * place the window client area. The refresh rate is ignored when no monitor
  2310. * is specified.
  2311. *
  2312. * If you only wish to update the resolution of a full screen window or the
  2313. * size of a windowed mode window, see @ref glfwSetWindowSize.
  2314. *
  2315. * When a window transitions from full screen to windowed mode, this function
  2316. * restores any previous window settings such as whether it is decorated,
  2317. * floating, resizable, has size or aspect ratio limits, etc..
  2318. *
  2319. * @param[in] window The window whose monitor, size or video mode to set.
  2320. * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
  2321. * @param[in] xpos The desired x-coordinate of the upper-left corner of the
  2322. * client area.
  2323. * @param[in] ypos The desired y-coordinate of the upper-left corner of the
  2324. * client area.
  2325. * @param[in] width The desired with, in screen coordinates, of the client area
  2326. * or video mode.
  2327. * @param[in] height The desired height, in screen coordinates, of the client
  2328. * area or video mode.
  2329. * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
  2330. * or `GLFW_DONT_CARE`.
  2331. *
  2332. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2333. * GLFW_PLATFORM_ERROR.
  2334. *
  2335. * @thread_safety This function must only be called from the main thread.
  2336. *
  2337. * @sa @ref window_monitor
  2338. * @sa @ref window_full_screen
  2339. * @sa glfwGetWindowMonitor
  2340. * @sa glfwSetWindowSize
  2341. *
  2342. * @since Added in version 3.2.
  2343. *
  2344. * @ingroup window
  2345. */
  2346. GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
  2347. /*! @brief Returns an attribute of the specified window.
  2348. *
  2349. * This function returns the value of an attribute of the specified window or
  2350. * its OpenGL or OpenGL ES context.
  2351. *
  2352. * @param[in] window The window to query.
  2353. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  2354. * return.
  2355. * @return The value of the attribute, or zero if an
  2356. * [error](@ref error_handling) occurred.
  2357. *
  2358. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2359. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  2360. *
  2361. * @remark Framebuffer related hints are not window attributes. See @ref
  2362. * window_attribs_fb for more information.
  2363. *
  2364. * @remark Zero is a valid value for many window and context related
  2365. * attributes so you cannot use a return value of zero as an indication of
  2366. * errors. However, this function should not fail as long as it is passed
  2367. * valid arguments and the library has been [initialized](@ref intro_init).
  2368. *
  2369. * @thread_safety This function must only be called from the main thread.
  2370. *
  2371. * @sa @ref window_attribs
  2372. *
  2373. * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
  2374. * `glfwGetGLVersion`.
  2375. *
  2376. * @ingroup window
  2377. */
  2378. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  2379. /*! @brief Sets the user pointer of the specified window.
  2380. *
  2381. * This function sets the user-defined pointer of the specified window. The
  2382. * current value is retained until the window is destroyed. The initial value
  2383. * is `NULL`.
  2384. *
  2385. * @param[in] window The window whose pointer to set.
  2386. * @param[in] pointer The new value.
  2387. *
  2388. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2389. *
  2390. * @thread_safety This function may be called from any thread. Access is not
  2391. * synchronized.
  2392. *
  2393. * @sa @ref window_userptr
  2394. * @sa glfwGetWindowUserPointer
  2395. *
  2396. * @since Added in version 3.0.
  2397. *
  2398. * @ingroup window
  2399. */
  2400. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  2401. /*! @brief Returns the user pointer of the specified window.
  2402. *
  2403. * This function returns the current value of the user-defined pointer of the
  2404. * specified window. The initial value is `NULL`.
  2405. *
  2406. * @param[in] window The window whose pointer to return.
  2407. *
  2408. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2409. *
  2410. * @thread_safety This function may be called from any thread. Access is not
  2411. * synchronized.
  2412. *
  2413. * @sa @ref window_userptr
  2414. * @sa glfwSetWindowUserPointer
  2415. *
  2416. * @since Added in version 3.0.
  2417. *
  2418. * @ingroup window
  2419. */
  2420. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  2421. /*! @brief Sets the position callback for the specified window.
  2422. *
  2423. * This function sets the position callback of the specified window, which is
  2424. * called when the window is moved. The callback is provided with the screen
  2425. * position of the upper-left corner of the client area of the window.
  2426. *
  2427. * @param[in] window The window whose callback to set.
  2428. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2429. * callback.
  2430. * @return The previously set callback, or `NULL` if no callback was set or the
  2431. * library had not been [initialized](@ref intro_init).
  2432. *
  2433. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2434. *
  2435. * @thread_safety This function must only be called from the main thread.
  2436. *
  2437. * @sa @ref window_pos
  2438. *
  2439. * @since Added in version 3.0.
  2440. *
  2441. * @ingroup window
  2442. */
  2443. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
  2444. /*! @brief Sets the size callback for the specified window.
  2445. *
  2446. * This function sets the size callback of the specified window, which is
  2447. * called when the window is resized. The callback is provided with the size,
  2448. * in screen coordinates, of the client area of the window.
  2449. *
  2450. * @param[in] window The window whose callback to set.
  2451. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2452. * callback.
  2453. * @return The previously set callback, or `NULL` if no callback was set or the
  2454. * library had not been [initialized](@ref intro_init).
  2455. *
  2456. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2457. *
  2458. * @thread_safety This function must only be called from the main thread.
  2459. *
  2460. * @sa @ref window_size
  2461. *
  2462. * @since Added in version 1.0.
  2463. * @glfw3 Added window handle parameter and return value.
  2464. *
  2465. * @ingroup window
  2466. */
  2467. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
  2468. /*! @brief Sets the close callback for the specified window.
  2469. *
  2470. * This function sets the close callback of the specified window, which is
  2471. * called when the user attempts to close the window, for example by clicking
  2472. * the close widget in the title bar.
  2473. *
  2474. * The close flag is set before this callback is called, but you can modify it
  2475. * at any time with @ref glfwSetWindowShouldClose.
  2476. *
  2477. * The close callback is not triggered by @ref glfwDestroyWindow.
  2478. *
  2479. * @param[in] window The window whose callback to set.
  2480. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2481. * callback.
  2482. * @return The previously set callback, or `NULL` if no callback was set or the
  2483. * library had not been [initialized](@ref intro_init).
  2484. *
  2485. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2486. *
  2487. * @remark @osx Selecting Quit from the application menu will trigger the close
  2488. * callback for all windows.
  2489. *
  2490. * @thread_safety This function must only be called from the main thread.
  2491. *
  2492. * @sa @ref window_close
  2493. *
  2494. * @since Added in version 2.5.
  2495. * @glfw3 Added window handle parameter and return value.
  2496. *
  2497. * @ingroup window
  2498. */
  2499. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
  2500. /*! @brief Sets the refresh callback for the specified window.
  2501. *
  2502. * This function sets the refresh callback of the specified window, which is
  2503. * called when the client area of the window needs to be redrawn, for example
  2504. * if the window has been exposed after having been covered by another window.
  2505. *
  2506. * On compositing window systems such as Aero, Compiz or Aqua, where the window
  2507. * contents are saved off-screen, this callback may be called only very
  2508. * infrequently or never at all.
  2509. *
  2510. * @param[in] window The window whose callback to set.
  2511. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2512. * callback.
  2513. * @return The previously set callback, or `NULL` if no callback was set or the
  2514. * library had not been [initialized](@ref intro_init).
  2515. *
  2516. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2517. *
  2518. * @thread_safety This function must only be called from the main thread.
  2519. *
  2520. * @sa @ref window_refresh
  2521. *
  2522. * @since Added in version 2.5.
  2523. * @glfw3 Added window handle parameter and return value.
  2524. *
  2525. * @ingroup window
  2526. */
  2527. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
  2528. /*! @brief Sets the focus callback for the specified window.
  2529. *
  2530. * This function sets the focus callback of the specified window, which is
  2531. * called when the window gains or loses input focus.
  2532. *
  2533. * After the focus callback is called for a window that lost input focus,
  2534. * synthetic key and mouse button release events will be generated for all such
  2535. * that had been pressed. For more information, see @ref glfwSetKeyCallback
  2536. * and @ref glfwSetMouseButtonCallback.
  2537. *
  2538. * @param[in] window The window whose callback to set.
  2539. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2540. * callback.
  2541. * @return The previously set callback, or `NULL` if no callback was set or the
  2542. * library had not been [initialized](@ref intro_init).
  2543. *
  2544. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2545. *
  2546. * @thread_safety This function must only be called from the main thread.
  2547. *
  2548. * @sa @ref window_focus
  2549. *
  2550. * @since Added in version 3.0.
  2551. *
  2552. * @ingroup window
  2553. */
  2554. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
  2555. /*! @brief Sets the iconify callback for the specified window.
  2556. *
  2557. * This function sets the iconification callback of the specified window, which
  2558. * is called when the window is iconified or restored.
  2559. *
  2560. * @param[in] window The window whose callback to set.
  2561. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2562. * callback.
  2563. * @return The previously set callback, or `NULL` if no callback was set or the
  2564. * library had not been [initialized](@ref intro_init).
  2565. *
  2566. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2567. *
  2568. * @thread_safety This function must only be called from the main thread.
  2569. *
  2570. * @sa @ref window_iconify
  2571. *
  2572. * @since Added in version 3.0.
  2573. *
  2574. * @ingroup window
  2575. */
  2576. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
  2577. /*! @brief Sets the framebuffer resize callback for the specified window.
  2578. *
  2579. * This function sets the framebuffer resize callback of the specified window,
  2580. * which is called when the framebuffer of the specified window is resized.
  2581. *
  2582. * @param[in] window The window whose callback to set.
  2583. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2584. * callback.
  2585. * @return The previously set callback, or `NULL` if no callback was set or the
  2586. * library had not been [initialized](@ref intro_init).
  2587. *
  2588. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2589. *
  2590. * @thread_safety This function must only be called from the main thread.
  2591. *
  2592. * @sa @ref window_fbsize
  2593. *
  2594. * @since Added in version 3.0.
  2595. *
  2596. * @ingroup window
  2597. */
  2598. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
  2599. /*! @brief Processes all pending events.
  2600. *
  2601. * This function processes only those events that are already in the event
  2602. * queue and then returns immediately. Processing events will cause the window
  2603. * and input callbacks associated with those events to be called.
  2604. *
  2605. * On some platforms, a window move, resize or menu operation will cause event
  2606. * processing to block. This is due to how event processing is designed on
  2607. * those platforms. You can use the
  2608. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2609. * your window when necessary during such operations.
  2610. *
  2611. * On some platforms, certain events are sent directly to the application
  2612. * without going through the event queue, causing callbacks to be called
  2613. * outside of a call to one of the event processing functions.
  2614. *
  2615. * Event processing is not required for joystick input to work.
  2616. *
  2617. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2618. * GLFW_PLATFORM_ERROR.
  2619. *
  2620. * @reentrancy This function must not be called from a callback.
  2621. *
  2622. * @thread_safety This function must only be called from the main thread.
  2623. *
  2624. * @sa @ref events
  2625. * @sa glfwWaitEvents
  2626. * @sa glfwWaitEventsTimeout
  2627. *
  2628. * @since Added in version 1.0.
  2629. *
  2630. * @ingroup window
  2631. */
  2632. GLFWAPI void glfwPollEvents(void);
  2633. /*! @brief Waits until events are queued and processes them.
  2634. *
  2635. * This function puts the calling thread to sleep until at least one event is
  2636. * available in the event queue. Once one or more events are available,
  2637. * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
  2638. * are processed and the function then returns immediately. Processing events
  2639. * will cause the window and input callbacks associated with those events to be
  2640. * called.
  2641. *
  2642. * Since not all events are associated with callbacks, this function may return
  2643. * without a callback having been called even if you are monitoring all
  2644. * callbacks.
  2645. *
  2646. * On some platforms, a window move, resize or menu operation will cause event
  2647. * processing to block. This is due to how event processing is designed on
  2648. * those platforms. You can use the
  2649. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2650. * your window when necessary during such operations.
  2651. *
  2652. * On some platforms, certain callbacks may be called outside of a call to one
  2653. * of the event processing functions.
  2654. *
  2655. * If no windows exist, this function returns immediately. For synchronization
  2656. * of threads in applications that do not create windows, use your threading
  2657. * library of choice.
  2658. *
  2659. * Event processing is not required for joystick input to work.
  2660. *
  2661. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2662. * GLFW_PLATFORM_ERROR.
  2663. *
  2664. * @reentrancy This function must not be called from a callback.
  2665. *
  2666. * @thread_safety This function must only be called from the main thread.
  2667. *
  2668. * @sa @ref events
  2669. * @sa glfwPollEvents
  2670. * @sa glfwWaitEventsTimeout
  2671. *
  2672. * @since Added in version 2.5.
  2673. *
  2674. * @ingroup window
  2675. */
  2676. GLFWAPI void glfwWaitEvents(void);
  2677. /*! @brief Waits with timeout until events are queued and processes them.
  2678. *
  2679. * This function puts the calling thread to sleep until at least one event is
  2680. * available in the event queue, or until the specified timeout is reached. If
  2681. * one or more events are available, it behaves exactly like @ref
  2682. * glfwPollEvents, i.e. the events in the queue are processed and the function
  2683. * then returns immediately. Processing events will cause the window and input
  2684. * callbacks associated with those events to be called.
  2685. *
  2686. * The timeout value must be a positive finite number.
  2687. *
  2688. * Since not all events are associated with callbacks, this function may return
  2689. * without a callback having been called even if you are monitoring all
  2690. * callbacks.
  2691. *
  2692. * On some platforms, a window move, resize or menu operation will cause event
  2693. * processing to block. This is due to how event processing is designed on
  2694. * those platforms. You can use the
  2695. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2696. * your window when necessary during such operations.
  2697. *
  2698. * On some platforms, certain callbacks may be called outside of a call to one
  2699. * of the event processing functions.
  2700. *
  2701. * If no windows exist, this function returns immediately. For synchronization
  2702. * of threads in applications that do not create windows, use your threading
  2703. * library of choice.
  2704. *
  2705. * Event processing is not required for joystick input to work.
  2706. *
  2707. * @param[in] timeout The maximum amount of time, in seconds, to wait.
  2708. *
  2709. * @reentrancy This function must not be called from a callback.
  2710. *
  2711. * @thread_safety This function must only be called from the main thread.
  2712. *
  2713. * @sa @ref events
  2714. * @sa glfwPollEvents
  2715. * @sa glfwWaitEvents
  2716. *
  2717. * @since Added in version 3.2.
  2718. *
  2719. * @ingroup window
  2720. */
  2721. GLFWAPI void glfwWaitEventsTimeout(double timeout);
  2722. /*! @brief Posts an empty event to the event queue.
  2723. *
  2724. * This function posts an empty event from the current thread to the event
  2725. * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
  2726. *
  2727. * If no windows exist, this function returns immediately. For synchronization
  2728. * of threads in applications that do not create windows, use your threading
  2729. * library of choice.
  2730. *
  2731. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2732. * GLFW_PLATFORM_ERROR.
  2733. *
  2734. * @thread_safety This function may be called from any thread.
  2735. *
  2736. * @sa @ref events
  2737. * @sa glfwWaitEvents
  2738. * @sa glfwWaitEventsTimeout
  2739. *
  2740. * @since Added in version 3.1.
  2741. *
  2742. * @ingroup window
  2743. */
  2744. GLFWAPI void glfwPostEmptyEvent(void);
  2745. /*! @brief Returns the value of an input option for the specified window.
  2746. *
  2747. * This function returns the value of an input option for the specified window.
  2748. * The mode must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2749. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2750. *
  2751. * @param[in] window The window to query.
  2752. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2753. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2754. *
  2755. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2756. * GLFW_INVALID_ENUM.
  2757. *
  2758. * @thread_safety This function must only be called from the main thread.
  2759. *
  2760. * @sa glfwSetInputMode
  2761. *
  2762. * @since Added in version 3.0.
  2763. *
  2764. * @ingroup input
  2765. */
  2766. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  2767. /*! @brief Sets an input option for the specified window.
  2768. *
  2769. * This function sets an input mode option for the specified window. The mode
  2770. * must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2771. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2772. *
  2773. * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  2774. * modes:
  2775. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  2776. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
  2777. * area of the window but does not restrict the cursor from leaving.
  2778. * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  2779. * and unlimited cursor movement. This is useful for implementing for
  2780. * example 3D camera controls.
  2781. *
  2782. * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
  2783. * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
  2784. * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  2785. * the next time it is called even if the key had been released before the
  2786. * call. This is useful when you are only interested in whether keys have been
  2787. * pressed but not when or in which order.
  2788. *
  2789. * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  2790. * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
  2791. * If sticky mouse buttons are enabled, a mouse button press will ensure that
  2792. * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
  2793. * if the mouse button had been released before the call. This is useful when
  2794. * you are only interested in whether mouse buttons have been pressed but not
  2795. * when or in which order.
  2796. *
  2797. * @param[in] window The window whose input mode to set.
  2798. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2799. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2800. * @param[in] value The new value of the specified input mode.
  2801. *
  2802. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2803. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  2804. *
  2805. * @thread_safety This function must only be called from the main thread.
  2806. *
  2807. * @sa glfwGetInputMode
  2808. *
  2809. * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
  2810. *
  2811. * @ingroup input
  2812. */
  2813. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  2814. /*! @brief Returns the localized name of the specified printable key.
  2815. *
  2816. * This function returns the localized name of the specified printable key.
  2817. * This is intended for displaying key bindings to the user.
  2818. *
  2819. * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used instead, otherwise
  2820. * the scancode is ignored. If a non-printable key or (if the key is
  2821. * `GLFW_KEY_UNKNOWN`) a scancode that maps to a non-printable key is
  2822. * specified, this function returns `NULL`.
  2823. *
  2824. * This behavior allows you to pass in the arguments passed to the
  2825. * [key callback](@ref input_key) without modification.
  2826. *
  2827. * The printable keys are:
  2828. * - `GLFW_KEY_APOSTROPHE`
  2829. * - `GLFW_KEY_COMMA`
  2830. * - `GLFW_KEY_MINUS`
  2831. * - `GLFW_KEY_PERIOD`
  2832. * - `GLFW_KEY_SLASH`
  2833. * - `GLFW_KEY_SEMICOLON`
  2834. * - `GLFW_KEY_EQUAL`
  2835. * - `GLFW_KEY_LEFT_BRACKET`
  2836. * - `GLFW_KEY_RIGHT_BRACKET`
  2837. * - `GLFW_KEY_BACKSLASH`
  2838. * - `GLFW_KEY_WORLD_1`
  2839. * - `GLFW_KEY_WORLD_2`
  2840. * - `GLFW_KEY_0` to `GLFW_KEY_9`
  2841. * - `GLFW_KEY_A` to `GLFW_KEY_Z`
  2842. * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
  2843. * - `GLFW_KEY_KP_DECIMAL`
  2844. * - `GLFW_KEY_KP_DIVIDE`
  2845. * - `GLFW_KEY_KP_MULTIPLY`
  2846. * - `GLFW_KEY_KP_SUBTRACT`
  2847. * - `GLFW_KEY_KP_ADD`
  2848. * - `GLFW_KEY_KP_EQUAL`
  2849. *
  2850. * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
  2851. * @param[in] scancode The scancode of the key to query.
  2852. * @return The localized name of the key, or `NULL`.
  2853. *
  2854. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2855. * GLFW_PLATFORM_ERROR.
  2856. *
  2857. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  2858. * should not free it yourself. It is valid until the next call to @ref
  2859. * glfwGetKeyName, or until the library is terminated.
  2860. *
  2861. * @thread_safety This function must only be called from the main thread.
  2862. *
  2863. * @sa @ref input_key_name
  2864. *
  2865. * @since Added in version 3.2.
  2866. *
  2867. * @ingroup input
  2868. */
  2869. GLFWAPI const char* glfwGetKeyName(int key, int scancode);
  2870. /*! @brief Returns the last reported state of a keyboard key for the specified
  2871. * window.
  2872. *
  2873. * This function returns the last state reported for the specified key to the
  2874. * specified window. The returned state is one of `GLFW_PRESS` or
  2875. * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
  2876. * the key callback.
  2877. *
  2878. * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
  2879. * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  2880. * that key has already been released.
  2881. *
  2882. * The key functions deal with physical keys, with [key tokens](@ref keys)
  2883. * named after their use on the standard US keyboard layout. If you want to
  2884. * input text, use the Unicode character callback instead.
  2885. *
  2886. * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  2887. * used with this function.
  2888. *
  2889. * __Do not use this function__ to implement [text input](@ref input_char).
  2890. *
  2891. * @param[in] window The desired window.
  2892. * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
  2893. * not a valid key for this function.
  2894. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  2895. *
  2896. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2897. * GLFW_INVALID_ENUM.
  2898. *
  2899. * @thread_safety This function must only be called from the main thread.
  2900. *
  2901. * @sa @ref input_key
  2902. *
  2903. * @since Added in version 1.0.
  2904. * @glfw3 Added window handle parameter.
  2905. *
  2906. * @ingroup input
  2907. */
  2908. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  2909. /*! @brief Returns the last reported state of a mouse button for the specified
  2910. * window.
  2911. *
  2912. * This function returns the last state reported for the specified mouse button
  2913. * to the specified window. The returned state is one of `GLFW_PRESS` or
  2914. * `GLFW_RELEASE`.
  2915. *
  2916. * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
  2917. * `GLFW_PRESS` the first time you call it for a mouse button that was pressed,
  2918. * even if that mouse button has already been released.
  2919. *
  2920. * @param[in] window The desired window.
  2921. * @param[in] button The desired [mouse button](@ref buttons).
  2922. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  2923. *
  2924. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2925. * GLFW_INVALID_ENUM.
  2926. *
  2927. * @thread_safety This function must only be called from the main thread.
  2928. *
  2929. * @sa @ref input_mouse_button
  2930. *
  2931. * @since Added in version 1.0.
  2932. * @glfw3 Added window handle parameter.
  2933. *
  2934. * @ingroup input
  2935. */
  2936. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  2937. /*! @brief Retrieves the position of the cursor relative to the client area of
  2938. * the window.
  2939. *
  2940. * This function returns the position of the cursor, in screen coordinates,
  2941. * relative to the upper-left corner of the client area of the specified
  2942. * window.
  2943. *
  2944. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  2945. * position is unbounded and limited only by the minimum and maximum values of
  2946. * a `double`.
  2947. *
  2948. * The coordinate can be converted to their integer equivalents with the
  2949. * `floor` function. Casting directly to an integer type works for positive
  2950. * coordinates, but fails for negative ones.
  2951. *
  2952. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  2953. * non-`NULL` position arguments will be set to zero.
  2954. *
  2955. * @param[in] window The desired window.
  2956. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  2957. * left edge of the client area, or `NULL`.
  2958. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  2959. * top edge of the client area, or `NULL`.
  2960. *
  2961. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2962. * GLFW_PLATFORM_ERROR.
  2963. *
  2964. * @thread_safety This function must only be called from the main thread.
  2965. *
  2966. * @sa @ref cursor_pos
  2967. * @sa glfwSetCursorPos
  2968. *
  2969. * @since Added in version 3.0. Replaces `glfwGetMousePos`.
  2970. *
  2971. * @ingroup input
  2972. */
  2973. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  2974. /*! @brief Sets the position of the cursor, relative to the client area of the
  2975. * window.
  2976. *
  2977. * This function sets the position, in screen coordinates, of the cursor
  2978. * relative to the upper-left corner of the client area of the specified
  2979. * window. The window must have input focus. If the window does not have
  2980. * input focus when this function is called, it fails silently.
  2981. *
  2982. * __Do not use this function__ to implement things like camera controls. GLFW
  2983. * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  2984. * cursor, transparently re-centers it and provides unconstrained cursor
  2985. * motion. See @ref glfwSetInputMode for more information.
  2986. *
  2987. * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  2988. * unconstrained and limited only by the minimum and maximum values of
  2989. * a `double`.
  2990. *
  2991. * @param[in] window The desired window.
  2992. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  2993. * client area.
  2994. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  2995. * client area.
  2996. *
  2997. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2998. * GLFW_PLATFORM_ERROR.
  2999. *
  3000. * @thread_safety This function must only be called from the main thread.
  3001. *
  3002. * @sa @ref cursor_pos
  3003. * @sa glfwGetCursorPos
  3004. *
  3005. * @since Added in version 3.0. Replaces `glfwSetMousePos`.
  3006. *
  3007. * @ingroup input
  3008. */
  3009. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  3010. /*! @brief Creates a custom cursor.
  3011. *
  3012. * Creates a new custom cursor image that can be set for a window with @ref
  3013. * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
  3014. * Any remaining cursors are destroyed by @ref glfwTerminate.
  3015. *
  3016. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  3017. * bits per channel. They are arranged canonically as packed sequential rows,
  3018. * starting from the top-left corner.
  3019. *
  3020. * The cursor hotspot is specified in pixels, relative to the upper-left corner
  3021. * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
  3022. * points to the right and the Y-axis points down.
  3023. *
  3024. * @param[in] image The desired cursor image.
  3025. * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
  3026. * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
  3027. * @return The handle of the created cursor, or `NULL` if an
  3028. * [error](@ref error_handling) occurred.
  3029. *
  3030. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3031. * GLFW_PLATFORM_ERROR.
  3032. *
  3033. * @pointer_lifetime The specified image data is copied before this function
  3034. * returns.
  3035. *
  3036. * @reentrancy This function must not be called from a callback.
  3037. *
  3038. * @thread_safety This function must only be called from the main thread.
  3039. *
  3040. * @sa @ref cursor_object
  3041. * @sa glfwDestroyCursor
  3042. * @sa glfwCreateStandardCursor
  3043. *
  3044. * @since Added in version 3.1.
  3045. *
  3046. * @ingroup input
  3047. */
  3048. GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
  3049. /*! @brief Creates a cursor with a standard shape.
  3050. *
  3051. * Returns a cursor with a [standard shape](@ref shapes), that can be set for
  3052. * a window with @ref glfwSetCursor.
  3053. *
  3054. * @param[in] shape One of the [standard shapes](@ref shapes).
  3055. * @return A new cursor ready to use or `NULL` if an
  3056. * [error](@ref error_handling) occurred.
  3057. *
  3058. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3059. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3060. *
  3061. * @reentrancy This function must not be called from a callback.
  3062. *
  3063. * @thread_safety This function must only be called from the main thread.
  3064. *
  3065. * @sa @ref cursor_object
  3066. * @sa glfwCreateCursor
  3067. *
  3068. * @since Added in version 3.1.
  3069. *
  3070. * @ingroup input
  3071. */
  3072. GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
  3073. /*! @brief Destroys a cursor.
  3074. *
  3075. * This function destroys a cursor previously created with @ref
  3076. * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
  3077. * glfwTerminate.
  3078. *
  3079. * @param[in] cursor The cursor object to destroy.
  3080. *
  3081. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3082. * GLFW_PLATFORM_ERROR.
  3083. *
  3084. * @reentrancy This function must not be called from a callback.
  3085. *
  3086. * @thread_safety This function must only be called from the main thread.
  3087. *
  3088. * @sa @ref cursor_object
  3089. * @sa glfwCreateCursor
  3090. *
  3091. * @since Added in version 3.1.
  3092. *
  3093. * @ingroup input
  3094. */
  3095. GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
  3096. /*! @brief Sets the cursor for the window.
  3097. *
  3098. * This function sets the cursor image to be used when the cursor is over the
  3099. * client area of the specified window. The set cursor will only be visible
  3100. * when the [cursor mode](@ref cursor_mode) of the window is
  3101. * `GLFW_CURSOR_NORMAL`.
  3102. *
  3103. * On some platforms, the set cursor may not be visible unless the window also
  3104. * has input focus.
  3105. *
  3106. * @param[in] window The window to set the cursor for.
  3107. * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  3108. * arrow cursor.
  3109. *
  3110. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3111. * GLFW_PLATFORM_ERROR.
  3112. *
  3113. * @thread_safety This function must only be called from the main thread.
  3114. *
  3115. * @sa @ref cursor_object
  3116. *
  3117. * @since Added in version 3.1.
  3118. *
  3119. * @ingroup input
  3120. */
  3121. GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
  3122. /*! @brief Sets the key callback.
  3123. *
  3124. * This function sets the key callback of the specified window, which is called
  3125. * when a key is pressed, repeated or released.
  3126. *
  3127. * The key functions deal with physical keys, with layout independent
  3128. * [key tokens](@ref keys) named after their values in the standard US keyboard
  3129. * layout. If you want to input text, use the
  3130. * [character callback](@ref glfwSetCharCallback) instead.
  3131. *
  3132. * When a window loses input focus, it will generate synthetic key release
  3133. * events for all pressed keys. You can tell these events from user-generated
  3134. * events by the fact that the synthetic ones are generated after the focus
  3135. * loss event has been processed, i.e. after the
  3136. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  3137. *
  3138. * The scancode of a key is specific to that platform or sometimes even to that
  3139. * machine. Scancodes are intended to allow users to bind keys that don't have
  3140. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  3141. * state is not saved and so it cannot be queried with @ref glfwGetKey.
  3142. *
  3143. * Sometimes GLFW needs to generate synthetic key events, in which case the
  3144. * scancode may be zero.
  3145. *
  3146. * @param[in] window The window whose callback to set.
  3147. * @param[in] cbfun The new key callback, or `NULL` to remove the currently
  3148. * set callback.
  3149. * @return The previously set callback, or `NULL` if no callback was set or the
  3150. * library had not been [initialized](@ref intro_init).
  3151. *
  3152. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3153. *
  3154. * @thread_safety This function must only be called from the main thread.
  3155. *
  3156. * @sa @ref input_key
  3157. *
  3158. * @since Added in version 1.0.
  3159. * @glfw3 Added window handle parameter and return value.
  3160. *
  3161. * @ingroup input
  3162. */
  3163. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
  3164. /*! @brief Sets the Unicode character callback.
  3165. *
  3166. * This function sets the character callback of the specified window, which is
  3167. * called when a Unicode character is input.
  3168. *
  3169. * The character callback is intended for Unicode text input. As it deals with
  3170. * characters, it is keyboard layout dependent, whereas the
  3171. * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
  3172. * to physical keys, as a key may produce zero, one or more characters. If you
  3173. * want to know whether a specific physical key was pressed or released, see
  3174. * the key callback instead.
  3175. *
  3176. * The character callback behaves as system text input normally does and will
  3177. * not be called if modifier keys are held down that would prevent normal text
  3178. * input on that platform, for example a Super (Command) key on OS X or Alt key
  3179. * on Windows. There is a
  3180. * [character with modifiers callback](@ref glfwSetCharModsCallback) that
  3181. * receives these events.
  3182. *
  3183. * @param[in] window The window whose callback to set.
  3184. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3185. * callback.
  3186. * @return The previously set callback, or `NULL` if no callback was set or the
  3187. * library had not been [initialized](@ref intro_init).
  3188. *
  3189. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3190. *
  3191. * @thread_safety This function must only be called from the main thread.
  3192. *
  3193. * @sa @ref input_char
  3194. *
  3195. * @since Added in version 2.4.
  3196. * @glfw3 Added window handle parameter and return value.
  3197. *
  3198. * @ingroup input
  3199. */
  3200. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
  3201. /*! @brief Sets the Unicode character with modifiers callback.
  3202. *
  3203. * This function sets the character with modifiers callback of the specified
  3204. * window, which is called when a Unicode character is input regardless of what
  3205. * modifier keys are used.
  3206. *
  3207. * The character with modifiers callback is intended for implementing custom
  3208. * Unicode character input. For regular Unicode text input, see the
  3209. * [character callback](@ref glfwSetCharCallback). Like the character
  3210. * callback, the character with modifiers callback deals with characters and is
  3211. * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
  3212. * a key may produce zero, one or more characters. If you want to know whether
  3213. * a specific physical key was pressed or released, see the
  3214. * [key callback](@ref glfwSetKeyCallback) instead.
  3215. *
  3216. * @param[in] window The window whose callback to set.
  3217. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3218. * callback.
  3219. * @return The previously set callback, or `NULL` if no callback was set or an
  3220. * [error](@ref error_handling) occurred.
  3221. *
  3222. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3223. *
  3224. * @thread_safety This function must only be called from the main thread.
  3225. *
  3226. * @sa @ref input_char
  3227. *
  3228. * @since Added in version 3.1.
  3229. *
  3230. * @ingroup input
  3231. */
  3232. GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);
  3233. /*! @brief Sets the mouse button callback.
  3234. *
  3235. * This function sets the mouse button callback of the specified window, which
  3236. * is called when a mouse button is pressed or released.
  3237. *
  3238. * When a window loses input focus, it will generate synthetic mouse button
  3239. * release events for all pressed mouse buttons. You can tell these events
  3240. * from user-generated events by the fact that the synthetic ones are generated
  3241. * after the focus loss event has been processed, i.e. after the
  3242. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  3243. *
  3244. * @param[in] window The window whose callback to set.
  3245. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3246. * callback.
  3247. * @return The previously set callback, or `NULL` if no callback was set or the
  3248. * library had not been [initialized](@ref intro_init).
  3249. *
  3250. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3251. *
  3252. * @thread_safety This function must only be called from the main thread.
  3253. *
  3254. * @sa @ref input_mouse_button
  3255. *
  3256. * @since Added in version 1.0.
  3257. * @glfw3 Added window handle parameter and return value.
  3258. *
  3259. * @ingroup input
  3260. */
  3261. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
  3262. /*! @brief Sets the cursor position callback.
  3263. *
  3264. * This function sets the cursor position callback of the specified window,
  3265. * which is called when the cursor is moved. The callback is provided with the
  3266. * position, in screen coordinates, relative to the upper-left corner of the
  3267. * client area of the window.
  3268. *
  3269. * @param[in] window The window whose callback to set.
  3270. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3271. * callback.
  3272. * @return The previously set callback, or `NULL` if no callback was set or the
  3273. * library had not been [initialized](@ref intro_init).
  3274. *
  3275. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3276. *
  3277. * @thread_safety This function must only be called from the main thread.
  3278. *
  3279. * @sa @ref cursor_pos
  3280. *
  3281. * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
  3282. *
  3283. * @ingroup input
  3284. */
  3285. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
  3286. /*! @brief Sets the cursor enter/exit callback.
  3287. *
  3288. * This function sets the cursor boundary crossing callback of the specified
  3289. * window, which is called when the cursor enters or leaves the client area of
  3290. * the window.
  3291. *
  3292. * @param[in] window The window whose callback to set.
  3293. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3294. * callback.
  3295. * @return The previously set callback, or `NULL` if no callback was set or the
  3296. * library had not been [initialized](@ref intro_init).
  3297. *
  3298. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3299. *
  3300. * @thread_safety This function must only be called from the main thread.
  3301. *
  3302. * @sa @ref cursor_enter
  3303. *
  3304. * @since Added in version 3.0.
  3305. *
  3306. * @ingroup input
  3307. */
  3308. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
  3309. /*! @brief Sets the scroll callback.
  3310. *
  3311. * This function sets the scroll callback of the specified window, which is
  3312. * called when a scrolling device is used, such as a mouse wheel or scrolling
  3313. * area of a touchpad.
  3314. *
  3315. * The scroll callback receives all scrolling input, like that from a mouse
  3316. * wheel or a touchpad scrolling area.
  3317. *
  3318. * @param[in] window The window whose callback to set.
  3319. * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
  3320. * set callback.
  3321. * @return The previously set callback, or `NULL` if no callback was set or the
  3322. * library had not been [initialized](@ref intro_init).
  3323. *
  3324. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3325. *
  3326. * @thread_safety This function must only be called from the main thread.
  3327. *
  3328. * @sa @ref scrolling
  3329. *
  3330. * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
  3331. *
  3332. * @ingroup input
  3333. */
  3334. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
  3335. /*! @brief Sets the file drop callback.
  3336. *
  3337. * This function sets the file drop callback of the specified window, which is
  3338. * called when one or more dragged files are dropped on the window.
  3339. *
  3340. * Because the path array and its strings may have been generated specifically
  3341. * for that event, they are not guaranteed to be valid after the callback has
  3342. * returned. If you wish to use them after the callback returns, you need to
  3343. * make a deep copy.
  3344. *
  3345. * @param[in] window The window whose callback to set.
  3346. * @param[in] cbfun The new file drop callback, or `NULL` to remove the
  3347. * currently set callback.
  3348. * @return The previously set callback, or `NULL` if no callback was set or the
  3349. * library had not been [initialized](@ref intro_init).
  3350. *
  3351. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3352. *
  3353. * @thread_safety This function must only be called from the main thread.
  3354. *
  3355. * @sa @ref path_drop
  3356. *
  3357. * @since Added in version 3.1.
  3358. *
  3359. * @ingroup input
  3360. */
  3361. GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);
  3362. /*! @brief Returns whether the specified joystick is present.
  3363. *
  3364. * This function returns whether the specified joystick is present.
  3365. *
  3366. * @param[in] joy The [joystick](@ref joysticks) to query.
  3367. * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
  3368. *
  3369. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3370. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3371. *
  3372. * @thread_safety This function must only be called from the main thread.
  3373. *
  3374. * @sa @ref joystick
  3375. *
  3376. * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
  3377. *
  3378. * @ingroup input
  3379. */
  3380. GLFWAPI int glfwJoystickPresent(int joy);
  3381. /*! @brief Returns the values of all axes of the specified joystick.
  3382. *
  3383. * This function returns the values of all axes of the specified joystick.
  3384. * Each element in the array is a value between -1.0 and 1.0.
  3385. *
  3386. * Querying a joystick slot with no device present is not an error, but will
  3387. * cause this function to return `NULL`. Call @ref glfwJoystickPresent to
  3388. * check device presence.
  3389. *
  3390. * @param[in] joy The [joystick](@ref joysticks) to query.
  3391. * @param[out] count Where to store the number of axis values in the returned
  3392. * array. This is set to zero if the joystick is not present or an error
  3393. * occurred.
  3394. * @return An array of axis values, or `NULL` if the joystick is not present or
  3395. * an [error](@ref error_handling) occurred.
  3396. *
  3397. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3398. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3399. *
  3400. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  3401. * should not free it yourself. It is valid until the specified joystick is
  3402. * disconnected, this function is called again for that joystick or the library
  3403. * is terminated.
  3404. *
  3405. * @thread_safety This function must only be called from the main thread.
  3406. *
  3407. * @sa @ref joystick_axis
  3408. *
  3409. * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
  3410. *
  3411. * @ingroup input
  3412. */
  3413. GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count);
  3414. /*! @brief Returns the state of all buttons of the specified joystick.
  3415. *
  3416. * This function returns the state of all buttons of the specified joystick.
  3417. * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
  3418. *
  3419. * Querying a joystick slot with no device present is not an error, but will
  3420. * cause this function to return `NULL`. Call @ref glfwJoystickPresent to
  3421. * check device presence.
  3422. *
  3423. * @param[in] joy The [joystick](@ref joysticks) to query.
  3424. * @param[out] count Where to store the number of button states in the returned
  3425. * array. This is set to zero if the joystick is not present or an error
  3426. * occurred.
  3427. * @return An array of button states, or `NULL` if the joystick is not present
  3428. * or an [error](@ref error_handling) occurred.
  3429. *
  3430. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3431. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3432. *
  3433. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  3434. * should not free it yourself. It is valid until the specified joystick is
  3435. * disconnected, this function is called again for that joystick or the library
  3436. * is terminated.
  3437. *
  3438. * @thread_safety This function must only be called from the main thread.
  3439. *
  3440. * @sa @ref joystick_button
  3441. *
  3442. * @since Added in version 2.2.
  3443. * @glfw3 Changed to return a dynamic array.
  3444. *
  3445. * @ingroup input
  3446. */
  3447. GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count);
  3448. /*! @brief Returns the name of the specified joystick.
  3449. *
  3450. * This function returns the name, encoded as UTF-8, of the specified joystick.
  3451. * The returned string is allocated and freed by GLFW. You should not free it
  3452. * yourself.
  3453. *
  3454. * Querying a joystick slot with no device present is not an error, but will
  3455. * cause this function to return `NULL`. Call @ref glfwJoystickPresent to
  3456. * check device presence.
  3457. *
  3458. * @param[in] joy The [joystick](@ref joysticks) to query.
  3459. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  3460. * is not present or an [error](@ref error_handling) occurred.
  3461. *
  3462. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3463. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3464. *
  3465. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  3466. * should not free it yourself. It is valid until the specified joystick is
  3467. * disconnected, this function is called again for that joystick or the library
  3468. * is terminated.
  3469. *
  3470. * @thread_safety This function must only be called from the main thread.
  3471. *
  3472. * @sa @ref joystick_name
  3473. *
  3474. * @since Added in version 3.0.
  3475. *
  3476. * @ingroup input
  3477. */
  3478. GLFWAPI const char* glfwGetJoystickName(int joy);
  3479. /*! @brief Sets the joystick configuration callback.
  3480. *
  3481. * This function sets the joystick configuration callback, or removes the
  3482. * currently set callback. This is called when a joystick is connected to or
  3483. * disconnected from the system.
  3484. *
  3485. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3486. * callback.
  3487. * @return The previously set callback, or `NULL` if no callback was set or the
  3488. * library had not been [initialized](@ref intro_init).
  3489. *
  3490. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3491. *
  3492. * @thread_safety This function must only be called from the main thread.
  3493. *
  3494. * @sa @ref joystick_event
  3495. *
  3496. * @since Added in version 3.2.
  3497. *
  3498. * @ingroup input
  3499. */
  3500. GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun);
  3501. /*! @brief Sets the clipboard to the specified string.
  3502. *
  3503. * This function sets the system clipboard to the specified, UTF-8 encoded
  3504. * string.
  3505. *
  3506. * @param[in] window The window that will own the clipboard contents.
  3507. * @param[in] string A UTF-8 encoded string.
  3508. *
  3509. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3510. * GLFW_PLATFORM_ERROR.
  3511. *
  3512. * @pointer_lifetime The specified string is copied before this function
  3513. * returns.
  3514. *
  3515. * @thread_safety This function must only be called from the main thread.
  3516. *
  3517. * @sa @ref clipboard
  3518. * @sa glfwGetClipboardString
  3519. *
  3520. * @since Added in version 3.0.
  3521. *
  3522. * @ingroup input
  3523. */
  3524. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  3525. /*! @brief Returns the contents of the clipboard as a string.
  3526. *
  3527. * This function returns the contents of the system clipboard, if it contains
  3528. * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
  3529. * if its contents cannot be converted, `NULL` is returned and a @ref
  3530. * GLFW_FORMAT_UNAVAILABLE error is generated.
  3531. *
  3532. * @param[in] window The window that will request the clipboard contents.
  3533. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  3534. * if an [error](@ref error_handling) occurred.
  3535. *
  3536. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3537. * GLFW_PLATFORM_ERROR.
  3538. *
  3539. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  3540. * should not free it yourself. It is valid until the next call to @ref
  3541. * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
  3542. * is terminated.
  3543. *
  3544. * @thread_safety This function must only be called from the main thread.
  3545. *
  3546. * @sa @ref clipboard
  3547. * @sa glfwSetClipboardString
  3548. *
  3549. * @since Added in version 3.0.
  3550. *
  3551. * @ingroup input
  3552. */
  3553. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  3554. /*! @brief Returns the value of the GLFW timer.
  3555. *
  3556. * This function returns the value of the GLFW timer. Unless the timer has
  3557. * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
  3558. * was initialized.
  3559. *
  3560. * The resolution of the timer is system dependent, but is usually on the order
  3561. * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
  3562. * time source on each supported platform.
  3563. *
  3564. * @return The current value, in seconds, or zero if an
  3565. * [error](@ref error_handling) occurred.
  3566. *
  3567. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3568. *
  3569. * @thread_safety This function may be called from any thread. Reading and
  3570. * writing of the internal timer offset is not atomic, so it needs to be
  3571. * externally synchronized with calls to @ref glfwSetTime.
  3572. *
  3573. * @sa @ref time
  3574. *
  3575. * @since Added in version 1.0.
  3576. *
  3577. * @ingroup input
  3578. */
  3579. GLFWAPI double glfwGetTime(void);
  3580. /*! @brief Sets the GLFW timer.
  3581. *
  3582. * This function sets the value of the GLFW timer. It then continues to count
  3583. * up from that value. The value must be a positive finite number less than
  3584. * or equal to 18446744073.0, which is approximately 584.5 years.
  3585. *
  3586. * @param[in] time The new value, in seconds.
  3587. *
  3588. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3589. * GLFW_INVALID_VALUE.
  3590. *
  3591. * @remark The upper limit of the timer is calculated as
  3592. * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
  3593. * storing nanoseconds in 64 bits. The limit may be increased in the future.
  3594. *
  3595. * @thread_safety This function may be called from any thread. Reading and
  3596. * writing of the internal timer offset is not atomic, so it needs to be
  3597. * externally synchronized with calls to @ref glfwGetTime.
  3598. *
  3599. * @sa @ref time
  3600. *
  3601. * @since Added in version 2.2.
  3602. *
  3603. * @ingroup input
  3604. */
  3605. GLFWAPI void glfwSetTime(double time);
  3606. /*! @brief Returns the current value of the raw timer.
  3607. *
  3608. * This function returns the current value of the raw timer, measured in
  3609. * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
  3610. * glfwGetTimerFrequency.
  3611. *
  3612. * @return The value of the timer, or zero if an
  3613. * [error](@ref error_handling) occurred.
  3614. *
  3615. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3616. *
  3617. * @thread_safety This function may be called from any thread.
  3618. *
  3619. * @sa @ref time
  3620. * @sa glfwGetTimerFrequency
  3621. *
  3622. * @since Added in version 3.2.
  3623. *
  3624. * @ingroup input
  3625. */
  3626. GLFWAPI uint64_t glfwGetTimerValue(void);
  3627. /*! @brief Returns the frequency, in Hz, of the raw timer.
  3628. *
  3629. * This function returns the frequency, in Hz, of the raw timer.
  3630. *
  3631. * @return The frequency of the timer, in Hz, or zero if an
  3632. * [error](@ref error_handling) occurred.
  3633. *
  3634. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3635. *
  3636. * @thread_safety This function may be called from any thread.
  3637. *
  3638. * @sa @ref time
  3639. * @sa glfwGetTimerValue
  3640. *
  3641. * @since Added in version 3.2.
  3642. *
  3643. * @ingroup input
  3644. */
  3645. GLFWAPI uint64_t glfwGetTimerFrequency(void);
  3646. /*! @brief Makes the context of the specified window current for the calling
  3647. * thread.
  3648. *
  3649. * This function makes the OpenGL or OpenGL ES context of the specified window
  3650. * current on the calling thread. A context can only be made current on
  3651. * a single thread at a time and each thread can have only a single current
  3652. * context at a time.
  3653. *
  3654. * By default, making a context non-current implicitly forces a pipeline flush.
  3655. * On machines that support `GL_KHR_context_flush_control`, you can control
  3656. * whether a context performs this flush by setting the
  3657. * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint.
  3658. *
  3659. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  3660. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  3661. * error.
  3662. *
  3663. * @param[in] window The window whose context to make current, or `NULL` to
  3664. * detach the current context.
  3665. *
  3666. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3667. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3668. *
  3669. * @thread_safety This function may be called from any thread.
  3670. *
  3671. * @sa @ref context_current
  3672. * @sa glfwGetCurrentContext
  3673. *
  3674. * @since Added in version 3.0.
  3675. *
  3676. * @ingroup context
  3677. */
  3678. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  3679. /*! @brief Returns the window whose context is current on the calling thread.
  3680. *
  3681. * This function returns the window whose OpenGL or OpenGL ES context is
  3682. * current on the calling thread.
  3683. *
  3684. * @return The window whose context is current, or `NULL` if no window's
  3685. * context is current.
  3686. *
  3687. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3688. *
  3689. * @thread_safety This function may be called from any thread.
  3690. *
  3691. * @sa @ref context_current
  3692. * @sa glfwMakeContextCurrent
  3693. *
  3694. * @since Added in version 3.0.
  3695. *
  3696. * @ingroup context
  3697. */
  3698. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  3699. /*! @brief Swaps the front and back buffers of the specified window.
  3700. *
  3701. * This function swaps the front and back buffers of the specified window when
  3702. * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
  3703. * zero, the GPU driver waits the specified number of screen updates before
  3704. * swapping the buffers.
  3705. *
  3706. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  3707. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  3708. * error.
  3709. *
  3710. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  3711. * see `vkQueuePresentKHR` instead.
  3712. *
  3713. * @param[in] window The window whose buffers to swap.
  3714. *
  3715. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3716. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3717. *
  3718. * @remark __EGL:__ The context of the specified window must be current on the
  3719. * calling thread.
  3720. *
  3721. * @thread_safety This function may be called from any thread.
  3722. *
  3723. * @sa @ref buffer_swap
  3724. * @sa glfwSwapInterval
  3725. *
  3726. * @since Added in version 1.0.
  3727. * @glfw3 Added window handle parameter.
  3728. *
  3729. * @ingroup window
  3730. */
  3731. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  3732. /*! @brief Sets the swap interval for the current context.
  3733. *
  3734. * This function sets the swap interval for the current OpenGL or OpenGL ES
  3735. * context, i.e. the number of screen updates to wait from the time @ref
  3736. * glfwSwapBuffers was called before swapping the buffers and returning. This
  3737. * is sometimes called _vertical synchronization_, _vertical retrace
  3738. * synchronization_ or just _vsync_.
  3739. *
  3740. * Contexts that support either of the `WGL_EXT_swap_control_tear` and
  3741. * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,
  3742. * which allow the driver to swap even if a frame arrives a little bit late.
  3743. * You can check for the presence of these extensions using @ref
  3744. * glfwExtensionSupported. For more information about swap tearing, see the
  3745. * extension specifications.
  3746. *
  3747. * A context must be current on the calling thread. Calling this function
  3748. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3749. *
  3750. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  3751. * see the present mode of your swapchain instead.
  3752. *
  3753. * @param[in] interval The minimum number of screen updates to wait for
  3754. * until the buffers are swapped by @ref glfwSwapBuffers.
  3755. *
  3756. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3757. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3758. *
  3759. * @remark This function is not called during context creation, leaving the
  3760. * swap interval set to whatever is the default on that platform. This is done
  3761. * because some swap interval extensions used by GLFW do not allow the swap
  3762. * interval to be reset to zero once it has been set to a non-zero value.
  3763. *
  3764. * @remark Some GPU drivers do not honor the requested swap interval, either
  3765. * because of a user setting that overrides the application's request or due to
  3766. * bugs in the driver.
  3767. *
  3768. * @thread_safety This function may be called from any thread.
  3769. *
  3770. * @sa @ref buffer_swap
  3771. * @sa glfwSwapBuffers
  3772. *
  3773. * @since Added in version 1.0.
  3774. *
  3775. * @ingroup context
  3776. */
  3777. GLFWAPI void glfwSwapInterval(int interval);
  3778. /*! @brief Returns whether the specified extension is available.
  3779. *
  3780. * This function returns whether the specified
  3781. * [API extension](@ref context_glext) is supported by the current OpenGL or
  3782. * OpenGL ES context. It searches both for client API extension and context
  3783. * creation API extensions.
  3784. *
  3785. * A context must be current on the calling thread. Calling this function
  3786. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3787. *
  3788. * As this functions retrieves and searches one or more extension strings each
  3789. * call, it is recommended that you cache its results if it is going to be used
  3790. * frequently. The extension strings will not change during the lifetime of
  3791. * a context, so there is no danger in doing this.
  3792. *
  3793. * This function does not apply to Vulkan. If you are using Vulkan, see @ref
  3794. * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
  3795. * and `vkEnumerateDeviceExtensionProperties` instead.
  3796. *
  3797. * @param[in] extension The ASCII encoded name of the extension.
  3798. * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
  3799. * otherwise.
  3800. *
  3801. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3802. * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
  3803. * GLFW_PLATFORM_ERROR.
  3804. *
  3805. * @thread_safety This function may be called from any thread.
  3806. *
  3807. * @sa @ref context_glext
  3808. * @sa glfwGetProcAddress
  3809. *
  3810. * @since Added in version 1.0.
  3811. *
  3812. * @ingroup context
  3813. */
  3814. GLFWAPI int glfwExtensionSupported(const char* extension);
  3815. /*! @brief Returns the address of the specified function for the current
  3816. * context.
  3817. *
  3818. * This function returns the address of the specified OpenGL or OpenGL ES
  3819. * [core or extension function](@ref context_glext), if it is supported
  3820. * by the current context.
  3821. *
  3822. * A context must be current on the calling thread. Calling this function
  3823. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3824. *
  3825. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  3826. * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
  3827. * `vkGetDeviceProcAddr` instead.
  3828. *
  3829. * @param[in] procname The ASCII encoded name of the function.
  3830. * @return The address of the function, or `NULL` if an
  3831. * [error](@ref error_handling) occurred.
  3832. *
  3833. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3834. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3835. *
  3836. * @remark The address of a given function is not guaranteed to be the same
  3837. * between contexts.
  3838. *
  3839. * @remark This function may return a non-`NULL` address despite the
  3840. * associated version or extension not being available. Always check the
  3841. * context version or extension string first.
  3842. *
  3843. * @pointer_lifetime The returned function pointer is valid until the context
  3844. * is destroyed or the library is terminated.
  3845. *
  3846. * @thread_safety This function may be called from any thread.
  3847. *
  3848. * @sa @ref context_glext
  3849. * @sa glfwExtensionSupported
  3850. *
  3851. * @since Added in version 1.0.
  3852. *
  3853. * @ingroup context
  3854. */
  3855. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  3856. /*! @brief Returns whether the Vulkan loader has been found.
  3857. *
  3858. * This function returns whether the Vulkan loader has been found. This check
  3859. * is performed by @ref glfwInit.
  3860. *
  3861. * The availability of a Vulkan loader does not by itself guarantee that window
  3862. * surface creation or even device creation is possible. Call @ref
  3863. * glfwGetRequiredInstanceExtensions to check whether the extensions necessary
  3864. * for Vulkan surface creation are available and @ref
  3865. * glfwGetPhysicalDevicePresentationSupport to check whether a queue family of
  3866. * a physical device supports image presentation.
  3867. *
  3868. * @return `GLFW_TRUE` if Vulkan is available, or `GLFW_FALSE` otherwise.
  3869. *
  3870. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3871. *
  3872. * @thread_safety This function may be called from any thread.
  3873. *
  3874. * @sa @ref vulkan_support
  3875. *
  3876. * @since Added in version 3.2.
  3877. *
  3878. * @ingroup vulkan
  3879. */
  3880. GLFWAPI int glfwVulkanSupported(void);
  3881. /*! @brief Returns the Vulkan instance extensions required by GLFW.
  3882. *
  3883. * This function returns an array of names of Vulkan instance extensions required
  3884. * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
  3885. * list will always contains `VK_KHR_surface`, so if you don't require any
  3886. * additional extensions you can pass this list directly to the
  3887. * `VkInstanceCreateInfo` struct.
  3888. *
  3889. * If Vulkan is not available on the machine, this function returns `NULL` and
  3890. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  3891. * to check whether Vulkan is available.
  3892. *
  3893. * If Vulkan is available but no set of extensions allowing window surface
  3894. * creation was found, this function returns `NULL`. You may still use Vulkan
  3895. * for off-screen rendering and compute work.
  3896. *
  3897. * @param[out] count Where to store the number of extensions in the returned
  3898. * array. This is set to zero if an error occurred.
  3899. * @return An array of ASCII encoded extension names, or `NULL` if an
  3900. * [error](@ref error_handling) occurred.
  3901. *
  3902. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3903. * GLFW_API_UNAVAILABLE.
  3904. *
  3905. * @remarks Additional extensions may be required by future versions of GLFW.
  3906. * You should check if any extensions you wish to enable are already in the
  3907. * returned array, as it is an error to specify an extension more than once in
  3908. * the `VkInstanceCreateInfo` struct.
  3909. *
  3910. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  3911. * should not free it yourself. It is guaranteed to be valid only until the
  3912. * library is terminated.
  3913. *
  3914. * @thread_safety This function may be called from any thread.
  3915. *
  3916. * @sa @ref vulkan_ext
  3917. * @sa glfwCreateWindowSurface
  3918. *
  3919. * @since Added in version 3.2.
  3920. *
  3921. * @ingroup vulkan
  3922. */
  3923. GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
  3924. #if defined(VK_VERSION_1_0)
  3925. /*! @brief Returns the address of the specified Vulkan instance function.
  3926. *
  3927. * This function returns the address of the specified Vulkan core or extension
  3928. * function for the specified instance. If instance is set to `NULL` it can
  3929. * return any function exported from the Vulkan loader, including at least the
  3930. * following functions:
  3931. *
  3932. * - `vkEnumerateInstanceExtensionProperties`
  3933. * - `vkEnumerateInstanceLayerProperties`
  3934. * - `vkCreateInstance`
  3935. * - `vkGetInstanceProcAddr`
  3936. *
  3937. * If Vulkan is not available on the machine, this function returns `NULL` and
  3938. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  3939. * to check whether Vulkan is available.
  3940. *
  3941. * This function is equivalent to calling `vkGetInstanceProcAddr` with
  3942. * a platform-specific query of the Vulkan loader as a fallback.
  3943. *
  3944. * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
  3945. * functions related to instance creation.
  3946. * @param[in] procname The ASCII encoded name of the function.
  3947. * @return The address of the function, or `NULL` if an
  3948. * [error](@ref error_handling) occurred.
  3949. *
  3950. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3951. * GLFW_API_UNAVAILABLE.
  3952. *
  3953. * @pointer_lifetime The returned function pointer is valid until the library
  3954. * is terminated.
  3955. *
  3956. * @thread_safety This function may be called from any thread.
  3957. *
  3958. * @sa @ref vulkan_proc
  3959. *
  3960. * @since Added in version 3.2.
  3961. *
  3962. * @ingroup vulkan
  3963. */
  3964. GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
  3965. /*! @brief Returns whether the specified queue family can present images.
  3966. *
  3967. * This function returns whether the specified queue family of the specified
  3968. * physical device supports presentation to the platform GLFW was built for.
  3969. *
  3970. * If Vulkan or the required window surface creation instance extensions are
  3971. * not available on the machine, or if the specified instance was not created
  3972. * with the required extensions, this function returns `GLFW_FALSE` and
  3973. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  3974. * to check whether Vulkan is available and @ref
  3975. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  3976. * required.
  3977. *
  3978. * @param[in] instance The instance that the physical device belongs to.
  3979. * @param[in] device The physical device that the queue family belongs to.
  3980. * @param[in] queuefamily The index of the queue family to query.
  3981. * @return `GLFW_TRUE` if the queue family supports presentation, or
  3982. * `GLFW_FALSE` otherwise.
  3983. *
  3984. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3985. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  3986. *
  3987. * @thread_safety This function may be called from any thread. For
  3988. * synchronization details of Vulkan objects, see the Vulkan specification.
  3989. *
  3990. * @sa @ref vulkan_present
  3991. *
  3992. * @since Added in version 3.2.
  3993. *
  3994. * @ingroup vulkan
  3995. */
  3996. GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
  3997. /*! @brief Creates a Vulkan surface for the specified window.
  3998. *
  3999. * This function creates a Vulkan surface for the specified window.
  4000. *
  4001. * If the Vulkan loader was not found at initialization, this function returns
  4002. * `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref GLFW_API_UNAVAILABLE
  4003. * error. Call @ref glfwVulkanSupported to check whether the Vulkan loader was
  4004. * found.
  4005. *
  4006. * If the required window surface creation instance extensions are not
  4007. * available or if the specified instance was not created with these extensions
  4008. * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
  4009. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
  4010. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  4011. * required.
  4012. *
  4013. * The window surface must be destroyed before the specified Vulkan instance.
  4014. * It is the responsibility of the caller to destroy the window surface. GLFW
  4015. * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
  4016. * surface.
  4017. *
  4018. * @param[in] instance The Vulkan instance to create the surface in.
  4019. * @param[in] window The window to create the surface for.
  4020. * @param[in] allocator The allocator to use, or `NULL` to use the default
  4021. * allocator.
  4022. * @param[out] surface Where to store the handle of the surface. This is set
  4023. * to `VK_NULL_HANDLE` if an error occurred.
  4024. * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
  4025. * [error](@ref error_handling) occurred.
  4026. *
  4027. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4028. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  4029. *
  4030. * @remarks If an error occurs before the creation call is made, GLFW returns
  4031. * the Vulkan error code most appropriate for the error. Appropriate use of
  4032. * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
  4033. * eliminate almost all occurrences of these errors.
  4034. *
  4035. * @thread_safety This function may be called from any thread. For
  4036. * synchronization details of Vulkan objects, see the Vulkan specification.
  4037. *
  4038. * @sa @ref vulkan_surface
  4039. * @sa glfwGetRequiredInstanceExtensions
  4040. *
  4041. * @since Added in version 3.2.
  4042. *
  4043. * @ingroup vulkan
  4044. */
  4045. GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
  4046. #endif /*VK_VERSION_1_0*/
  4047. /*************************************************************************
  4048. * Global definition cleanup
  4049. *************************************************************************/
  4050. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  4051. #ifdef GLFW_WINGDIAPI_DEFINED
  4052. #undef WINGDIAPI
  4053. #undef GLFW_WINGDIAPI_DEFINED
  4054. #endif
  4055. #ifdef GLFW_CALLBACK_DEFINED
  4056. #undef CALLBACK
  4057. #undef GLFW_CALLBACK_DEFINED
  4058. #endif
  4059. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  4060. #ifdef __cplusplus
  4061. }
  4062. #endif
  4063. #endif /* _glfw3_h_ */