1 /*************************************************************************
2 * GLFW 3.4 - www.glfw.org
3 * A library for OpenGL, window and input
4 *------------------------------------------------------------------------
5 * Copyright (c) 2002-2006 Marcus Geelnard
6 * Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
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.
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:
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.
21 * 2. Altered source versions must be plainly marked as such, and must not
22 * be misrepresented as being the original software.
24 * 3. This notice may not be removed or altered from any source
27 *************************************************************************/
37 /*************************************************************************
38 * Doxygen documentation
39 *************************************************************************/
42 * @brief The header of the GLFW 3 API.
44 * This is the header file of the GLFW 3 API. It defines all its types and
45 * declares all its functions.
47 * For more information about how to use this file, see @ref build_include.
49 /*! @defgroup context Context reference
50 * @brief Functions and types related to OpenGL and OpenGL ES contexts.
52 * This is the reference documentation for OpenGL and OpenGL ES context related
53 * functions. For more task-oriented information, see the @ref context_guide.
55 /*! @defgroup vulkan Vulkan support reference
56 * @brief Functions and types related to Vulkan.
58 * This is the reference documentation for Vulkan related functions and types.
59 * For more task-oriented information, see the @ref vulkan_guide.
61 /*! @defgroup init Initialization, version and error reference
62 * @brief Functions and types related to initialization and error handling.
64 * This is the reference documentation for initialization and termination of
65 * the library, version management and error handling. For more task-oriented
66 * information, see the @ref intro_guide.
68 /*! @defgroup input Input reference
69 * @brief Functions and types related to input handling.
71 * This is the reference documentation for input related functions and types.
72 * For more task-oriented information, see the @ref input_guide.
74 /*! @defgroup monitor Monitor reference
75 * @brief Functions and types related to monitors.
77 * This is the reference documentation for monitor related functions and types.
78 * For more task-oriented information, see the @ref monitor_guide.
80 /*! @defgroup window Window reference
81 * @brief Functions and types related to windows.
83 * This is the reference documentation for window related functions and types,
84 * including creation, deletion and event polling. For more task-oriented
85 * information, see the @ref window_guide.
89 /*************************************************************************
90 * Compiler- and platform-specific preprocessor work
91 *************************************************************************/
93 /* If we are we on Windows, we want a single define for it.
95 #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
99 /* Include because most Windows GLU headers need wchar_t and
100 * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
101 * Include it unconditionally to avoid surprising side-effects.
105 /* Include because it is needed by Vulkan and related functions.
106 * Include it unconditionally to avoid surprising side-effects.
110 #if defined(GLFW_INCLUDE_VULKAN)
111 #include <vulkan/vulkan.h>
112 #endif /* Vulkan header */
114 /* The Vulkan header may have indirectly included windows.h (because of
115 * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it.
118 /* It is customary to use APIENTRY for OpenGL function pointer declarations on
119 * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
121 #if !defined(APIENTRY)
123 #define APIENTRY __stdcall
127 #define GLFW_APIENTRY_DEFINED
128 #endif /* APIENTRY */
130 /* Some Windows OpenGL headers need this.
132 #if !defined(WINGDIAPI) && defined(_WIN32)
133 #define WINGDIAPI __declspec(dllimport)
134 #define GLFW_WINGDIAPI_DEFINED
135 #endif /* WINGDIAPI */
137 /* Some Windows GLU headers need this.
139 #if !defined(CALLBACK) && defined(_WIN32)
140 #define CALLBACK __stdcall
141 #define GLFW_CALLBACK_DEFINED
142 #endif /* CALLBACK */
144 /* Include the chosen OpenGL or OpenGL ES headers.
146 #if defined(GLFW_INCLUDE_ES1)
149 #if defined(GLFW_INCLUDE_GLEXT)
150 #include <GLES/glext.h>
153 #elif defined(GLFW_INCLUDE_ES2)
155 #include <GLES2/gl2.h>
156 #if defined(GLFW_INCLUDE_GLEXT)
157 #include <GLES2/gl2ext.h>
160 #elif defined(GLFW_INCLUDE_ES3)
162 #include <GLES3/gl3.h>
163 #if defined(GLFW_INCLUDE_GLEXT)
164 #include <GLES2/gl2ext.h>
167 #elif defined(GLFW_INCLUDE_ES31)
169 #include <GLES3/gl31.h>
170 #if defined(GLFW_INCLUDE_GLEXT)
171 #include <GLES2/gl2ext.h>
174 #elif defined(GLFW_INCLUDE_ES32)
176 #include <GLES3/gl32.h>
177 #if defined(GLFW_INCLUDE_GLEXT)
178 #include <GLES2/gl2ext.h>
181 #elif defined(GLFW_INCLUDE_GLCOREARB)
183 #if defined(__APPLE__)
185 #include <OpenGL/gl3.h>
186 #if defined(GLFW_INCLUDE_GLEXT)
187 #include <OpenGL/gl3ext.h>
188 #endif /*GLFW_INCLUDE_GLEXT*/
192 #include <GL/glcorearb.h>
196 #elif defined(GLFW_INCLUDE_GLU)
198 #if defined(__APPLE__)
200 #if defined(GLFW_INCLUDE_GLU)
201 #include <OpenGL/glu.h>
206 #if defined(GLFW_INCLUDE_GLU)
212 #elif !defined(GLFW_INCLUDE_NONE) && \
213 !defined(__gl_h_) && \
214 !defined(__gles1_gl_h_) && \
215 !defined(__gles2_gl2_h_) && \
216 !defined(__gles2_gl3_h_) && \
217 !defined(__gles2_gl31_h_) && \
218 !defined(__gles2_gl32_h_) && \
219 !defined(__gl_glcorearb_h_) && \
220 !defined(__gl2_h_) /*legacy*/ && \
221 !defined(__gl3_h_) /*legacy*/ && \
222 !defined(__gl31_h_) /*legacy*/ && \
223 !defined(__gl32_h_) /*legacy*/ && \
224 !defined(__glcorearb_h_) /*legacy*/ && \
225 !defined(__GL_H__) /*non-standard*/ && \
226 !defined(__gltypes_h_) /*non-standard*/ && \
227 !defined(__glee_h_) /*non-standard*/
229 #if defined(__APPLE__)
231 #if !defined(GLFW_INCLUDE_GLEXT)
232 #define GL_GLEXT_LEGACY
234 #include <OpenGL/gl.h>
239 #if defined(GLFW_INCLUDE_GLEXT)
240 #include <GL/glext.h>
245 #endif /* OpenGL and OpenGL ES headers */
247 #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
248 /* GLFW_DLL must be defined by applications that are linking against the DLL
249 * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
250 * configuration header when compiling the DLL version of the library.
252 #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
255 /* GLFWAPI is used to declare public API functions for export
256 * from the DLL / shared library / dynamic library.
258 #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
259 /* We are building GLFW as a Win32 DLL */
260 #define GLFWAPI __declspec(dllexport)
261 #elif defined(_WIN32) && defined(GLFW_DLL)
262 /* We are calling GLFW as a Win32 DLL */
263 #define GLFWAPI __declspec(dllimport)
264 #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
265 /* We are building GLFW as a shared / dynamic library */
266 #define GLFWAPI __attribute__((visibility("default")))
268 /* We are building or calling GLFW as a static library */
273 /*************************************************************************
275 *************************************************************************/
277 /*! @name GLFW version macros
279 /*! @brief The major version number of the GLFW library.
281 * This is incremented when the API is changed in non-compatible ways.
284 #define GLFW_VERSION_MAJOR 3
285 /*! @brief The minor version number of the GLFW library.
287 * This is incremented when features are added to the API but it remains
288 * backward-compatible.
291 #define GLFW_VERSION_MINOR 4
292 /*! @brief The revision number of the GLFW library.
294 * This is incremented when a bug fix release is made that does not contain any
298 #define GLFW_VERSION_REVISION 0
303 * This is only semantic sugar for the number 1. You can instead use `1` or
304 * `true` or `_True` or `GL_TRUE` or `VK_TRUE` or anything else that is equal
312 * This is only semantic sugar for the number 0. You can instead use `0` or
313 * `false` or `_False` or `GL_FALSE` or `VK_FALSE` or anything else that is
320 /*! @name Key and button actions
322 /*! @brief The key or mouse button was released.
324 * The key or mouse button was released.
328 #define GLFW_RELEASE 0
329 /*! @brief The key or mouse button was pressed.
331 * The key or mouse button was pressed.
336 /*! @brief The key was held down until it repeated.
338 * The key was held down until it repeated.
342 #define GLFW_REPEAT 2
345 /*! @defgroup hat_state Joystick hat states
346 * @brief Joystick hat states.
348 * See [joystick hat input](@ref joystick_hat) for how these are used.
352 #define GLFW_HAT_CENTERED 0
353 #define GLFW_HAT_UP 1
354 #define GLFW_HAT_RIGHT 2
355 #define GLFW_HAT_DOWN 4
356 #define GLFW_HAT_LEFT 8
357 #define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP)
358 #define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
359 #define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
360 #define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
363 /*! @defgroup keys Keyboard keys
364 * @brief Keyboard key IDs.
366 * See [key input](@ref input_key) for how these are used.
368 * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
369 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
370 * put in the 256+ range).
372 * The naming of the key codes follow these rules:
373 * - The US keyboard layout is used
374 * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
376 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
377 * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
378 * correspond to the Unicode standard (usually for brevity)
379 * - Keys that lack a clear US mapping are named "WORLD_x"
380 * - For non-printable keys, custom names are used (e.g. "F4",
387 /* The unknown key */
388 #define GLFW_KEY_UNKNOWN -1
391 #define GLFW_KEY_SPACE 32
392 #define GLFW_KEY_APOSTROPHE 39 /* ' */
393 #define GLFW_KEY_COMMA 44 /* , */
394 #define GLFW_KEY_MINUS 45 /* - */
395 #define GLFW_KEY_PERIOD 46 /* . */
396 #define GLFW_KEY_SLASH 47 /* / */
397 #define GLFW_KEY_0 48
398 #define GLFW_KEY_1 49
399 #define GLFW_KEY_2 50
400 #define GLFW_KEY_3 51
401 #define GLFW_KEY_4 52
402 #define GLFW_KEY_5 53
403 #define GLFW_KEY_6 54
404 #define GLFW_KEY_7 55
405 #define GLFW_KEY_8 56
406 #define GLFW_KEY_9 57
407 #define GLFW_KEY_SEMICOLON 59 /* ; */
408 #define GLFW_KEY_EQUAL 61 /* = */
409 #define GLFW_KEY_A 65
410 #define GLFW_KEY_B 66
411 #define GLFW_KEY_C 67
412 #define GLFW_KEY_D 68
413 #define GLFW_KEY_E 69
414 #define GLFW_KEY_F 70
415 #define GLFW_KEY_G 71
416 #define GLFW_KEY_H 72
417 #define GLFW_KEY_I 73
418 #define GLFW_KEY_J 74
419 #define GLFW_KEY_K 75
420 #define GLFW_KEY_L 76
421 #define GLFW_KEY_M 77
422 #define GLFW_KEY_N 78
423 #define GLFW_KEY_O 79
424 #define GLFW_KEY_P 80
425 #define GLFW_KEY_Q 81
426 #define GLFW_KEY_R 82
427 #define GLFW_KEY_S 83
428 #define GLFW_KEY_T 84
429 #define GLFW_KEY_U 85
430 #define GLFW_KEY_V 86
431 #define GLFW_KEY_W 87
432 #define GLFW_KEY_X 88
433 #define GLFW_KEY_Y 89
434 #define GLFW_KEY_Z 90
435 #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
436 #define GLFW_KEY_BACKSLASH 92 /* \ */
437 #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
438 #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
439 #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
440 #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
443 #define GLFW_KEY_ESCAPE 256
444 #define GLFW_KEY_ENTER 257
445 #define GLFW_KEY_TAB 258
446 #define GLFW_KEY_BACKSPACE 259
447 #define GLFW_KEY_INSERT 260
448 #define GLFW_KEY_DELETE 261
449 #define GLFW_KEY_RIGHT 262
450 #define GLFW_KEY_LEFT 263
451 #define GLFW_KEY_DOWN 264
452 #define GLFW_KEY_UP 265
453 #define GLFW_KEY_PAGE_UP 266
454 #define GLFW_KEY_PAGE_DOWN 267
455 #define GLFW_KEY_HOME 268
456 #define GLFW_KEY_END 269
457 #define GLFW_KEY_CAPS_LOCK 280
458 #define GLFW_KEY_SCROLL_LOCK 281
459 #define GLFW_KEY_NUM_LOCK 282
460 #define GLFW_KEY_PRINT_SCREEN 283
461 #define GLFW_KEY_PAUSE 284
462 #define GLFW_KEY_F1 290
463 #define GLFW_KEY_F2 291
464 #define GLFW_KEY_F3 292
465 #define GLFW_KEY_F4 293
466 #define GLFW_KEY_F5 294
467 #define GLFW_KEY_F6 295
468 #define GLFW_KEY_F7 296
469 #define GLFW_KEY_F8 297
470 #define GLFW_KEY_F9 298
471 #define GLFW_KEY_F10 299
472 #define GLFW_KEY_F11 300
473 #define GLFW_KEY_F12 301
474 #define GLFW_KEY_F13 302
475 #define GLFW_KEY_F14 303
476 #define GLFW_KEY_F15 304
477 #define GLFW_KEY_F16 305
478 #define GLFW_KEY_F17 306
479 #define GLFW_KEY_F18 307
480 #define GLFW_KEY_F19 308
481 #define GLFW_KEY_F20 309
482 #define GLFW_KEY_F21 310
483 #define GLFW_KEY_F22 311
484 #define GLFW_KEY_F23 312
485 #define GLFW_KEY_F24 313
486 #define GLFW_KEY_F25 314
487 #define GLFW_KEY_KP_0 320
488 #define GLFW_KEY_KP_1 321
489 #define GLFW_KEY_KP_2 322
490 #define GLFW_KEY_KP_3 323
491 #define GLFW_KEY_KP_4 324
492 #define GLFW_KEY_KP_5 325
493 #define GLFW_KEY_KP_6 326
494 #define GLFW_KEY_KP_7 327
495 #define GLFW_KEY_KP_8 328
496 #define GLFW_KEY_KP_9 329
497 #define GLFW_KEY_KP_DECIMAL 330
498 #define GLFW_KEY_KP_DIVIDE 331
499 #define GLFW_KEY_KP_MULTIPLY 332
500 #define GLFW_KEY_KP_SUBTRACT 333
501 #define GLFW_KEY_KP_ADD 334
502 #define GLFW_KEY_KP_ENTER 335
503 #define GLFW_KEY_KP_EQUAL 336
504 #define GLFW_KEY_LEFT_SHIFT 340
505 #define GLFW_KEY_LEFT_CONTROL 341
506 #define GLFW_KEY_LEFT_ALT 342
507 #define GLFW_KEY_LEFT_SUPER 343
508 #define GLFW_KEY_RIGHT_SHIFT 344
509 #define GLFW_KEY_RIGHT_CONTROL 345
510 #define GLFW_KEY_RIGHT_ALT 346
511 #define GLFW_KEY_RIGHT_SUPER 347
512 #define GLFW_KEY_MENU 348
514 #define GLFW_KEY_LAST GLFW_KEY_MENU
518 /*! @defgroup mods Modifier key flags
519 * @brief Modifier key flags.
521 * See [key input](@ref input_key) for how these are used.
526 /*! @brief If this bit is set one or more Shift keys were held down.
528 * If this bit is set one or more Shift keys were held down.
530 #define GLFW_MOD_SHIFT 0x0001
531 /*! @brief If this bit is set one or more Control keys were held down.
533 * If this bit is set one or more Control keys were held down.
535 #define GLFW_MOD_CONTROL 0x0002
536 /*! @brief If this bit is set one or more Alt keys were held down.
538 * If this bit is set one or more Alt keys were held down.
540 #define GLFW_MOD_ALT 0x0004
541 /*! @brief If this bit is set one or more Super keys were held down.
543 * If this bit is set one or more Super keys were held down.
545 #define GLFW_MOD_SUPER 0x0008
546 /*! @brief If this bit is set the Caps Lock key is enabled.
548 * If this bit is set the Caps Lock key is enabled and the @ref
549 * GLFW_LOCK_KEY_MODS input mode is set.
551 #define GLFW_MOD_CAPS_LOCK 0x0010
552 /*! @brief If this bit is set the Num Lock key is enabled.
554 * If this bit is set the Num Lock key is enabled and the @ref
555 * GLFW_LOCK_KEY_MODS input mode is set.
557 #define GLFW_MOD_NUM_LOCK 0x0020
561 /*! @defgroup buttons Mouse buttons
562 * @brief Mouse button IDs.
564 * See [mouse button input](@ref input_mouse_button) for how these are used.
568 #define GLFW_MOUSE_BUTTON_1 0
569 #define GLFW_MOUSE_BUTTON_2 1
570 #define GLFW_MOUSE_BUTTON_3 2
571 #define GLFW_MOUSE_BUTTON_4 3
572 #define GLFW_MOUSE_BUTTON_5 4
573 #define GLFW_MOUSE_BUTTON_6 5
574 #define GLFW_MOUSE_BUTTON_7 6
575 #define GLFW_MOUSE_BUTTON_8 7
576 #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
577 #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
578 #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
579 #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
582 /*! @defgroup joysticks Joysticks
583 * @brief Joystick IDs.
585 * See [joystick input](@ref joystick) for how these are used.
589 #define GLFW_JOYSTICK_1 0
590 #define GLFW_JOYSTICK_2 1
591 #define GLFW_JOYSTICK_3 2
592 #define GLFW_JOYSTICK_4 3
593 #define GLFW_JOYSTICK_5 4
594 #define GLFW_JOYSTICK_6 5
595 #define GLFW_JOYSTICK_7 6
596 #define GLFW_JOYSTICK_8 7
597 #define GLFW_JOYSTICK_9 8
598 #define GLFW_JOYSTICK_10 9
599 #define GLFW_JOYSTICK_11 10
600 #define GLFW_JOYSTICK_12 11
601 #define GLFW_JOYSTICK_13 12
602 #define GLFW_JOYSTICK_14 13
603 #define GLFW_JOYSTICK_15 14
604 #define GLFW_JOYSTICK_16 15
605 #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
608 /*! @defgroup gamepad_buttons Gamepad buttons
609 * @brief Gamepad buttons.
611 * See @ref gamepad for how these are used.
615 #define GLFW_GAMEPAD_BUTTON_A 0
616 #define GLFW_GAMEPAD_BUTTON_B 1
617 #define GLFW_GAMEPAD_BUTTON_X 2
618 #define GLFW_GAMEPAD_BUTTON_Y 3
619 #define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
620 #define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
621 #define GLFW_GAMEPAD_BUTTON_BACK 6
622 #define GLFW_GAMEPAD_BUTTON_START 7
623 #define GLFW_GAMEPAD_BUTTON_GUIDE 8
624 #define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
625 #define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
626 #define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
627 #define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
628 #define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
629 #define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
630 #define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
632 #define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
633 #define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
634 #define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
635 #define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
638 /*! @defgroup gamepad_axes Gamepad axes
639 * @brief Gamepad axes.
641 * See @ref gamepad for how these are used.
645 #define GLFW_GAMEPAD_AXIS_LEFT_X 0
646 #define GLFW_GAMEPAD_AXIS_LEFT_Y 1
647 #define GLFW_GAMEPAD_AXIS_RIGHT_X 2
648 #define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
649 #define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
650 #define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
651 #define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
654 /*! @defgroup errors Error codes
655 * @brief Error codes.
657 * See [error handling](@ref error_handling) for how these are used.
661 /*! @brief No error has occurred.
663 * No error has occurred.
667 #define GLFW_NO_ERROR 0
668 /*! @brief GLFW has not been initialized.
670 * This occurs if a GLFW function was called that must not be called unless the
671 * library is [initialized](@ref intro_init).
673 * @analysis Application programmer error. Initialize GLFW before calling any
674 * function that requires initialization.
676 #define GLFW_NOT_INITIALIZED 0x00010001
677 /*! @brief No context is current for this thread.
679 * This occurs if a GLFW function was called that needs and operates on the
680 * current OpenGL or OpenGL ES context but no context is current on the calling
681 * thread. One such function is @ref glfwSwapInterval.
683 * @analysis Application programmer error. Ensure a context is current before
684 * calling functions that require a current context.
686 #define GLFW_NO_CURRENT_CONTEXT 0x00010002
687 /*! @brief One of the arguments to the function was an invalid enum value.
689 * One of the arguments to the function was an invalid enum value, for example
690 * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
692 * @analysis Application programmer error. Fix the offending call.
694 #define GLFW_INVALID_ENUM 0x00010003
695 /*! @brief One of the arguments to the function was an invalid value.
697 * One of the arguments to the function was an invalid value, for example
698 * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
700 * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
701 * result in a @ref GLFW_VERSION_UNAVAILABLE error.
703 * @analysis Application programmer error. Fix the offending call.
705 #define GLFW_INVALID_VALUE 0x00010004
706 /*! @brief A memory allocation failed.
708 * A memory allocation failed.
710 * @analysis A bug in GLFW or the underlying operating system. Report the bug
711 * to our [issue tracker](https://github.com/glfw/glfw/issues).
713 #define GLFW_OUT_OF_MEMORY 0x00010005
714 /*! @brief GLFW could not find support for the requested API on the system.
716 * GLFW could not find support for the requested API on the system.
718 * @analysis The installed graphics driver does not support the requested
719 * API, or does not support it via the chosen context creation backend.
720 * Below are a few examples.
723 * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
724 * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
725 * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
726 * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
727 * driver. Older graphics drivers do not support Vulkan.
729 #define GLFW_API_UNAVAILABLE 0x00010006
730 /*! @brief The requested OpenGL or OpenGL ES version is not available.
732 * The requested OpenGL or OpenGL ES version (including any requested context
733 * or framebuffer hints) is not available on this machine.
735 * @analysis The machine does not support your requirements. If your
736 * application is sufficiently flexible, downgrade your requirements and try
737 * again. Otherwise, inform the user that their machine does not match your
741 * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
742 * comes out before the 4.x series gets that far, also fail with this error and
743 * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
746 #define GLFW_VERSION_UNAVAILABLE 0x00010007
747 /*! @brief A platform-specific error occurred that does not match any of the
748 * more specific categories.
750 * A platform-specific error occurred that does not match any of the more
751 * specific categories.
753 * @analysis A bug or configuration error in GLFW, the underlying operating
754 * system or its drivers, or a lack of required resources. Report the issue to
755 * our [issue tracker](https://github.com/glfw/glfw/issues).
757 #define GLFW_PLATFORM_ERROR 0x00010008
758 /*! @brief The requested format is not supported or available.
760 * If emitted during window creation, the requested pixel format is not
763 * If emitted when querying the clipboard, the contents of the clipboard could
764 * not be converted to the requested format.
766 * @analysis If emitted during window creation, one or more
767 * [hard constraints](@ref window_hints_hard) did not match any of the
768 * available pixel formats. If your application is sufficiently flexible,
769 * downgrade your requirements and try again. Otherwise, inform the user that
770 * their machine does not match your requirements.
773 * If emitted when querying the clipboard, ignore the error or report it to
774 * the user, as appropriate.
776 #define GLFW_FORMAT_UNAVAILABLE 0x00010009
777 /*! @brief The specified window does not have an OpenGL or OpenGL ES context.
779 * A window that does not have an OpenGL or OpenGL ES context was passed to
780 * a function that requires it to have one.
782 * @analysis Application programmer error. Fix the offending call.
784 #define GLFW_NO_WINDOW_CONTEXT 0x0001000A
785 /*! @brief The specified cursor shape is not available.
787 * The specified standard cursor shape is not available, either because the
788 * current system cursor theme does not provide it or because it is not
789 * available on the platform.
791 * @analysis Platform or system settings limitation. Pick another
792 * [standard cursor shape](@ref shapes) or create a
793 * [custom cursor](@ref cursor_custom).
795 #define GLFW_CURSOR_UNAVAILABLE 0x0001000B
796 /*! @brief The requested feature is not provided by the platform.
798 * The requested feature is not provided by the platform, so GLFW is unable to
799 * implement it. The documentation for each function notes if it could emit
802 * @analysis Platform or platform version limitation. The error can be ignored
803 * unless the feature is critical to the application.
806 * A function call that emits this error has no effect other than the error and
807 * updating any existing out parameters.
809 #define GLFW_FEATURE_UNAVAILABLE 0x0001000C
810 /*! @brief The requested feature is not implemented for the platform.
812 * The requested feature has not yet been implemented in GLFW for this platform.
814 * @analysis An incomplete implementation of GLFW for this platform, hopefully
815 * fixed in a future release. The error can be ignored unless the feature is
816 * critical to the application.
819 * A function call that emits this error has no effect other than the error and
820 * updating any existing out parameters.
822 #define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
825 /*! @addtogroup window
827 /*! @brief Input focus window hint and attribute
829 * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
830 * [window attribute](@ref GLFW_FOCUSED_attrib).
832 #define GLFW_FOCUSED 0x00020001
833 /*! @brief Window iconification window attribute
835 * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
837 #define GLFW_ICONIFIED 0x00020002
838 /*! @brief Window resize-ability window hint and attribute
840 * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
841 * [window attribute](@ref GLFW_RESIZABLE_attrib).
843 #define GLFW_RESIZABLE 0x00020003
844 /*! @brief Window visibility window hint and attribute
846 * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
847 * [window attribute](@ref GLFW_VISIBLE_attrib).
849 #define GLFW_VISIBLE 0x00020004
850 /*! @brief Window decoration window hint and attribute
852 * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
853 * [window attribute](@ref GLFW_DECORATED_attrib).
855 #define GLFW_DECORATED 0x00020005
856 /*! @brief Window auto-iconification window hint and attribute
858 * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
859 * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
861 #define GLFW_AUTO_ICONIFY 0x00020006
862 /*! @brief Window decoration window hint and attribute
864 * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
865 * [window attribute](@ref GLFW_FLOATING_attrib).
867 #define GLFW_FLOATING 0x00020007
868 /*! @brief Window maximization window hint and attribute
870 * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
871 * [window attribute](@ref GLFW_MAXIMIZED_attrib).
873 #define GLFW_MAXIMIZED 0x00020008
874 /*! @brief Cursor centering window hint
876 * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
878 #define GLFW_CENTER_CURSOR 0x00020009
879 /*! @brief Window framebuffer transparency hint and attribute
881 * Window framebuffer transparency
882 * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
883 * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
885 #define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
886 /*! @brief Mouse cursor hover window attribute.
888 * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
890 #define GLFW_HOVERED 0x0002000B
891 /*! @brief Input focus on calling show window hint and attribute
893 * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
894 * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
896 #define GLFW_FOCUS_ON_SHOW 0x0002000C
898 /*! @brief Mouse input transparency window hint and attribute
900 * Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or
901 * [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
903 #define GLFW_MOUSE_PASSTHROUGH 0x0002000D
905 /*! @brief Framebuffer bit depth hint.
907 * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
909 #define GLFW_RED_BITS 0x00021001
910 /*! @brief Framebuffer bit depth hint.
912 * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
914 #define GLFW_GREEN_BITS 0x00021002
915 /*! @brief Framebuffer bit depth hint.
917 * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
919 #define GLFW_BLUE_BITS 0x00021003
920 /*! @brief Framebuffer bit depth hint.
922 * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
924 #define GLFW_ALPHA_BITS 0x00021004
925 /*! @brief Framebuffer bit depth hint.
927 * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
929 #define GLFW_DEPTH_BITS 0x00021005
930 /*! @brief Framebuffer bit depth hint.
932 * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
934 #define GLFW_STENCIL_BITS 0x00021006
935 /*! @brief Framebuffer bit depth hint.
937 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
939 #define GLFW_ACCUM_RED_BITS 0x00021007
940 /*! @brief Framebuffer bit depth hint.
942 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
944 #define GLFW_ACCUM_GREEN_BITS 0x00021008
945 /*! @brief Framebuffer bit depth hint.
947 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
949 #define GLFW_ACCUM_BLUE_BITS 0x00021009
950 /*! @brief Framebuffer bit depth hint.
952 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
954 #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
955 /*! @brief Framebuffer auxiliary buffer hint.
957 * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
959 #define GLFW_AUX_BUFFERS 0x0002100B
960 /*! @brief OpenGL stereoscopic rendering hint.
962 * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
964 #define GLFW_STEREO 0x0002100C
965 /*! @brief Framebuffer MSAA samples hint.
967 * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
969 #define GLFW_SAMPLES 0x0002100D
970 /*! @brief Framebuffer sRGB hint.
972 * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
974 #define GLFW_SRGB_CAPABLE 0x0002100E
975 /*! @brief Monitor refresh rate hint.
977 * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
979 #define GLFW_REFRESH_RATE 0x0002100F
980 /*! @brief Framebuffer double buffering hint.
982 * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
984 #define GLFW_DOUBLEBUFFER 0x00021010
986 /*! @brief Context client API hint and attribute.
988 * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
989 * [attribute](@ref GLFW_CLIENT_API_attrib).
991 #define GLFW_CLIENT_API 0x00022001
992 /*! @brief Context client API major version hint and attribute.
994 * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint)
995 * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib).
997 #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
998 /*! @brief Context client API minor version hint and attribute.
1000 * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint)
1001 * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
1003 #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
1004 /*! @brief Context client API revision number hint and attribute.
1006 * Context client API revision number
1007 * [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
1009 #define GLFW_CONTEXT_REVISION 0x00022004
1010 /*! @brief Context robustness hint and attribute.
1012 * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint)
1013 * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib).
1015 #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
1016 /*! @brief OpenGL forward-compatibility hint and attribute.
1018 * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
1019 * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
1021 #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
1022 /*! @brief Debug mode context hint and attribute.
1024 * Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and
1025 * [attribute](@ref GLFW_CONTEXT_DEBUG_attrib).
1027 #define GLFW_CONTEXT_DEBUG 0x00022007
1028 /*! @brief Legacy name for compatibility.
1030 * This is an alias for compatibility with earlier versions.
1032 #define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG
1033 /*! @brief OpenGL profile hint and attribute.
1035 * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
1036 * [attribute](@ref GLFW_OPENGL_PROFILE_attrib).
1038 #define GLFW_OPENGL_PROFILE 0x00022008
1039 /*! @brief Context flush-on-release hint and attribute.
1041 * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and
1042 * [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib).
1044 #define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
1045 /*! @brief Context error suppression hint and attribute.
1047 * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and
1048 * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib).
1050 #define GLFW_CONTEXT_NO_ERROR 0x0002200A
1051 /*! @brief Context creation API hint and attribute.
1053 * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and
1054 * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
1056 #define GLFW_CONTEXT_CREATION_API 0x0002200B
1057 /*! @brief Window content area scaling window
1058 * [window hint](@ref GLFW_SCALE_TO_MONITOR).
1060 #define GLFW_SCALE_TO_MONITOR 0x0002200C
1061 /*! @brief macOS specific
1062 * [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint).
1064 #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
1065 /*! @brief macOS specific
1066 * [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
1068 #define GLFW_COCOA_FRAME_NAME 0x00023002
1069 /*! @brief macOS specific
1070 * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint).
1072 #define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
1073 /*! @brief X11 specific
1074 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1076 #define GLFW_X11_CLASS_NAME 0x00024001
1077 /*! @brief X11 specific
1078 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1080 #define GLFW_X11_INSTANCE_NAME 0x00024002
1081 #define GLFW_WIN32_KEYBOARD_MENU 0x00025001
1084 #define GLFW_NO_API 0
1085 #define GLFW_OPENGL_API 0x00030001
1086 #define GLFW_OPENGL_ES_API 0x00030002
1088 #define GLFW_NO_ROBUSTNESS 0
1089 #define GLFW_NO_RESET_NOTIFICATION 0x00031001
1090 #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
1092 #define GLFW_OPENGL_ANY_PROFILE 0
1093 #define GLFW_OPENGL_CORE_PROFILE 0x00032001
1094 #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
1096 #define GLFW_CURSOR 0x00033001
1097 #define GLFW_STICKY_KEYS 0x00033002
1098 #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
1099 #define GLFW_LOCK_KEY_MODS 0x00033004
1100 #define GLFW_RAW_MOUSE_MOTION 0x00033005
1102 #define GLFW_CURSOR_NORMAL 0x00034001
1103 #define GLFW_CURSOR_HIDDEN 0x00034002
1104 #define GLFW_CURSOR_DISABLED 0x00034003
1106 #define GLFW_ANY_RELEASE_BEHAVIOR 0
1107 #define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
1108 #define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
1110 #define GLFW_NATIVE_CONTEXT_API 0x00036001
1111 #define GLFW_EGL_CONTEXT_API 0x00036002
1112 #define GLFW_OSMESA_CONTEXT_API 0x00036003
1114 #define GLFW_ANGLE_PLATFORM_TYPE_NONE 0x00037001
1115 #define GLFW_ANGLE_PLATFORM_TYPE_OPENGL 0x00037002
1116 #define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
1117 #define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004
1118 #define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005
1119 #define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007
1120 #define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008
1122 /*! @defgroup shapes Standard cursor shapes
1123 * @brief Standard system cursor shapes.
1125 * These are the [standard cursor shapes](@ref cursor_standard) that can be
1126 * requested from the window system.
1131 /*! @brief The regular arrow cursor shape.
1133 * The regular arrow cursor shape.
1135 #define GLFW_ARROW_CURSOR 0x00036001
1136 /*! @brief The text input I-beam cursor shape.
1138 * The text input I-beam cursor shape.
1140 #define GLFW_IBEAM_CURSOR 0x00036002
1141 /*! @brief The crosshair cursor shape.
1143 * The crosshair cursor shape.
1145 #define GLFW_CROSSHAIR_CURSOR 0x00036003
1146 /*! @brief The pointing hand cursor shape.
1148 * The pointing hand cursor shape.
1150 #define GLFW_POINTING_HAND_CURSOR 0x00036004
1151 /*! @brief The horizontal resize/move arrow shape.
1153 * The horizontal resize/move arrow shape. This is usually a horizontal
1154 * double-headed arrow.
1156 #define GLFW_RESIZE_EW_CURSOR 0x00036005
1157 /*! @brief The vertical resize/move arrow shape.
1159 * The vertical resize/move shape. This is usually a vertical double-headed
1162 #define GLFW_RESIZE_NS_CURSOR 0x00036006
1163 /*! @brief The top-left to bottom-right diagonal resize/move arrow shape.
1165 * The top-left to bottom-right diagonal resize/move shape. This is usually
1166 * a diagonal double-headed arrow.
1168 * @note @macos This shape is provided by a private system API and may fail
1169 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1171 * @note @x11 This shape is provided by a newer standard not supported by all
1174 * @note @wayland This shape is provided by a newer standard not supported by
1175 * all cursor themes.
1177 #define GLFW_RESIZE_NWSE_CURSOR 0x00036007
1178 /*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
1180 * The top-right to bottom-left diagonal resize/move shape. This is usually
1181 * a diagonal double-headed arrow.
1183 * @note @macos This shape is provided by a private system API and may fail
1184 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1186 * @note @x11 This shape is provided by a newer standard not supported by all
1189 * @note @wayland This shape is provided by a newer standard not supported by
1190 * all cursor themes.
1192 #define GLFW_RESIZE_NESW_CURSOR 0x00036008
1193 /*! @brief The omni-directional resize/move cursor shape.
1195 * The omni-directional resize cursor/move shape. This is usually either
1196 * a combined horizontal and vertical double-headed arrow or a grabbing hand.
1198 #define GLFW_RESIZE_ALL_CURSOR 0x00036009
1199 /*! @brief The operation-not-allowed shape.
1201 * The operation-not-allowed shape. This is usually a circle with a diagonal
1204 * @note @x11 This shape is provided by a newer standard not supported by all
1207 * @note @wayland This shape is provided by a newer standard not supported by
1208 * all cursor themes.
1210 #define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
1211 /*! @brief Legacy name for compatibility.
1213 * This is an alias for compatibility with earlier versions.
1215 #define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR
1216 /*! @brief Legacy name for compatibility.
1218 * This is an alias for compatibility with earlier versions.
1220 #define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR
1221 /*! @brief Legacy name for compatibility.
1223 * This is an alias for compatibility with earlier versions.
1225 #define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR
1228 #define GLFW_CONNECTED 0x00040001
1229 #define GLFW_DISCONNECTED 0x00040002
1231 /*! @addtogroup init
1233 /*! @brief Joystick hat buttons init hint.
1235 * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
1237 #define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
1238 /*! @brief ANGLE rendering backend init hint.
1240 * ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
1242 #define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
1243 /*! @brief macOS specific init hint.
1245 * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
1247 #define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
1248 /*! @brief macOS specific init hint.
1250 * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
1252 #define GLFW_COCOA_MENUBAR 0x00051002
1255 #define GLFW_DONT_CARE -1
1258 /*************************************************************************
1260 *************************************************************************/
1262 /*! @brief Client API function pointer type.
1264 * Generic function pointer used for returning client API function pointers
1265 * without forcing a cast from a regular pointer.
1267 * @sa @ref context_glext
1268 * @sa @ref glfwGetProcAddress
1270 * @since Added in version 3.0.
1274 typedef void (*GLFWglproc)(void);
1276 /*! @brief Vulkan API function pointer type.
1278 * Generic function pointer used for returning Vulkan API function pointers
1279 * without forcing a cast from a regular pointer.
1281 * @sa @ref vulkan_proc
1282 * @sa @ref glfwGetInstanceProcAddress
1284 * @since Added in version 3.2.
1288 typedef void (*GLFWvkproc)(void);
1290 /*! @brief Opaque monitor object.
1292 * Opaque monitor object.
1294 * @see @ref monitor_object
1296 * @since Added in version 3.0.
1300 typedef struct GLFWmonitor GLFWmonitor;
1302 /*! @brief Opaque window object.
1304 * Opaque window object.
1306 * @see @ref window_object
1308 * @since Added in version 3.0.
1312 typedef struct GLFWwindow GLFWwindow;
1314 /*! @brief Opaque cursor object.
1316 * Opaque cursor object.
1318 * @see @ref cursor_object
1320 * @since Added in version 3.1.
1324 typedef struct GLFWcursor GLFWcursor;
1326 /*! @brief The function pointer type for error callbacks.
1328 * This is the function pointer type for error callbacks. An error callback
1329 * function has the following signature:
1331 * void callback_name(int error_code, const char* description)
1334 * @param[in] error_code An [error code](@ref errors). Future releases may add
1336 * @param[in] description A UTF-8 encoded string describing the error.
1338 * @pointer_lifetime The error description string is valid until the callback
1341 * @sa @ref error_handling
1342 * @sa @ref glfwSetErrorCallback
1344 * @since Added in version 3.0.
1348 typedef void (* GLFWerrorfun)(int,const char*);
1350 /*! @brief The function pointer type for window position callbacks.
1352 * This is the function pointer type for window position callbacks. A window
1353 * position callback function has the following signature:
1355 * void callback_name(GLFWwindow* window, int xpos, int ypos)
1358 * @param[in] window The window that was moved.
1359 * @param[in] xpos The new x-coordinate, in screen coordinates, of the
1360 * upper-left corner of the content area of the window.
1361 * @param[in] ypos The new y-coordinate, in screen coordinates, of the
1362 * upper-left corner of the content area of the window.
1364 * @sa @ref window_pos
1365 * @sa @ref glfwSetWindowPosCallback
1367 * @since Added in version 3.0.
1371 typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
1373 /*! @brief The function pointer type for window size callbacks.
1375 * This is the function pointer type for window size callbacks. A window size
1376 * callback function has the following signature:
1378 * void callback_name(GLFWwindow* window, int width, int height)
1381 * @param[in] window The window that was resized.
1382 * @param[in] width The new width, in screen coordinates, of the window.
1383 * @param[in] height The new height, in screen coordinates, of the window.
1385 * @sa @ref window_size
1386 * @sa @ref glfwSetWindowSizeCallback
1388 * @since Added in version 1.0.
1389 * @glfw3 Added window handle parameter.
1393 typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
1395 /*! @brief The function pointer type for window close callbacks.
1397 * This is the function pointer type for window close callbacks. A window
1398 * close callback function has the following signature:
1400 * void function_name(GLFWwindow* window)
1403 * @param[in] window The window that the user attempted to close.
1405 * @sa @ref window_close
1406 * @sa @ref glfwSetWindowCloseCallback
1408 * @since Added in version 2.5.
1409 * @glfw3 Added window handle parameter.
1413 typedef void (* GLFWwindowclosefun)(GLFWwindow*);
1415 /*! @brief The function pointer type for window content refresh callbacks.
1417 * This is the function pointer type for window content refresh callbacks.
1418 * A window content refresh callback function has the following signature:
1420 * void function_name(GLFWwindow* window);
1423 * @param[in] window The window whose content needs to be refreshed.
1425 * @sa @ref window_refresh
1426 * @sa @ref glfwSetWindowRefreshCallback
1428 * @since Added in version 2.5.
1429 * @glfw3 Added window handle parameter.
1433 typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
1435 /*! @brief The function pointer type for window focus callbacks.
1437 * This is the function pointer type for window focus callbacks. A window
1438 * focus callback function has the following signature:
1440 * void function_name(GLFWwindow* window, int focused)
1443 * @param[in] window The window that gained or lost input focus.
1444 * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
1445 * `GLFW_FALSE` if it lost it.
1447 * @sa @ref window_focus
1448 * @sa @ref glfwSetWindowFocusCallback
1450 * @since Added in version 3.0.
1454 typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
1456 /*! @brief The function pointer type for window iconify callbacks.
1458 * This is the function pointer type for window iconify callbacks. A window
1459 * iconify callback function has the following signature:
1461 * void function_name(GLFWwindow* window, int iconified)
1464 * @param[in] window The window that was iconified or restored.
1465 * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
1466 * `GLFW_FALSE` if it was restored.
1468 * @sa @ref window_iconify
1469 * @sa @ref glfwSetWindowIconifyCallback
1471 * @since Added in version 3.0.
1475 typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
1477 /*! @brief The function pointer type for window maximize callbacks.
1479 * This is the function pointer type for window maximize callbacks. A window
1480 * maximize callback function has the following signature:
1482 * void function_name(GLFWwindow* window, int maximized)
1485 * @param[in] window The window that was maximized or restored.
1486 * @param[in] maximized `GLFW_TRUE` if the window was maximized, or
1487 * `GLFW_FALSE` if it was restored.
1489 * @sa @ref window_maximize
1490 * @sa glfwSetWindowMaximizeCallback
1492 * @since Added in version 3.3.
1496 typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
1498 /*! @brief The function pointer type for framebuffer size callbacks.
1500 * This is the function pointer type for framebuffer size callbacks.
1501 * A framebuffer size callback function has the following signature:
1503 * void function_name(GLFWwindow* window, int width, int height)
1506 * @param[in] window The window whose framebuffer was resized.
1507 * @param[in] width The new width, in pixels, of the framebuffer.
1508 * @param[in] height The new height, in pixels, of the framebuffer.
1510 * @sa @ref window_fbsize
1511 * @sa @ref glfwSetFramebufferSizeCallback
1513 * @since Added in version 3.0.
1517 typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
1519 /*! @brief The function pointer type for window content scale callbacks.
1521 * This is the function pointer type for window content scale callbacks.
1522 * A window content scale callback function has the following signature:
1524 * void function_name(GLFWwindow* window, float xscale, float yscale)
1527 * @param[in] window The window whose content scale changed.
1528 * @param[in] xscale The new x-axis content scale of the window.
1529 * @param[in] yscale The new y-axis content scale of the window.
1531 * @sa @ref window_scale
1532 * @sa @ref glfwSetWindowContentScaleCallback
1534 * @since Added in version 3.3.
1538 typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
1540 /*! @brief The function pointer type for mouse button callbacks.
1542 * This is the function pointer type for mouse button callback functions.
1543 * A mouse button callback function has the following signature:
1545 * void function_name(GLFWwindow* window, int button, int action, int mods)
1548 * @param[in] window The window that received the event.
1549 * @param[in] button The [mouse button](@ref buttons) that was pressed or
1551 * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases
1552 * may add more actions.
1553 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1556 * @sa @ref input_mouse_button
1557 * @sa @ref glfwSetMouseButtonCallback
1559 * @since Added in version 1.0.
1560 * @glfw3 Added window handle and modifier mask parameters.
1564 typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
1566 /*! @brief The function pointer type for cursor position callbacks.
1568 * This is the function pointer type for cursor position callbacks. A cursor
1569 * position callback function has the following signature:
1571 * void function_name(GLFWwindow* window, double xpos, double ypos);
1574 * @param[in] window The window that received the event.
1575 * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
1577 * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
1580 * @sa @ref cursor_pos
1581 * @sa @ref glfwSetCursorPosCallback
1583 * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
1587 typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
1589 /*! @brief The function pointer type for cursor enter/leave callbacks.
1591 * This is the function pointer type for cursor enter/leave callbacks.
1592 * A cursor enter/leave callback function has the following signature:
1594 * void function_name(GLFWwindow* window, int entered)
1597 * @param[in] window The window that received the event.
1598 * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
1599 * area, or `GLFW_FALSE` if it left it.
1601 * @sa @ref cursor_enter
1602 * @sa @ref glfwSetCursorEnterCallback
1604 * @since Added in version 3.0.
1608 typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
1610 /*! @brief The function pointer type for scroll callbacks.
1612 * This is the function pointer type for scroll callbacks. A scroll callback
1613 * function has the following signature:
1615 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
1618 * @param[in] window The window that received the event.
1619 * @param[in] xoffset The scroll offset along the x-axis.
1620 * @param[in] yoffset The scroll offset along the y-axis.
1622 * @sa @ref scrolling
1623 * @sa @ref glfwSetScrollCallback
1625 * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
1629 typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
1631 /*! @brief The function pointer type for keyboard key callbacks.
1633 * This is the function pointer type for keyboard key callbacks. A keyboard
1634 * key callback function has the following signature:
1636 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
1639 * @param[in] window The window that received the event.
1640 * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
1641 * @param[in] scancode The system-specific scancode of the key.
1642 * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
1643 * releases may add more actions.
1644 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1647 * @sa @ref input_key
1648 * @sa @ref glfwSetKeyCallback
1650 * @since Added in version 1.0.
1651 * @glfw3 Added window handle, scancode and modifier mask parameters.
1655 typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
1657 /*! @brief The function pointer type for Unicode character callbacks.
1659 * This is the function pointer type for Unicode character callbacks.
1660 * A Unicode character callback function has the following signature:
1662 * void function_name(GLFWwindow* window, unsigned int codepoint)
1665 * @param[in] window The window that received the event.
1666 * @param[in] codepoint The Unicode code point of the character.
1668 * @sa @ref input_char
1669 * @sa @ref glfwSetCharCallback
1671 * @since Added in version 2.4.
1672 * @glfw3 Added window handle parameter.
1676 typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
1678 /*! @brief The function pointer type for Unicode character with modifiers
1681 * This is the function pointer type for Unicode character with modifiers
1682 * callbacks. It is called for each input character, regardless of what
1683 * modifier keys are held down. A Unicode character with modifiers callback
1684 * function has the following signature:
1686 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
1689 * @param[in] window The window that received the event.
1690 * @param[in] codepoint The Unicode code point of the character.
1691 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1694 * @sa @ref input_char
1695 * @sa @ref glfwSetCharModsCallback
1697 * @deprecated Scheduled for removal in version 4.0.
1699 * @since Added in version 3.1.
1703 typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
1705 /*! @brief The function pointer type for path drop callbacks.
1707 * This is the function pointer type for path drop callbacks. A path drop
1708 * callback function has the following signature:
1710 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
1713 * @param[in] window The window that received the event.
1714 * @param[in] path_count The number of dropped paths.
1715 * @param[in] paths The UTF-8 encoded file and/or directory path names.
1717 * @pointer_lifetime The path array and its strings are valid until the
1718 * callback function returns.
1720 * @sa @ref path_drop
1721 * @sa @ref glfwSetDropCallback
1723 * @since Added in version 3.1.
1727 typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
1729 /*! @brief The function pointer type for monitor configuration callbacks.
1731 * This is the function pointer type for monitor configuration callbacks.
1732 * A monitor callback function has the following signature:
1734 * void function_name(GLFWmonitor* monitor, int event)
1737 * @param[in] monitor The monitor that was connected or disconnected.
1738 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
1739 * releases may add more events.
1741 * @sa @ref monitor_event
1742 * @sa @ref glfwSetMonitorCallback
1744 * @since Added in version 3.0.
1748 typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
1750 /*! @brief The function pointer type for joystick configuration callbacks.
1752 * This is the function pointer type for joystick configuration callbacks.
1753 * A joystick configuration callback function has the following signature:
1755 * void function_name(int jid, int event)
1758 * @param[in] jid The joystick that was connected or disconnected.
1759 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
1760 * releases may add more events.
1762 * @sa @ref joystick_event
1763 * @sa @ref glfwSetJoystickCallback
1765 * @since Added in version 3.2.
1769 typedef void (* GLFWjoystickfun)(int,int);
1771 /*! @brief Video mode type.
1773 * This describes a single video mode.
1775 * @sa @ref monitor_modes
1776 * @sa @ref glfwGetVideoMode
1777 * @sa @ref glfwGetVideoModes
1779 * @since Added in version 1.0.
1780 * @glfw3 Added refresh rate member.
1784 typedef struct GLFWvidmode
1786 /*! The width, in screen coordinates, of the video mode.
1789 /*! The height, in screen coordinates, of the video mode.
1792 /*! The bit depth of the red channel of the video mode.
1795 /*! The bit depth of the green channel of the video mode.
1798 /*! The bit depth of the blue channel of the video mode.
1801 /*! The refresh rate, in Hz, of the video mode.
1806 /*! @brief Gamma ramp.
1808 * This describes the gamma ramp for a monitor.
1810 * @sa @ref monitor_gamma
1811 * @sa @ref glfwGetGammaRamp
1812 * @sa @ref glfwSetGammaRamp
1814 * @since Added in version 3.0.
1818 typedef struct GLFWgammaramp
1820 /*! An array of value describing the response of the red channel.
1822 unsigned short* red;
1823 /*! An array of value describing the response of the green channel.
1825 unsigned short* green;
1826 /*! An array of value describing the response of the blue channel.
1828 unsigned short* blue;
1829 /*! The number of elements in each array.
1834 /*! @brief Image data.
1836 * This describes a single 2D image. See the documentation for each related
1837 * function what the expected pixel format is.
1839 * @sa @ref cursor_custom
1840 * @sa @ref window_icon
1842 * @since Added in version 2.1.
1843 * @glfw3 Removed format and bytes-per-pixel members.
1847 typedef struct GLFWimage
1849 /*! The width, in pixels, of this image.
1852 /*! The height, in pixels, of this image.
1855 /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
1857 unsigned char* pixels;
1860 /*! @brief Gamepad input state
1862 * This describes the input state of a gamepad.
1865 * @sa @ref glfwGetGamepadState
1867 * @since Added in version 3.3.
1871 typedef struct GLFWgamepadstate
1873 /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
1874 * or `GLFW_RELEASE`.
1876 unsigned char buttons[15];
1877 /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
1884 /*************************************************************************
1885 * GLFW API functions
1886 *************************************************************************/
1888 /*! @brief Initializes the GLFW library.
1890 * This function initializes the GLFW library. Before most GLFW functions can
1891 * be used, GLFW must be initialized, and before an application terminates GLFW
1892 * should be terminated in order to free any resources allocated during or
1893 * after initialization.
1895 * If this function fails, it calls @ref glfwTerminate before returning. If it
1896 * succeeds, you should call @ref glfwTerminate before the application exits.
1898 * Additional calls to this function after successful initialization but before
1899 * termination will return `GLFW_TRUE` immediately.
1901 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
1902 * [error](@ref error_handling) occurred.
1904 * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
1906 * @remark @macos This function will change the current directory of the
1907 * application to the `Contents/Resources` subdirectory of the application's
1908 * bundle, if present. This can be disabled with the @ref
1909 * GLFW_COCOA_CHDIR_RESOURCES init hint.
1911 * @remark @macos This function will create the main menu and dock icon for the
1912 * application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to
1913 * contain a menu bar. Otherwise a minimal menu bar is created manually with
1914 * common commands like Hide, Quit and About. The About entry opens a minimal
1915 * about dialog with information from the application's bundle. The menu bar
1916 * and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
1919 * @remark @x11 This function will set the `LC_CTYPE` category of the
1920 * application locale according to the current environment if that category is
1921 * still "C". This is because the "C" locale breaks Unicode text input.
1923 * @thread_safety This function must only be called from the main thread.
1925 * @sa @ref intro_init
1926 * @sa @ref glfwTerminate
1928 * @since Added in version 1.0.
1932 GLFWAPI int glfwInit(void);
1934 /*! @brief Terminates the GLFW library.
1936 * This function destroys all remaining windows and cursors, restores any
1937 * modified gamma ramps and frees any other allocated resources. Once this
1938 * function is called, you must again call @ref glfwInit successfully before
1939 * you will be able to use most GLFW functions.
1941 * If GLFW has been successfully initialized, this function should be called
1942 * before the application exits. If initialization fails, there is no need to
1943 * call this function, as it is called by @ref glfwInit before it returns
1946 * This function has no effect if GLFW is not initialized.
1948 * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
1950 * @remark This function may be called before @ref glfwInit.
1952 * @warning The contexts of any remaining windows must not be current on any
1953 * other thread when this function is called.
1955 * @reentrancy This function must not be called from a callback.
1957 * @thread_safety This function must only be called from the main thread.
1959 * @sa @ref intro_init
1962 * @since Added in version 1.0.
1966 GLFWAPI void glfwTerminate(void);
1968 /*! @brief Sets the specified init hint to the desired value.
1970 * This function sets hints for the next initialization of GLFW.
1972 * The values you set hints to are never reset by GLFW, but they only take
1973 * effect during initialization. Once GLFW has been initialized, any values
1974 * you set will be ignored until the library is terminated and initialized
1977 * Some hints are platform specific. These may be set on any platform but they
1978 * will only affect their specific platform. Other platforms will ignore them.
1979 * Setting these hints requires no platform specific headers or functions.
1981 * @param[in] hint The [init hint](@ref init_hints) to set.
1982 * @param[in] value The new value of the init hint.
1984 * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
1985 * GLFW_INVALID_VALUE.
1987 * @remarks This function may be called before @ref glfwInit.
1989 * @thread_safety This function must only be called from the main thread.
1994 * @since Added in version 3.3.
1998 GLFWAPI void glfwInitHint(int hint, int value);
2000 /*! @brief Retrieves the version of the GLFW library.
2002 * This function retrieves the major, minor and revision numbers of the GLFW
2003 * library. It is intended for when you are using GLFW as a shared library and
2004 * want to ensure that you are using the minimum required version.
2006 * Any or all of the version arguments may be `NULL`.
2008 * @param[out] major Where to store the major version number, or `NULL`.
2009 * @param[out] minor Where to store the minor version number, or `NULL`.
2010 * @param[out] rev Where to store the revision number, or `NULL`.
2014 * @remark This function may be called before @ref glfwInit.
2016 * @thread_safety This function may be called from any thread.
2018 * @sa @ref intro_version
2019 * @sa @ref glfwGetVersionString
2021 * @since Added in version 1.0.
2025 GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
2027 /*! @brief Returns a string describing the compile-time configuration.
2029 * This function returns the compile-time generated
2030 * [version string](@ref intro_version_string) of the GLFW library binary. It
2031 * describes the version, platform, compiler and any platform-specific
2032 * compile-time options. It should not be confused with the OpenGL or OpenGL
2033 * ES version string, queried with `glGetString`.
2035 * __Do not use the version string__ to parse the GLFW library version. The
2036 * @ref glfwGetVersion function provides the version of the running library
2037 * binary in numerical format.
2039 * @return The ASCII encoded GLFW version string.
2043 * @remark This function may be called before @ref glfwInit.
2045 * @pointer_lifetime The returned string is static and compile-time generated.
2047 * @thread_safety This function may be called from any thread.
2049 * @sa @ref intro_version
2050 * @sa @ref glfwGetVersion
2052 * @since Added in version 3.0.
2056 GLFWAPI const char* glfwGetVersionString(void);
2058 /*! @brief Returns and clears the last error for the calling thread.
2060 * This function returns and clears the [error code](@ref errors) of the last
2061 * error that occurred on the calling thread, and optionally a UTF-8 encoded
2062 * human-readable description of it. If no error has occurred since the last
2063 * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
2066 * @param[in] description Where to store the error description pointer, or `NULL`.
2067 * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
2072 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2073 * should not free it yourself. It is guaranteed to be valid only until the
2074 * next error occurs or the library is terminated.
2076 * @remark This function may be called before @ref glfwInit.
2078 * @thread_safety This function may be called from any thread.
2080 * @sa @ref error_handling
2081 * @sa @ref glfwSetErrorCallback
2083 * @since Added in version 3.3.
2087 GLFWAPI int glfwGetError(const char** description);
2089 /*! @brief Sets the error callback.
2091 * This function sets the error callback, which is called with an error code
2092 * and a human-readable description each time a GLFW error occurs.
2094 * The error code is set before the callback is called. Calling @ref
2095 * glfwGetError from the error callback will return the same value as the error
2098 * The error callback is called on the thread where the error occurred. If you
2099 * are using GLFW from multiple threads, your error callback needs to be
2100 * written accordingly.
2102 * Because the description string may have been generated specifically for that
2103 * error, it is not guaranteed to be valid after the callback has returned. If
2104 * you wish to use it after the callback returns, you need to make a copy.
2106 * Once set, the error callback remains set even after the library has been
2109 * @param[in] callback The new callback, or `NULL` to remove the currently set
2111 * @return The previously set callback, or `NULL` if no callback was set.
2113 * @callback_signature
2115 * void callback_name(int error_code, const char* description)
2117 * For more information about the callback parameters, see the
2118 * [callback pointer type](@ref GLFWerrorfun).
2122 * @remark This function may be called before @ref glfwInit.
2124 * @thread_safety This function must only be called from the main thread.
2126 * @sa @ref error_handling
2127 * @sa @ref glfwGetError
2129 * @since Added in version 3.0.
2133 GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
2135 /*! @brief Returns the currently connected monitors.
2137 * This function returns an array of handles for all currently connected
2138 * monitors. The primary monitor is always first in the returned array. If no
2139 * monitors were found, this function returns `NULL`.
2141 * @param[out] count Where to store the number of monitors in the returned
2142 * array. This is set to zero if an error occurred.
2143 * @return An array of monitor handles, or `NULL` if no monitors were found or
2144 * if an [error](@ref error_handling) occurred.
2146 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2148 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2149 * should not free it yourself. It is guaranteed to be valid only until the
2150 * monitor configuration changes or the library is terminated.
2152 * @thread_safety This function must only be called from the main thread.
2154 * @sa @ref monitor_monitors
2155 * @sa @ref monitor_event
2156 * @sa @ref glfwGetPrimaryMonitor
2158 * @since Added in version 3.0.
2162 GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
2164 /*! @brief Returns the primary monitor.
2166 * This function returns the primary monitor. This is usually the monitor
2167 * where elements like the task bar or global menu bar are located.
2169 * @return The primary monitor, or `NULL` if no monitors were found or if an
2170 * [error](@ref error_handling) occurred.
2172 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2174 * @thread_safety This function must only be called from the main thread.
2176 * @remark The primary monitor is always first in the array returned by @ref
2179 * @sa @ref monitor_monitors
2180 * @sa @ref glfwGetMonitors
2182 * @since Added in version 3.0.
2186 GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
2188 /*! @brief Returns the position of the monitor's viewport on the virtual screen.
2190 * This function returns the position, in screen coordinates, of the upper-left
2191 * corner of the specified monitor.
2193 * Any or all of the position arguments may be `NULL`. If an error occurs, all
2194 * non-`NULL` position arguments will be set to zero.
2196 * @param[in] monitor The monitor to query.
2197 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2198 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
2200 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2201 * GLFW_PLATFORM_ERROR.
2203 * @thread_safety This function must only be called from the main thread.
2205 * @sa @ref monitor_properties
2207 * @since Added in version 3.0.
2211 GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
2213 /*! @brief Retrieves the work area of the monitor.
2215 * This function returns the position, in screen coordinates, of the upper-left
2216 * corner of the work area of the specified monitor along with the work area
2217 * size in screen coordinates. The work area is defined as the area of the
2218 * monitor not occluded by the operating system task bar where present. If no
2219 * task bar exists then the work area is the monitor resolution in screen
2222 * Any or all of the position and size arguments may be `NULL`. If an error
2223 * occurs, all non-`NULL` position and size arguments will be set to zero.
2225 * @param[in] monitor The monitor to query.
2226 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2227 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
2228 * @param[out] width Where to store the monitor width, or `NULL`.
2229 * @param[out] height Where to store the monitor height, or `NULL`.
2231 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2232 * GLFW_PLATFORM_ERROR.
2234 * @thread_safety This function must only be called from the main thread.
2236 * @sa @ref monitor_workarea
2238 * @since Added in version 3.3.
2242 GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
2244 /*! @brief Returns the physical size of the monitor.
2246 * This function returns the size, in millimetres, of the display area of the
2247 * specified monitor.
2249 * Some systems do not provide accurate monitor size information, either
2250 * because the monitor
2251 * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
2252 * data is incorrect or because the driver does not report it accurately.
2254 * Any or all of the size arguments may be `NULL`. If an error occurs, all
2255 * non-`NULL` size arguments will be set to zero.
2257 * @param[in] monitor The monitor to query.
2258 * @param[out] widthMM Where to store the width, in millimetres, of the
2259 * monitor's display area, or `NULL`.
2260 * @param[out] heightMM Where to store the height, in millimetres, of the
2261 * monitor's display area, or `NULL`.
2263 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2265 * @remark @win32 calculates the returned physical size from the
2266 * current resolution and system DPI instead of querying the monitor EDID data.
2268 * @thread_safety This function must only be called from the main thread.
2270 * @sa @ref monitor_properties
2272 * @since Added in version 3.0.
2276 GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
2278 /*! @brief Retrieves the content scale for the specified monitor.
2280 * This function retrieves the content scale for the specified monitor. The
2281 * content scale is the ratio between the current DPI and the platform's
2282 * default DPI. This is especially important for text and any UI elements. If
2283 * the pixel dimensions of your UI scaled by this look appropriate on your
2284 * machine then it should appear at a reasonable size on other machines
2285 * regardless of their DPI and scaling settings. This relies on the system DPI
2286 * and scaling settings being somewhat correct.
2288 * The content scale may depend on both the monitor resolution and pixel
2289 * density and on user settings. It may be very different from the raw DPI
2290 * calculated from the physical size and current resolution.
2292 * @param[in] monitor The monitor to query.
2293 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
2294 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
2296 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2297 * GLFW_PLATFORM_ERROR.
2299 * @thread_safety This function must only be called from the main thread.
2301 * @sa @ref monitor_scale
2302 * @sa @ref glfwGetWindowContentScale
2304 * @since Added in version 3.3.
2308 GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
2310 /*! @brief Returns the name of the specified monitor.
2312 * This function returns a human-readable name, encoded as UTF-8, of the
2313 * specified monitor. The name typically reflects the make and model of the
2314 * monitor and is not guaranteed to be unique among the connected monitors.
2316 * @param[in] monitor The monitor to query.
2317 * @return The UTF-8 encoded name of the monitor, or `NULL` if an
2318 * [error](@ref error_handling) occurred.
2320 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2322 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2323 * should not free it yourself. It is valid until the specified monitor is
2324 * disconnected or the library is terminated.
2326 * @thread_safety This function must only be called from the main thread.
2328 * @sa @ref monitor_properties
2330 * @since Added in version 3.0.
2334 GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
2336 /*! @brief Sets the user pointer of the specified monitor.
2338 * This function sets the user-defined pointer of the specified monitor. The
2339 * current value is retained until the monitor is disconnected. The initial
2342 * This function may be called from the monitor callback, even for a monitor
2343 * that is being disconnected.
2345 * @param[in] monitor The monitor whose pointer to set.
2346 * @param[in] pointer The new value.
2348 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2350 * @thread_safety This function may be called from any thread. Access is not
2353 * @sa @ref monitor_userptr
2354 * @sa @ref glfwGetMonitorUserPointer
2356 * @since Added in version 3.3.
2360 GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
2362 /*! @brief Returns the user pointer of the specified monitor.
2364 * This function returns the current value of the user-defined pointer of the
2365 * specified monitor. The initial value is `NULL`.
2367 * This function may be called from the monitor callback, even for a monitor
2368 * that is being disconnected.
2370 * @param[in] monitor The monitor whose pointer to return.
2372 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2374 * @thread_safety This function may be called from any thread. Access is not
2377 * @sa @ref monitor_userptr
2378 * @sa @ref glfwSetMonitorUserPointer
2380 * @since Added in version 3.3.
2384 GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
2386 /*! @brief Sets the monitor configuration callback.
2388 * This function sets the monitor configuration callback, or removes the
2389 * currently set callback. This is called when a monitor is connected to or
2390 * disconnected from the system.
2392 * @param[in] callback The new callback, or `NULL` to remove the currently set
2394 * @return The previously set callback, or `NULL` if no callback was set or the
2395 * library had not been [initialized](@ref intro_init).
2397 * @callback_signature
2399 * void function_name(GLFWmonitor* monitor, int event)
2401 * For more information about the callback parameters, see the
2402 * [function pointer type](@ref GLFWmonitorfun).
2404 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2406 * @thread_safety This function must only be called from the main thread.
2408 * @sa @ref monitor_event
2410 * @since Added in version 3.0.
2414 GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
2416 /*! @brief Returns the available video modes for the specified monitor.
2418 * This function returns an array of all video modes supported by the specified
2419 * monitor. The returned array is sorted in ascending order, first by color
2420 * bit depth (the sum of all channel depths) and then by resolution area (the
2421 * product of width and height).
2423 * @param[in] monitor The monitor to query.
2424 * @param[out] count Where to store the number of video modes in the returned
2425 * array. This is set to zero if an error occurred.
2426 * @return An array of video modes, or `NULL` if an
2427 * [error](@ref error_handling) occurred.
2429 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2430 * GLFW_PLATFORM_ERROR.
2432 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2433 * should not free it yourself. It is valid until the specified monitor is
2434 * disconnected, this function is called again for that monitor or the library
2437 * @thread_safety This function must only be called from the main thread.
2439 * @sa @ref monitor_modes
2440 * @sa @ref glfwGetVideoMode
2442 * @since Added in version 1.0.
2443 * @glfw3 Changed to return an array of modes for a specific monitor.
2447 GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
2449 /*! @brief Returns the current mode of the specified monitor.
2451 * This function returns the current video mode of the specified monitor. If
2452 * you have created a full screen window for that monitor, the return value
2453 * will depend on whether that window is iconified.
2455 * @param[in] monitor The monitor to query.
2456 * @return The current mode of the monitor, or `NULL` if an
2457 * [error](@ref error_handling) occurred.
2459 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2460 * GLFW_PLATFORM_ERROR.
2462 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2463 * should not free it yourself. It is valid until the specified monitor is
2464 * disconnected or the library is terminated.
2466 * @thread_safety This function must only be called from the main thread.
2468 * @sa @ref monitor_modes
2469 * @sa @ref glfwGetVideoModes
2471 * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
2475 GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
2477 /*! @brief Generates a gamma ramp and sets it for the specified monitor.
2479 * This function generates an appropriately sized gamma ramp from the specified
2480 * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
2481 * a finite number greater than zero.
2483 * The software controlled gamma ramp is applied _in addition_ to the hardware
2484 * gamma correction, which today is usually an approximation of sRGB gamma.
2485 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2486 * the default (usually sRGB-like) behavior.
2488 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2489 * GLFW_SRGB_CAPABLE hint.
2491 * @param[in] monitor The monitor whose gamma ramp to set.
2492 * @param[in] gamma The desired exponent.
2494 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2495 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
2497 * @remark @wayland Gamma handling is a privileged protocol, this function
2498 * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
2500 * @thread_safety This function must only be called from the main thread.
2502 * @sa @ref monitor_gamma
2504 * @since Added in version 3.0.
2508 GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
2510 /*! @brief Returns the current gamma ramp for the specified monitor.
2512 * This function returns the current gamma ramp of the specified monitor.
2514 * @param[in] monitor The monitor to query.
2515 * @return The current gamma ramp, or `NULL` if an
2516 * [error](@ref error_handling) occurred.
2518 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2519 * GLFW_PLATFORM_ERROR.
2521 * @remark @wayland Gamma handling is a privileged protocol, this function
2522 * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
2525 * @pointer_lifetime The returned structure and its arrays are allocated and
2526 * freed by GLFW. You should not free them yourself. They are valid until the
2527 * specified monitor is disconnected, this function is called again for that
2528 * monitor or the library is terminated.
2530 * @thread_safety This function must only be called from the main thread.
2532 * @sa @ref monitor_gamma
2534 * @since Added in version 3.0.
2538 GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
2540 /*! @brief Sets the current gamma ramp for the specified monitor.
2542 * This function sets the current gamma ramp for the specified monitor. The
2543 * original gamma ramp for that monitor is saved by GLFW the first time this
2544 * function is called and is restored by @ref glfwTerminate.
2546 * The software controlled gamma ramp is applied _in addition_ to the hardware
2547 * gamma correction, which today is usually an approximation of sRGB gamma.
2548 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2549 * the default (usually sRGB-like) behavior.
2551 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2552 * GLFW_SRGB_CAPABLE hint.
2554 * @param[in] monitor The monitor whose gamma ramp to set.
2555 * @param[in] ramp The gamma ramp to use.
2557 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2558 * GLFW_PLATFORM_ERROR.
2560 * @remark The size of the specified gamma ramp should match the size of the
2561 * current ramp for that monitor.
2563 * @remark @win32 The gamma ramp size must be 256.
2565 * @remark @wayland Gamma handling is a privileged protocol, this function
2566 * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
2568 * @pointer_lifetime The specified gamma ramp is copied before this function
2571 * @thread_safety This function must only be called from the main thread.
2573 * @sa @ref monitor_gamma
2575 * @since Added in version 3.0.
2579 GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
2581 /*! @brief Resets all window hints to their default values.
2583 * This function resets all window hints to their
2584 * [default values](@ref window_hints_values).
2586 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2588 * @thread_safety This function must only be called from the main thread.
2590 * @sa @ref window_hints
2591 * @sa @ref glfwWindowHint
2592 * @sa @ref glfwWindowHintString
2594 * @since Added in version 3.0.
2598 GLFWAPI void glfwDefaultWindowHints(void);
2600 /*! @brief Sets the specified window hint to the desired value.
2602 * This function sets hints for the next call to @ref glfwCreateWindow. The
2603 * hints, once set, retain their values until changed by a call to this
2604 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
2606 * Only integer value hints can be set with this function. String value hints
2607 * are set with @ref glfwWindowHintString.
2609 * This function does not check whether the specified hint values are valid.
2610 * If you set hints to invalid values this will instead be reported by the next
2611 * call to @ref glfwCreateWindow.
2613 * Some hints are platform specific. These may be set on any platform but they
2614 * will only affect their specific platform. Other platforms will ignore them.
2615 * Setting these hints requires no platform specific headers or functions.
2617 * @param[in] hint The [window hint](@ref window_hints) to set.
2618 * @param[in] value The new value of the window hint.
2620 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2621 * GLFW_INVALID_ENUM.
2623 * @thread_safety This function must only be called from the main thread.
2625 * @sa @ref window_hints
2626 * @sa @ref glfwWindowHintString
2627 * @sa @ref glfwDefaultWindowHints
2629 * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
2633 GLFWAPI void glfwWindowHint(int hint, int value);
2635 /*! @brief Sets the specified window hint to the desired value.
2637 * This function sets hints for the next call to @ref glfwCreateWindow. The
2638 * hints, once set, retain their values until changed by a call to this
2639 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
2641 * Only string type hints can be set with this function. Integer value hints
2642 * are set with @ref glfwWindowHint.
2644 * This function does not check whether the specified hint values are valid.
2645 * If you set hints to invalid values this will instead be reported by the next
2646 * call to @ref glfwCreateWindow.
2648 * Some hints are platform specific. These may be set on any platform but they
2649 * will only affect their specific platform. Other platforms will ignore them.
2650 * Setting these hints requires no platform specific headers or functions.
2652 * @param[in] hint The [window hint](@ref window_hints) to set.
2653 * @param[in] value The new value of the window hint.
2655 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2656 * GLFW_INVALID_ENUM.
2658 * @pointer_lifetime The specified string is copied before this function
2661 * @thread_safety This function must only be called from the main thread.
2663 * @sa @ref window_hints
2664 * @sa @ref glfwWindowHint
2665 * @sa @ref glfwDefaultWindowHints
2667 * @since Added in version 3.3.
2671 GLFWAPI void glfwWindowHintString(int hint, const char* value);
2673 /*! @brief Creates a window and its associated context.
2675 * This function creates a window and its associated OpenGL or OpenGL ES
2676 * context. Most of the options controlling how the window and its context
2677 * should be created are specified with [window hints](@ref window_hints).
2679 * Successful creation does not change which context is current. Before you
2680 * can use the newly created context, you need to
2681 * [make it current](@ref context_current). For information about the `share`
2682 * parameter, see @ref context_sharing.
2684 * The created window, framebuffer and context may differ from what you
2685 * requested, as not all parameters and hints are
2686 * [hard constraints](@ref window_hints_hard). This includes the size of the
2687 * window, especially for full screen windows. To query the actual attributes
2688 * of the created window, framebuffer and context, see @ref
2689 * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
2691 * To create a full screen window, you need to specify the monitor the window
2692 * will cover. If no monitor is specified, the window will be windowed mode.
2693 * Unless you have a way for the user to choose a specific monitor, it is
2694 * recommended that you pick the primary monitor. For more information on how
2695 * to query connected monitors, see @ref monitor_monitors.
2697 * For full screen windows, the specified size becomes the resolution of the
2698 * window's _desired video mode_. As long as a full screen window is not
2699 * iconified, the supported video mode most closely matching the desired video
2700 * mode is set for the specified monitor. For more information about full
2701 * screen windows, including the creation of so called _windowed full screen_
2702 * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
2704 * Once you have created the window, you can switch it between windowed and
2705 * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
2706 * OpenGL or OpenGL ES context.
2708 * By default, newly created windows use the placement recommended by the
2709 * window system. To create the window at a specific position, make it
2710 * initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
2711 * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
2714 * As long as at least one full screen window is not iconified, the screensaver
2715 * is prohibited from starting.
2717 * Window systems put limits on window sizes. Very large or very small window
2718 * dimensions may be overridden by the window system on creation. Check the
2719 * actual [size](@ref window_size) after creation.
2721 * The [swap interval](@ref buffer_swap) is not set during window creation and
2722 * the initial value may vary depending on driver settings and defaults.
2724 * @param[in] width The desired width, in screen coordinates, of the window.
2725 * This must be greater than zero.
2726 * @param[in] height The desired height, in screen coordinates, of the window.
2727 * This must be greater than zero.
2728 * @param[in] title The initial, UTF-8 encoded window title.
2729 * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
2731 * @param[in] share The window whose context to share resources with, or `NULL`
2732 * to not share resources.
2733 * @return The handle of the created window, or `NULL` if an
2734 * [error](@ref error_handling) occurred.
2736 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2737 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
2738 * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
2739 * GLFW_PLATFORM_ERROR.
2741 * @remark @win32 Window creation will fail if the Microsoft GDI software
2742 * OpenGL implementation is the only one available.
2744 * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
2745 * will be set as the initial icon for the window. If no such icon is present,
2746 * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
2747 * see @ref glfwSetWindowIcon.
2749 * @remark @win32 The context to share resources with must not be current on
2752 * @remark @macos The OS only supports core profile contexts for OpenGL
2753 * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or
2754 * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
2755 * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all
2758 * @remark @macos The GLFW window has no icon, as it is not a document
2759 * window, but the dock icon will be the same as the application bundle's icon.
2760 * For more information on bundles, see the
2761 * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
2762 * in the Mac Developer Library.
2764 * @remark @macos On OS X 10.10 and later the window frame will not be rendered
2765 * at full resolution on Retina displays unless the
2766 * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
2767 * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
2768 * application bundle's `Info.plist`. For more information, see
2769 * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
2770 * in the Mac Developer Library. The GLFW test and example programs use
2771 * a custom `Info.plist` template for this, which can be found as
2772 * `CMake/Info.plist.in` in the source tree.
2774 * @remark @macos When activating frame autosaving with
2775 * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
2776 * window size and position may be overridden by previously saved values.
2778 * @remark @x11 Some window managers will not respect the placement of
2779 * initially hidden windows.
2781 * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
2782 * a window to reach its requested state. This means you may not be able to
2783 * query the final size, position or other attributes directly after window
2786 * @remark @x11 The class part of the `WM_CLASS` window property will by
2787 * default be set to the window title passed to this function. The instance
2788 * part will use the contents of the `RESOURCE_NAME` environment variable, if
2789 * present and not empty, or fall back to the window title. Set the
2790 * [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
2791 * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
2794 * @remark @wayland Compositors should implement the xdg-decoration protocol
2795 * for GLFW to decorate the window properly. If this protocol isn't
2796 * supported, or if the compositor prefers client-side decorations, a very
2797 * simple fallback frame will be drawn using the wp_viewporter protocol. A
2798 * compositor can still emit close, maximize or fullscreen events, using for
2799 * instance a keybind mechanism. If neither of these protocols is supported,
2800 * the window won't be decorated.
2802 * @remark @wayland A full screen window will not attempt to change the mode,
2803 * no matter what the requested size or refresh rate.
2805 * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
2806 * to be implemented in the user's compositor.
2808 * @thread_safety This function must only be called from the main thread.
2810 * @sa @ref window_creation
2811 * @sa @ref glfwDestroyWindow
2813 * @since Added in version 3.0. Replaces `glfwOpenWindow`.
2817 GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
2819 /*! @brief Destroys the specified window and its context.
2821 * This function destroys the specified window and its context. On calling
2822 * this function, no further callbacks will be called for that window.
2824 * If the context of the specified window is current on the main thread, it is
2825 * detached before being destroyed.
2827 * @param[in] window The window to destroy.
2829 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2830 * GLFW_PLATFORM_ERROR.
2832 * @note The context of the specified window must not be current on any other
2833 * thread when this function is called.
2835 * @reentrancy This function must not be called from a callback.
2837 * @thread_safety This function must only be called from the main thread.
2839 * @sa @ref window_creation
2840 * @sa @ref glfwCreateWindow
2842 * @since Added in version 3.0. Replaces `glfwCloseWindow`.
2846 GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
2848 /*! @brief Checks the close flag of the specified window.
2850 * This function returns the value of the close flag of the specified window.
2852 * @param[in] window The window to query.
2853 * @return The value of the close flag.
2855 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2857 * @thread_safety This function may be called from any thread. Access is not
2860 * @sa @ref window_close
2862 * @since Added in version 3.0.
2866 GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
2868 /*! @brief Sets the close flag of the specified window.
2870 * This function sets the value of the close flag of the specified window.
2871 * This can be used to override the user's attempt to close the window, or
2872 * to signal that it should be closed.
2874 * @param[in] window The window whose flag to change.
2875 * @param[in] value The new value.
2877 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2879 * @thread_safety This function may be called from any thread. Access is not
2882 * @sa @ref window_close
2884 * @since Added in version 3.0.
2888 GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
2890 /*! @brief Sets the title of the specified window.
2892 * This function sets the window title, encoded as UTF-8, of the specified
2895 * @param[in] window The window whose title to change.
2896 * @param[in] title The UTF-8 encoded window title.
2898 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2899 * GLFW_PLATFORM_ERROR.
2901 * @remark @macos The window title will not be updated until the next time you
2904 * @thread_safety This function must only be called from the main thread.
2906 * @sa @ref window_title
2908 * @since Added in version 1.0.
2909 * @glfw3 Added window handle parameter.
2913 GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
2915 /*! @brief Sets the icon for the specified window.
2917 * This function sets the icon of the specified window. If passed an array of
2918 * candidate images, those of or closest to the sizes desired by the system are
2919 * selected. If no images are specified, the window reverts to its default
2922 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
2923 * bits per channel with the red channel first. They are arranged canonically
2924 * as packed sequential rows, starting from the top-left corner.
2926 * The desired image sizes varies depending on platform and system settings.
2927 * The selected images will be rescaled as needed. Good sizes include 16x16,
2930 * @param[in] window The window whose icon to set.
2931 * @param[in] count The number of images in the specified array, or zero to
2932 * revert to the default window icon.
2933 * @param[in] images The images to create the icon from. This is ignored if
2936 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2937 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
2939 * @pointer_lifetime The specified image data is copied before this function
2942 * @remark @macos Regular windows do not have icons on macOS. This function
2943 * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
2944 * the application bundle's icon. For more information on bundles, see the
2945 * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
2946 * in the Mac Developer Library.
2948 * @remark @wayland There is no existing protocol to change an icon, the
2949 * window will thus inherit the one defined in the application's desktop file.
2950 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
2952 * @thread_safety This function must only be called from the main thread.
2954 * @sa @ref window_icon
2956 * @since Added in version 3.2.
2960 GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
2962 /*! @brief Retrieves the position of the content area of the specified window.
2964 * This function retrieves the position, in screen coordinates, of the
2965 * upper-left corner of the content area of the specified window.
2967 * Any or all of the position arguments may be `NULL`. If an error occurs, all
2968 * non-`NULL` position arguments will be set to zero.
2970 * @param[in] window The window to query.
2971 * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
2972 * the content area, or `NULL`.
2973 * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
2974 * the content area, or `NULL`.
2976 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2977 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
2979 * @remark @wayland There is no way for an application to retrieve the global
2980 * position of its windows. This function will emit @ref
2981 * GLFW_FEATURE_UNAVAILABLE.
2983 * @thread_safety This function must only be called from the main thread.
2985 * @sa @ref window_pos
2986 * @sa @ref glfwSetWindowPos
2988 * @since Added in version 3.0.
2992 GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
2994 /*! @brief Sets the position of the content area of the specified window.
2996 * This function sets the position, in screen coordinates, of the upper-left
2997 * corner of the content area of the specified windowed mode window. If the
2998 * window is a full screen window, this function does nothing.
3000 * __Do not use this function__ to move an already visible window unless you
3001 * have very good reasons for doing so, as it will confuse and annoy the user.
3003 * The window manager may put limits on what positions are allowed. GLFW
3004 * cannot and should not override these limits.
3006 * @param[in] window The window to query.
3007 * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
3008 * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
3010 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3011 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3013 * @remark @wayland There is no way for an application to set the global
3014 * position of its windows. This function will emit @ref
3015 * GLFW_FEATURE_UNAVAILABLE.
3017 * @thread_safety This function must only be called from the main thread.
3019 * @sa @ref window_pos
3020 * @sa @ref glfwGetWindowPos
3022 * @since Added in version 1.0.
3023 * @glfw3 Added window handle parameter.
3027 GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
3029 /*! @brief Retrieves the size of the content area of the specified window.
3031 * This function retrieves the size, in screen coordinates, of the content area
3032 * of the specified window. If you wish to retrieve the size of the
3033 * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
3035 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3036 * non-`NULL` size arguments will be set to zero.
3038 * @param[in] window The window whose size to retrieve.
3039 * @param[out] width Where to store the width, in screen coordinates, of the
3040 * content area, or `NULL`.
3041 * @param[out] height Where to store the height, in screen coordinates, of the
3042 * content area, or `NULL`.
3044 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3045 * GLFW_PLATFORM_ERROR.
3047 * @thread_safety This function must only be called from the main thread.
3049 * @sa @ref window_size
3050 * @sa @ref glfwSetWindowSize
3052 * @since Added in version 1.0.
3053 * @glfw3 Added window handle parameter.
3057 GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
3059 /*! @brief Sets the size limits of the specified window.
3061 * This function sets the size limits of the content area of the specified
3062 * window. If the window is full screen, the size limits only take effect
3063 * once it is made windowed. If the window is not resizable, this function
3066 * The size limits are applied immediately to a windowed mode window and may
3067 * cause it to be resized.
3069 * The maximum dimensions must be greater than or equal to the minimum
3070 * dimensions and all must be greater than or equal to zero.
3072 * @param[in] window The window to set limits for.
3073 * @param[in] minwidth The minimum width, in screen coordinates, of the content
3074 * area, or `GLFW_DONT_CARE`.
3075 * @param[in] minheight The minimum height, in screen coordinates, of the
3076 * content area, or `GLFW_DONT_CARE`.
3077 * @param[in] maxwidth The maximum width, in screen coordinates, of the content
3078 * area, or `GLFW_DONT_CARE`.
3079 * @param[in] maxheight The maximum height, in screen coordinates, of the
3080 * content area, or `GLFW_DONT_CARE`.
3082 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3083 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3085 * @remark If you set size limits and an aspect ratio that conflict, the
3086 * results are undefined.
3088 * @remark @wayland The size limits will not be applied until the window is
3089 * actually resized, either by the user or by the compositor.
3091 * @thread_safety This function must only be called from the main thread.
3093 * @sa @ref window_sizelimits
3094 * @sa @ref glfwSetWindowAspectRatio
3096 * @since Added in version 3.2.
3100 GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
3102 /*! @brief Sets the aspect ratio of the specified window.
3104 * This function sets the required aspect ratio of the content area of the
3105 * specified window. If the window is full screen, the aspect ratio only takes
3106 * effect once it is made windowed. If the window is not resizable, this
3107 * function does nothing.
3109 * The aspect ratio is specified as a numerator and a denominator and both
3110 * values must be greater than zero. For example, the common 16:9 aspect ratio
3111 * is specified as 16 and 9, respectively.
3113 * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
3114 * ratio limit is disabled.
3116 * The aspect ratio is applied immediately to a windowed mode window and may
3117 * cause it to be resized.
3119 * @param[in] window The window to set limits for.
3120 * @param[in] numer The numerator of the desired aspect ratio, or
3122 * @param[in] denom The denominator of the desired aspect ratio, or
3125 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3126 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3128 * @remark If you set size limits and an aspect ratio that conflict, the
3129 * results are undefined.
3131 * @remark @wayland The aspect ratio will not be applied until the window is
3132 * actually resized, either by the user or by the compositor.
3134 * @thread_safety This function must only be called from the main thread.
3136 * @sa @ref window_sizelimits
3137 * @sa @ref glfwSetWindowSizeLimits
3139 * @since Added in version 3.2.
3143 GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
3145 /*! @brief Sets the size of the content area of the specified window.
3147 * This function sets the size, in screen coordinates, of the content area of
3148 * the specified window.
3150 * For full screen windows, this function updates the resolution of its desired
3151 * video mode and switches to the video mode closest to it, without affecting
3152 * the window's context. As the context is unaffected, the bit depths of the
3153 * framebuffer remain unchanged.
3155 * If you wish to update the refresh rate of the desired video mode in addition
3156 * to its resolution, see @ref glfwSetWindowMonitor.
3158 * The window manager may put limits on what sizes are allowed. GLFW cannot
3159 * and should not override these limits.
3161 * @param[in] window The window to resize.
3162 * @param[in] width The desired width, in screen coordinates, of the window
3164 * @param[in] height The desired height, in screen coordinates, of the window
3167 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3168 * GLFW_PLATFORM_ERROR.
3170 * @remark @wayland A full screen window will not attempt to change the mode,
3171 * no matter what the requested size.
3173 * @thread_safety This function must only be called from the main thread.
3175 * @sa @ref window_size
3176 * @sa @ref glfwGetWindowSize
3177 * @sa @ref glfwSetWindowMonitor
3179 * @since Added in version 1.0.
3180 * @glfw3 Added window handle parameter.
3184 GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
3186 /*! @brief Retrieves the size of the framebuffer of the specified window.
3188 * This function retrieves the size, in pixels, of the framebuffer of the
3189 * specified window. If you wish to retrieve the size of the window in screen
3190 * coordinates, see @ref glfwGetWindowSize.
3192 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3193 * non-`NULL` size arguments will be set to zero.
3195 * @param[in] window The window whose framebuffer to query.
3196 * @param[out] width Where to store the width, in pixels, of the framebuffer,
3198 * @param[out] height Where to store the height, in pixels, of the framebuffer,
3201 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3202 * GLFW_PLATFORM_ERROR.
3204 * @thread_safety This function must only be called from the main thread.
3206 * @sa @ref window_fbsize
3207 * @sa @ref glfwSetFramebufferSizeCallback
3209 * @since Added in version 3.0.
3213 GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
3215 /*! @brief Retrieves the size of the frame of the window.
3217 * This function retrieves the size, in screen coordinates, of each edge of the
3218 * frame of the specified window. This size includes the title bar, if the
3219 * window has one. The size of the frame may vary depending on the
3220 * [window-related hints](@ref window_hints_wnd) used to create it.
3222 * Because this function retrieves the size of each window frame edge and not
3223 * the offset along a particular coordinate axis, the retrieved values will
3224 * always be zero or positive.
3226 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3227 * non-`NULL` size arguments will be set to zero.
3229 * @param[in] window The window whose frame size to query.
3230 * @param[out] left Where to store the size, in screen coordinates, of the left
3231 * edge of the window frame, or `NULL`.
3232 * @param[out] top Where to store the size, in screen coordinates, of the top
3233 * edge of the window frame, or `NULL`.
3234 * @param[out] right Where to store the size, in screen coordinates, of the
3235 * right edge of the window frame, or `NULL`.
3236 * @param[out] bottom Where to store the size, in screen coordinates, of the
3237 * bottom edge of the window frame, or `NULL`.
3239 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3240 * GLFW_PLATFORM_ERROR.
3242 * @thread_safety This function must only be called from the main thread.
3244 * @sa @ref window_size
3246 * @since Added in version 3.1.
3250 GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
3252 /*! @brief Retrieves the content scale for the specified window.
3254 * This function retrieves the content scale for the specified window. The
3255 * content scale is the ratio between the current DPI and the platform's
3256 * default DPI. This is especially important for text and any UI elements. If
3257 * the pixel dimensions of your UI scaled by this look appropriate on your
3258 * machine then it should appear at a reasonable size on other machines
3259 * regardless of their DPI and scaling settings. This relies on the system DPI
3260 * and scaling settings being somewhat correct.
3262 * On systems where each monitors can have its own content scale, the window
3263 * content scale will depend on which monitor the system considers the window
3266 * @param[in] window The window to query.
3267 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
3268 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
3270 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3271 * GLFW_PLATFORM_ERROR.
3273 * @thread_safety This function must only be called from the main thread.
3275 * @sa @ref window_scale
3276 * @sa @ref glfwSetWindowContentScaleCallback
3277 * @sa @ref glfwGetMonitorContentScale
3279 * @since Added in version 3.3.
3283 GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
3285 /*! @brief Returns the opacity of the whole window.
3287 * This function returns the opacity of the window, including any decorations.
3289 * The opacity (or alpha) value is a positive finite number between zero and
3290 * one, where zero is fully transparent and one is fully opaque. If the system
3291 * does not support whole window transparency, this function always returns one.
3293 * The initial opacity value for newly created windows is one.
3295 * @param[in] window The window to query.
3296 * @return The opacity value of the specified window.
3298 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3299 * GLFW_PLATFORM_ERROR.
3301 * @thread_safety This function must only be called from the main thread.
3303 * @sa @ref window_transparency
3304 * @sa @ref glfwSetWindowOpacity
3306 * @since Added in version 3.3.
3310 GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
3312 /*! @brief Sets the opacity of the whole window.
3314 * This function sets the opacity of the window, including any decorations.
3316 * The opacity (or alpha) value is a positive finite number between zero and
3317 * one, where zero is fully transparent and one is fully opaque.
3319 * The initial opacity value for newly created windows is one.
3321 * A window created with framebuffer transparency may not use whole window
3322 * transparency. The results of doing this are undefined.
3324 * @param[in] window The window to set the opacity for.
3325 * @param[in] opacity The desired opacity of the specified window.
3327 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3328 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3330 * @remark @wayland There is no way to set an opacity factor for a window.
3331 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
3333 * @thread_safety This function must only be called from the main thread.
3335 * @sa @ref window_transparency
3336 * @sa @ref glfwGetWindowOpacity
3338 * @since Added in version 3.3.
3342 GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
3344 /*! @brief Iconifies the specified window.
3346 * This function iconifies (minimizes) the specified window if it was
3347 * previously restored. If the window is already iconified, this function does
3350 * If the specified window is a full screen window, the original monitor
3351 * resolution is restored until the window is restored.
3353 * @param[in] window The window to iconify.
3355 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3356 * GLFW_PLATFORM_ERROR.
3358 * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
3359 * be able to restore it. This is a design decision of the xdg-shell
3362 * @thread_safety This function must only be called from the main thread.
3364 * @sa @ref window_iconify
3365 * @sa @ref glfwRestoreWindow
3366 * @sa @ref glfwMaximizeWindow
3368 * @since Added in version 2.1.
3369 * @glfw3 Added window handle parameter.
3373 GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
3375 /*! @brief Restores the specified window.
3377 * This function restores the specified window if it was previously iconified
3378 * (minimized) or maximized. If the window is already restored, this function
3381 * If the specified window is a full screen window, the resolution chosen for
3382 * the window is restored on the selected monitor.
3384 * @param[in] window The window to restore.
3386 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3387 * GLFW_PLATFORM_ERROR.
3389 * @thread_safety This function must only be called from the main thread.
3391 * @sa @ref window_iconify
3392 * @sa @ref glfwIconifyWindow
3393 * @sa @ref glfwMaximizeWindow
3395 * @since Added in version 2.1.
3396 * @glfw3 Added window handle parameter.
3400 GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
3402 /*! @brief Maximizes the specified window.
3404 * This function maximizes the specified window if it was previously not
3405 * maximized. If the window is already maximized, this function does nothing.
3407 * If the specified window is a full screen window, this function does nothing.
3409 * @param[in] window The window to maximize.
3411 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3412 * GLFW_PLATFORM_ERROR.
3414 * @par Thread Safety
3415 * This function may only be called from the main thread.
3417 * @sa @ref window_iconify
3418 * @sa @ref glfwIconifyWindow
3419 * @sa @ref glfwRestoreWindow
3421 * @since Added in GLFW 3.2.
3425 GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
3427 /*! @brief Makes the specified window visible.
3429 * This function makes the specified window visible if it was previously
3430 * hidden. If the window is already visible or is in full screen mode, this
3431 * function does nothing.
3433 * By default, windowed mode windows are focused when shown
3434 * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
3435 * to change this behavior for all newly created windows, or change the
3436 * behavior for an existing window with @ref glfwSetWindowAttrib.
3438 * @param[in] window The window to make visible.
3440 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3441 * GLFW_PLATFORM_ERROR.
3443 * @thread_safety This function must only be called from the main thread.
3445 * @sa @ref window_hide
3446 * @sa @ref glfwHideWindow
3448 * @since Added in version 3.0.
3452 GLFWAPI void glfwShowWindow(GLFWwindow* window);
3454 /*! @brief Hides the specified window.
3456 * This function hides the specified window if it was previously visible. If
3457 * the window is already hidden or is in full screen mode, this function does
3460 * @param[in] window The window to hide.
3462 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3463 * GLFW_PLATFORM_ERROR.
3465 * @thread_safety This function must only be called from the main thread.
3467 * @sa @ref window_hide
3468 * @sa @ref glfwShowWindow
3470 * @since Added in version 3.0.
3474 GLFWAPI void glfwHideWindow(GLFWwindow* window);
3476 /*! @brief Brings the specified window to front and sets input focus.
3478 * This function brings the specified window to front and sets input focus.
3479 * The window should already be visible and not iconified.
3481 * By default, both windowed and full screen mode windows are focused when
3482 * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
3483 * disable this behavior.
3485 * Also by default, windowed mode windows are focused when shown
3486 * with @ref glfwShowWindow. Set the
3487 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
3489 * __Do not use this function__ to steal focus from other applications unless
3490 * you are certain that is what the user wants. Focus stealing can be
3491 * extremely disruptive.
3493 * For a less disruptive way of getting the user's attention, see
3494 * [attention requests](@ref window_attention).
3496 * @param[in] window The window to give input focus.
3498 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3499 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3501 * @remark @wayland It is not possible for an application to set the input
3502 * focus. This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
3504 * @thread_safety This function must only be called from the main thread.
3506 * @sa @ref window_focus
3507 * @sa @ref window_attention
3509 * @since Added in version 3.2.
3513 GLFWAPI void glfwFocusWindow(GLFWwindow* window);
3515 /*! @brief Requests user attention to the specified window.
3517 * This function requests user attention to the specified window. On
3518 * platforms where this is not supported, attention is requested to the
3519 * application as a whole.
3521 * Once the user has given attention, usually by focusing the window or
3522 * application, the system will end the request automatically.
3524 * @param[in] window The window to request attention to.
3526 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3527 * GLFW_PLATFORM_ERROR.
3529 * @remark @macos Attention is requested to the application as a whole, not the
3532 * @thread_safety This function must only be called from the main thread.
3534 * @sa @ref window_attention
3536 * @since Added in version 3.3.
3540 GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
3542 /*! @brief Returns the monitor that the window uses for full screen mode.
3544 * This function returns the handle of the monitor that the specified window is
3545 * in full screen on.
3547 * @param[in] window The window to query.
3548 * @return The monitor, or `NULL` if the window is in windowed mode or an
3549 * [error](@ref error_handling) occurred.
3551 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3553 * @thread_safety This function must only be called from the main thread.
3555 * @sa @ref window_monitor
3556 * @sa @ref glfwSetWindowMonitor
3558 * @since Added in version 3.0.
3562 GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
3564 /*! @brief Sets the mode, monitor, video mode and placement of a window.
3566 * This function sets the monitor that the window uses for full screen mode or,
3567 * if the monitor is `NULL`, makes it windowed mode.
3569 * When setting a monitor, this function updates the width, height and refresh
3570 * rate of the desired video mode and switches to the video mode closest to it.
3571 * The window position is ignored when setting a monitor.
3573 * When the monitor is `NULL`, the position, width and height are used to
3574 * place the window content area. The refresh rate is ignored when no monitor
3577 * If you only wish to update the resolution of a full screen window or the
3578 * size of a windowed mode window, see @ref glfwSetWindowSize.
3580 * When a window transitions from full screen to windowed mode, this function
3581 * restores any previous window settings such as whether it is decorated,
3582 * floating, resizable, has size or aspect ratio limits, etc.
3584 * @param[in] window The window whose monitor, size or video mode to set.
3585 * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
3586 * @param[in] xpos The desired x-coordinate of the upper-left corner of the
3588 * @param[in] ypos The desired y-coordinate of the upper-left corner of the
3590 * @param[in] width The desired with, in screen coordinates, of the content
3591 * area or video mode.
3592 * @param[in] height The desired height, in screen coordinates, of the content
3593 * area or video mode.
3594 * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
3595 * or `GLFW_DONT_CARE`.
3597 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3598 * GLFW_PLATFORM_ERROR.
3600 * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
3601 * affected by any resizing or mode switching, although you may need to update
3602 * your viewport if the framebuffer size has changed.
3604 * @remark @wayland The desired window position is ignored, as there is no way
3605 * for an application to set this property.
3607 * @remark @wayland Setting the window to full screen will not attempt to
3608 * change the mode, no matter what the requested size or refresh rate.
3610 * @thread_safety This function must only be called from the main thread.
3612 * @sa @ref window_monitor
3613 * @sa @ref window_full_screen
3614 * @sa @ref glfwGetWindowMonitor
3615 * @sa @ref glfwSetWindowSize
3617 * @since Added in version 3.2.
3621 GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
3623 /*! @brief Returns an attribute of the specified window.
3625 * This function returns the value of an attribute of the specified window or
3626 * its OpenGL or OpenGL ES context.
3628 * @param[in] window The window to query.
3629 * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
3631 * @return The value of the attribute, or zero if an
3632 * [error](@ref error_handling) occurred.
3634 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3635 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
3637 * @remark Framebuffer related hints are not window attributes. See @ref
3638 * window_attribs_fb for more information.
3640 * @remark Zero is a valid value for many window and context related
3641 * attributes so you cannot use a return value of zero as an indication of
3642 * errors. However, this function should not fail as long as it is passed
3643 * valid arguments and the library has been [initialized](@ref intro_init).
3645 * @thread_safety This function must only be called from the main thread.
3647 * @sa @ref window_attribs
3648 * @sa @ref glfwSetWindowAttrib
3650 * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
3651 * `glfwGetGLVersion`.
3655 GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
3657 /*! @brief Sets an attribute of the specified window.
3659 * This function sets the value of an attribute of the specified window.
3661 * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
3662 * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
3663 * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
3664 * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
3665 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
3666 * [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
3668 * Some of these attributes are ignored for full screen windows. The new
3669 * value will take effect if the window is later made windowed.
3671 * Some of these attributes are ignored for windowed mode windows. The new
3672 * value will take effect if the window is later made full screen.
3674 * @param[in] window The window to set the attribute for.
3675 * @param[in] attrib A supported window attribute.
3676 * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
3678 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3679 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3681 * @remark Calling @ref glfwGetWindowAttrib will always return the latest
3682 * value, even if that value is ignored by the current mode of the window.
3684 * @thread_safety This function must only be called from the main thread.
3686 * @sa @ref window_attribs
3687 * @sa @ref glfwGetWindowAttrib
3689 * @since Added in version 3.3.
3693 GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
3695 /*! @brief Sets the user pointer of the specified window.
3697 * This function sets the user-defined pointer of the specified window. The
3698 * current value is retained until the window is destroyed. The initial value
3701 * @param[in] window The window whose pointer to set.
3702 * @param[in] pointer The new value.
3704 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3706 * @thread_safety This function may be called from any thread. Access is not
3709 * @sa @ref window_userptr
3710 * @sa @ref glfwGetWindowUserPointer
3712 * @since Added in version 3.0.
3716 GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
3718 /*! @brief Returns the user pointer of the specified window.
3720 * This function returns the current value of the user-defined pointer of the
3721 * specified window. The initial value is `NULL`.
3723 * @param[in] window The window whose pointer to return.
3725 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3727 * @thread_safety This function may be called from any thread. Access is not
3730 * @sa @ref window_userptr
3731 * @sa @ref glfwSetWindowUserPointer
3733 * @since Added in version 3.0.
3737 GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
3739 /*! @brief Sets the position callback for the specified window.
3741 * This function sets the position callback of the specified window, which is
3742 * called when the window is moved. The callback is provided with the
3743 * position, in screen coordinates, of the upper-left corner of the content
3744 * area of the window.
3746 * @param[in] window The window whose callback to set.
3747 * @param[in] callback The new callback, or `NULL` to remove the currently set
3749 * @return The previously set callback, or `NULL` if no callback was set or the
3750 * library had not been [initialized](@ref intro_init).
3752 * @callback_signature
3754 * void function_name(GLFWwindow* window, int xpos, int ypos)
3756 * For more information about the callback parameters, see the
3757 * [function pointer type](@ref GLFWwindowposfun).
3759 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3761 * @remark @wayland This callback will never be called, as there is no way for
3762 * an application to know its global position.
3764 * @thread_safety This function must only be called from the main thread.
3766 * @sa @ref window_pos
3768 * @since Added in version 3.0.
3772 GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
3774 /*! @brief Sets the size callback for the specified window.
3776 * This function sets the size callback of the specified window, which is
3777 * called when the window is resized. The callback is provided with the size,
3778 * in screen coordinates, of the content area of the window.
3780 * @param[in] window The window whose callback to set.
3781 * @param[in] callback The new callback, or `NULL` to remove the currently set
3783 * @return The previously set callback, or `NULL` if no callback was set or the
3784 * library had not been [initialized](@ref intro_init).
3786 * @callback_signature
3788 * void function_name(GLFWwindow* window, int width, int height)
3790 * For more information about the callback parameters, see the
3791 * [function pointer type](@ref GLFWwindowsizefun).
3793 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3795 * @thread_safety This function must only be called from the main thread.
3797 * @sa @ref window_size
3799 * @since Added in version 1.0.
3800 * @glfw3 Added window handle parameter and return value.
3804 GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
3806 /*! @brief Sets the close callback for the specified window.
3808 * This function sets the close callback of the specified window, which is
3809 * called when the user attempts to close the window, for example by clicking
3810 * the close widget in the title bar.
3812 * The close flag is set before this callback is called, but you can modify it
3813 * at any time with @ref glfwSetWindowShouldClose.
3815 * The close callback is not triggered by @ref glfwDestroyWindow.
3817 * @param[in] window The window whose callback to set.
3818 * @param[in] callback The new callback, or `NULL` to remove the currently set
3820 * @return The previously set callback, or `NULL` if no callback was set or the
3821 * library had not been [initialized](@ref intro_init).
3823 * @callback_signature
3825 * void function_name(GLFWwindow* window)
3827 * For more information about the callback parameters, see the
3828 * [function pointer type](@ref GLFWwindowclosefun).
3830 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3832 * @remark @macos Selecting Quit from the application menu will trigger the
3833 * close callback for all windows.
3835 * @thread_safety This function must only be called from the main thread.
3837 * @sa @ref window_close
3839 * @since Added in version 2.5.
3840 * @glfw3 Added window handle parameter and return value.
3844 GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
3846 /*! @brief Sets the refresh callback for the specified window.
3848 * This function sets the refresh callback of the specified window, which is
3849 * called when the content area of the window needs to be redrawn, for example
3850 * if the window has been exposed after having been covered by another window.
3852 * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
3853 * the window contents are saved off-screen, this callback may be called only
3854 * very infrequently or never at all.
3856 * @param[in] window The window whose callback to set.
3857 * @param[in] callback The new callback, or `NULL` to remove the currently set
3859 * @return The previously set callback, or `NULL` if no callback was set or the
3860 * library had not been [initialized](@ref intro_init).
3862 * @callback_signature
3864 * void function_name(GLFWwindow* window);
3866 * For more information about the callback parameters, see the
3867 * [function pointer type](@ref GLFWwindowrefreshfun).
3869 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3871 * @thread_safety This function must only be called from the main thread.
3873 * @sa @ref window_refresh
3875 * @since Added in version 2.5.
3876 * @glfw3 Added window handle parameter and return value.
3880 GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
3882 /*! @brief Sets the focus callback for the specified window.
3884 * This function sets the focus callback of the specified window, which is
3885 * called when the window gains or loses input focus.
3887 * After the focus callback is called for a window that lost input focus,
3888 * synthetic key and mouse button release events will be generated for all such
3889 * that had been pressed. For more information, see @ref glfwSetKeyCallback
3890 * and @ref glfwSetMouseButtonCallback.
3892 * @param[in] window The window whose callback to set.
3893 * @param[in] callback The new callback, or `NULL` to remove the currently set
3895 * @return The previously set callback, or `NULL` if no callback was set or the
3896 * library had not been [initialized](@ref intro_init).
3898 * @callback_signature
3900 * void function_name(GLFWwindow* window, int focused)
3902 * For more information about the callback parameters, see the
3903 * [function pointer type](@ref GLFWwindowfocusfun).
3905 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3907 * @thread_safety This function must only be called from the main thread.
3909 * @sa @ref window_focus
3911 * @since Added in version 3.0.
3915 GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
3917 /*! @brief Sets the iconify callback for the specified window.
3919 * This function sets the iconification callback of the specified window, which
3920 * is called when the window is iconified or restored.
3922 * @param[in] window The window whose callback to set.
3923 * @param[in] callback The new callback, or `NULL` to remove the currently set
3925 * @return The previously set callback, or `NULL` if no callback was set or the
3926 * library had not been [initialized](@ref intro_init).
3928 * @callback_signature
3930 * void function_name(GLFWwindow* window, int iconified)
3932 * For more information about the callback parameters, see the
3933 * [function pointer type](@ref GLFWwindowiconifyfun).
3935 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3937 * @thread_safety This function must only be called from the main thread.
3939 * @sa @ref window_iconify
3941 * @since Added in version 3.0.
3945 GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
3947 /*! @brief Sets the maximize callback for the specified window.
3949 * This function sets the maximization callback of the specified window, which
3950 * is called when the window is maximized or restored.
3952 * @param[in] window The window whose callback to set.
3953 * @param[in] callback The new callback, or `NULL` to remove the currently set
3955 * @return The previously set callback, or `NULL` if no callback was set or the
3956 * library had not been [initialized](@ref intro_init).
3958 * @callback_signature
3960 * void function_name(GLFWwindow* window, int maximized)
3962 * For more information about the callback parameters, see the
3963 * [function pointer type](@ref GLFWwindowmaximizefun).
3965 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3967 * @thread_safety This function must only be called from the main thread.
3969 * @sa @ref window_maximize
3971 * @since Added in version 3.3.
3975 GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
3977 /*! @brief Sets the framebuffer resize callback for the specified window.
3979 * This function sets the framebuffer resize callback of the specified window,
3980 * which is called when the framebuffer of the specified window is resized.
3982 * @param[in] window The window whose callback to set.
3983 * @param[in] callback The new callback, or `NULL` to remove the currently set
3985 * @return The previously set callback, or `NULL` if no callback was set or the
3986 * library had not been [initialized](@ref intro_init).
3988 * @callback_signature
3990 * void function_name(GLFWwindow* window, int width, int height)
3992 * For more information about the callback parameters, see the
3993 * [function pointer type](@ref GLFWframebuffersizefun).
3995 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3997 * @thread_safety This function must only be called from the main thread.
3999 * @sa @ref window_fbsize
4001 * @since Added in version 3.0.
4005 GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
4007 /*! @brief Sets the window content scale callback for the specified window.
4009 * This function sets the window content scale callback of the specified window,
4010 * which is called when the content scale of the specified window changes.
4012 * @param[in] window The window whose callback to set.
4013 * @param[in] callback The new callback, or `NULL` to remove the currently set
4015 * @return The previously set callback, or `NULL` if no callback was set or the
4016 * library had not been [initialized](@ref intro_init).
4018 * @callback_signature
4020 * void function_name(GLFWwindow* window, float xscale, float yscale)
4022 * For more information about the callback parameters, see the
4023 * [function pointer type](@ref GLFWwindowcontentscalefun).
4025 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4027 * @thread_safety This function must only be called from the main thread.
4029 * @sa @ref window_scale
4030 * @sa @ref glfwGetWindowContentScale
4032 * @since Added in version 3.3.
4036 GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
4038 /*! @brief Processes all pending events.
4040 * This function processes only those events that are already in the event
4041 * queue and then returns immediately. Processing events will cause the window
4042 * and input callbacks associated with those events to be called.
4044 * On some platforms, a window move, resize or menu operation will cause event
4045 * processing to block. This is due to how event processing is designed on
4046 * those platforms. You can use the
4047 * [window refresh callback](@ref window_refresh) to redraw the contents of
4048 * your window when necessary during such operations.
4050 * Do not assume that callbacks you set will _only_ be called in response to
4051 * event processing functions like this one. While it is necessary to poll for
4052 * events, window systems that require GLFW to register callbacks of its own
4053 * can pass events to GLFW in response to many window system function calls.
4054 * GLFW will pass those events on to the application callbacks before
4057 * Event processing is not required for joystick input to work.
4059 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4060 * GLFW_PLATFORM_ERROR.
4062 * @reentrancy This function must not be called from a callback.
4064 * @thread_safety This function must only be called from the main thread.
4067 * @sa @ref glfwWaitEvents
4068 * @sa @ref glfwWaitEventsTimeout
4070 * @since Added in version 1.0.
4074 GLFWAPI void glfwPollEvents(void);
4076 /*! @brief Waits until events are queued and processes them.
4078 * This function puts the calling thread to sleep until at least one event is
4079 * available in the event queue. Once one or more events are available,
4080 * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
4081 * are processed and the function then returns immediately. Processing events
4082 * will cause the window and input callbacks associated with those events to be
4085 * Since not all events are associated with callbacks, this function may return
4086 * without a callback having been called even if you are monitoring all
4089 * On some platforms, a window move, resize or menu operation will cause event
4090 * processing to block. This is due to how event processing is designed on
4091 * those platforms. You can use the
4092 * [window refresh callback](@ref window_refresh) to redraw the contents of
4093 * your window when necessary during such operations.
4095 * Do not assume that callbacks you set will _only_ be called in response to
4096 * event processing functions like this one. While it is necessary to poll for
4097 * events, window systems that require GLFW to register callbacks of its own
4098 * can pass events to GLFW in response to many window system function calls.
4099 * GLFW will pass those events on to the application callbacks before
4102 * Event processing is not required for joystick input to work.
4104 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4105 * GLFW_PLATFORM_ERROR.
4107 * @reentrancy This function must not be called from a callback.
4109 * @thread_safety This function must only be called from the main thread.
4112 * @sa @ref glfwPollEvents
4113 * @sa @ref glfwWaitEventsTimeout
4115 * @since Added in version 2.5.
4119 GLFWAPI void glfwWaitEvents(void);
4121 /*! @brief Waits with timeout until events are queued and processes them.
4123 * This function puts the calling thread to sleep until at least one event is
4124 * available in the event queue, or until the specified timeout is reached. If
4125 * one or more events are available, it behaves exactly like @ref
4126 * glfwPollEvents, i.e. the events in the queue are processed and the function
4127 * then returns immediately. Processing events will cause the window and input
4128 * callbacks associated with those events to be called.
4130 * The timeout value must be a positive finite number.
4132 * Since not all events are associated with callbacks, this function may return
4133 * without a callback having been called even if you are monitoring all
4136 * On some platforms, a window move, resize or menu operation will cause event
4137 * processing to block. This is due to how event processing is designed on
4138 * those platforms. You can use the
4139 * [window refresh callback](@ref window_refresh) to redraw the contents of
4140 * your window when necessary during such operations.
4142 * Do not assume that callbacks you set will _only_ be called in response to
4143 * event processing functions like this one. While it is necessary to poll for
4144 * events, window systems that require GLFW to register callbacks of its own
4145 * can pass events to GLFW in response to many window system function calls.
4146 * GLFW will pass those events on to the application callbacks before
4149 * Event processing is not required for joystick input to work.
4151 * @param[in] timeout The maximum amount of time, in seconds, to wait.
4153 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4154 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
4156 * @reentrancy This function must not be called from a callback.
4158 * @thread_safety This function must only be called from the main thread.
4161 * @sa @ref glfwPollEvents
4162 * @sa @ref glfwWaitEvents
4164 * @since Added in version 3.2.
4168 GLFWAPI void glfwWaitEventsTimeout(double timeout);
4170 /*! @brief Posts an empty event to the event queue.
4172 * This function posts an empty event from the current thread to the event
4173 * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
4175 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4176 * GLFW_PLATFORM_ERROR.
4178 * @thread_safety This function may be called from any thread.
4181 * @sa @ref glfwWaitEvents
4182 * @sa @ref glfwWaitEventsTimeout
4184 * @since Added in version 3.1.
4188 GLFWAPI void glfwPostEmptyEvent(void);
4190 /*! @brief Returns the value of an input option for the specified window.
4192 * This function returns the value of an input option for the specified window.
4193 * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
4194 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
4195 * @ref GLFW_RAW_MOUSE_MOTION.
4197 * @param[in] window The window to query.
4198 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
4199 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4200 * `GLFW_RAW_MOUSE_MOTION`.
4202 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4203 * GLFW_INVALID_ENUM.
4205 * @thread_safety This function must only be called from the main thread.
4207 * @sa @ref glfwSetInputMode
4209 * @since Added in version 3.0.
4213 GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
4215 /*! @brief Sets an input option for the specified window.
4217 * This function sets an input mode option for the specified window. The mode
4218 * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
4219 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
4220 * @ref GLFW_RAW_MOUSE_MOTION.
4222 * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
4224 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
4225 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
4226 * content area of the window but does not restrict the cursor from leaving.
4227 * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
4228 * and unlimited cursor movement. This is useful for implementing for
4229 * example 3D camera controls.
4231 * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
4232 * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
4233 * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
4234 * the next time it is called even if the key had been released before the
4235 * call. This is useful when you are only interested in whether keys have been
4236 * pressed but not when or in which order.
4238 * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
4239 * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
4240 * If sticky mouse buttons are enabled, a mouse button press will ensure that
4241 * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
4242 * if the mouse button had been released before the call. This is useful when
4243 * you are only interested in whether mouse buttons have been pressed but not
4244 * when or in which order.
4246 * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
4247 * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
4248 * callbacks that receive modifier bits will also have the @ref
4249 * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
4250 * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
4252 * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
4253 * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
4254 * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
4255 * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
4256 * glfwRawMouseMotionSupported to check for support.
4258 * @param[in] window The window whose input mode to set.
4259 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
4260 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4261 * `GLFW_RAW_MOUSE_MOTION`.
4262 * @param[in] value The new value of the specified input mode.
4264 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4265 * GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
4266 * GLFW_FEATURE_UNAVAILABLE (see above).
4268 * @thread_safety This function must only be called from the main thread.
4270 * @sa @ref glfwGetInputMode
4272 * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
4276 GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
4278 /*! @brief Returns whether raw mouse motion is supported.
4280 * This function returns whether raw mouse motion is supported on the current
4281 * system. This status does not change after GLFW has been initialized so you
4282 * only need to check this once. If you attempt to enable raw motion on
4283 * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
4285 * Raw mouse motion is closer to the actual motion of the mouse across
4286 * a surface. It is not affected by the scaling and acceleration applied to
4287 * the motion of the desktop cursor. That processing is suitable for a cursor
4288 * while raw motion is better for controlling for example a 3D camera. Because
4289 * of this, raw mouse motion is only provided when the cursor is disabled.
4291 * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
4292 * or `GLFW_FALSE` otherwise.
4294 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4296 * @thread_safety This function must only be called from the main thread.
4298 * @sa @ref raw_mouse_motion
4299 * @sa @ref glfwSetInputMode
4301 * @since Added in version 3.3.
4305 GLFWAPI int glfwRawMouseMotionSupported(void);
4307 /*! @brief Returns the layout-specific name of the specified printable key.
4309 * This function returns the name of the specified printable key, encoded as
4310 * UTF-8. This is typically the character that key would produce without any
4311 * modifier keys, intended for displaying key bindings to the user. For dead
4312 * keys, it is typically the diacritic it would add to a character.
4314 * __Do not use this function__ for [text input](@ref input_char). You will
4315 * break text input for many languages even if it happens to work for yours.
4317 * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
4318 * otherwise the scancode is ignored. If you specify a non-printable key, or
4319 * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
4320 * function returns `NULL` but does not emit an error.
4322 * This behavior allows you to always pass in the arguments in the
4323 * [key callback](@ref input_key) without modification.
4325 * The printable keys are:
4326 * - `GLFW_KEY_APOSTROPHE`
4327 * - `GLFW_KEY_COMMA`
4328 * - `GLFW_KEY_MINUS`
4329 * - `GLFW_KEY_PERIOD`
4330 * - `GLFW_KEY_SLASH`
4331 * - `GLFW_KEY_SEMICOLON`
4332 * - `GLFW_KEY_EQUAL`
4333 * - `GLFW_KEY_LEFT_BRACKET`
4334 * - `GLFW_KEY_RIGHT_BRACKET`
4335 * - `GLFW_KEY_BACKSLASH`
4336 * - `GLFW_KEY_WORLD_1`
4337 * - `GLFW_KEY_WORLD_2`
4338 * - `GLFW_KEY_0` to `GLFW_KEY_9`
4339 * - `GLFW_KEY_A` to `GLFW_KEY_Z`
4340 * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
4341 * - `GLFW_KEY_KP_DECIMAL`
4342 * - `GLFW_KEY_KP_DIVIDE`
4343 * - `GLFW_KEY_KP_MULTIPLY`
4344 * - `GLFW_KEY_KP_SUBTRACT`
4345 * - `GLFW_KEY_KP_ADD`
4346 * - `GLFW_KEY_KP_EQUAL`
4348 * Names for printable keys depend on keyboard layout, while names for
4349 * non-printable keys are the same across layouts but depend on the application
4350 * language and should be localized along with other user interface text.
4352 * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
4353 * @param[in] scancode The scancode of the key to query.
4354 * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
4356 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4357 * GLFW_PLATFORM_ERROR.
4359 * @remark The contents of the returned string may change when a keyboard
4360 * layout change event is received.
4362 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
4363 * should not free it yourself. It is valid until the library is terminated.
4365 * @thread_safety This function must only be called from the main thread.
4367 * @sa @ref input_key_name
4369 * @since Added in version 3.2.
4373 GLFWAPI const char* glfwGetKeyName(int key, int scancode);
4375 /*! @brief Returns the platform-specific scancode of the specified key.
4377 * This function returns the platform-specific scancode of the specified key.
4379 * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
4380 * method will return `-1`.
4382 * @param[in] key Any [named key](@ref keys).
4383 * @return The platform-specific scancode for the key, or `-1` if an
4384 * [error](@ref error_handling) occurred.
4386 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4387 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4389 * @thread_safety This function may be called from any thread.
4391 * @sa @ref input_key
4393 * @since Added in version 3.3.
4397 GLFWAPI int glfwGetKeyScancode(int key);
4399 /*! @brief Returns the last reported state of a keyboard key for the specified
4402 * This function returns the last state reported for the specified key to the
4403 * specified window. The returned state is one of `GLFW_PRESS` or
4404 * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
4407 * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
4408 * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
4409 * that key has already been released.
4411 * The key functions deal with physical keys, with [key tokens](@ref keys)
4412 * named after their use on the standard US keyboard layout. If you want to
4413 * input text, use the Unicode character callback instead.
4415 * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
4416 * used with this function.
4418 * __Do not use this function__ to implement [text input](@ref input_char).
4420 * @param[in] window The desired window.
4421 * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
4422 * not a valid key for this function.
4423 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
4425 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4426 * GLFW_INVALID_ENUM.
4428 * @thread_safety This function must only be called from the main thread.
4430 * @sa @ref input_key
4432 * @since Added in version 1.0.
4433 * @glfw3 Added window handle parameter.
4437 GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
4439 /*! @brief Returns the last reported state of a mouse button for the specified
4442 * This function returns the last state reported for the specified mouse button
4443 * to the specified window. The returned state is one of `GLFW_PRESS` or
4446 * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
4447 * returns `GLFW_PRESS` the first time you call it for a mouse button that was
4448 * pressed, even if that mouse button has already been released.
4450 * @param[in] window The desired window.
4451 * @param[in] button The desired [mouse button](@ref buttons).
4452 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
4454 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4455 * GLFW_INVALID_ENUM.
4457 * @thread_safety This function must only be called from the main thread.
4459 * @sa @ref input_mouse_button
4461 * @since Added in version 1.0.
4462 * @glfw3 Added window handle parameter.
4466 GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
4468 /*! @brief Retrieves the position of the cursor relative to the content area of
4471 * This function returns the position of the cursor, in screen coordinates,
4472 * relative to the upper-left corner of the content area of the specified
4475 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
4476 * position is unbounded and limited only by the minimum and maximum values of
4479 * The coordinate can be converted to their integer equivalents with the
4480 * `floor` function. Casting directly to an integer type works for positive
4481 * coordinates, but fails for negative ones.
4483 * Any or all of the position arguments may be `NULL`. If an error occurs, all
4484 * non-`NULL` position arguments will be set to zero.
4486 * @param[in] window The desired window.
4487 * @param[out] xpos Where to store the cursor x-coordinate, relative to the
4488 * left edge of the content area, or `NULL`.
4489 * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
4490 * top edge of the content area, or `NULL`.
4492 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4493 * GLFW_PLATFORM_ERROR.
4495 * @thread_safety This function must only be called from the main thread.
4497 * @sa @ref cursor_pos
4498 * @sa @ref glfwSetCursorPos
4500 * @since Added in version 3.0. Replaces `glfwGetMousePos`.
4504 GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
4506 /*! @brief Sets the position of the cursor, relative to the content area of the
4509 * This function sets the position, in screen coordinates, of the cursor
4510 * relative to the upper-left corner of the content area of the specified
4511 * window. The window must have input focus. If the window does not have
4512 * input focus when this function is called, it fails silently.
4514 * __Do not use this function__ to implement things like camera controls. GLFW
4515 * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
4516 * cursor, transparently re-centers it and provides unconstrained cursor
4517 * motion. See @ref glfwSetInputMode for more information.
4519 * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
4520 * unconstrained and limited only by the minimum and maximum values of
4523 * @param[in] window The desired window.
4524 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
4526 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
4529 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4530 * GLFW_PLATFORM_ERROR.
4532 * @remark @wayland This function will only work when the cursor mode is
4533 * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
4535 * @thread_safety This function must only be called from the main thread.
4537 * @sa @ref cursor_pos
4538 * @sa @ref glfwGetCursorPos
4540 * @since Added in version 3.0. Replaces `glfwSetMousePos`.
4544 GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
4546 /*! @brief Creates a custom cursor.
4548 * Creates a new custom cursor image that can be set for a window with @ref
4549 * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
4550 * Any remaining cursors are destroyed by @ref glfwTerminate.
4552 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
4553 * bits per channel with the red channel first. They are arranged canonically
4554 * as packed sequential rows, starting from the top-left corner.
4556 * The cursor hotspot is specified in pixels, relative to the upper-left corner
4557 * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
4558 * points to the right and the Y-axis points down.
4560 * @param[in] image The desired cursor image.
4561 * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
4562 * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
4563 * @return The handle of the created cursor, or `NULL` if an
4564 * [error](@ref error_handling) occurred.
4566 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4567 * GLFW_PLATFORM_ERROR.
4569 * @pointer_lifetime The specified image data is copied before this function
4572 * @thread_safety This function must only be called from the main thread.
4574 * @sa @ref cursor_object
4575 * @sa @ref glfwDestroyCursor
4576 * @sa @ref glfwCreateStandardCursor
4578 * @since Added in version 3.1.
4582 GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
4584 /*! @brief Creates a cursor with a standard shape.
4586 * Returns a cursor with a standard shape, that can be set for a window with
4587 * @ref glfwSetCursor. The images for these cursors come from the system
4588 * cursor theme and their exact appearance will vary between platforms.
4590 * Most of these shapes are guaranteed to exist on every supported platform but
4591 * a few may not be present. See the table below for details.
4593 * Cursor shape | Windows | macOS | X11 | Wayland
4594 * ------------------------------ | ------- | ----- | ------ | -------
4595 * @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes
4596 * @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes
4597 * @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes
4598 * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes
4599 * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes
4600 * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes
4601 * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
4602 * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
4603 * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes
4604 * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe<sup>2</sup> | Maybe<sup>2</sup>
4606 * 1) This uses a private system API and may fail in the future.
4608 * 2) This uses a newer standard that not all cursor themes support.
4610 * If the requested shape is not available, this function emits a @ref
4611 * GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
4613 * @param[in] shape One of the [standard shapes](@ref shapes).
4614 * @return A new cursor ready to use or `NULL` if an
4615 * [error](@ref error_handling) occurred.
4617 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4618 * GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
4619 * GLFW_PLATFORM_ERROR.
4621 * @thread_safety This function must only be called from the main thread.
4623 * @sa @ref cursor_standard
4624 * @sa @ref glfwCreateCursor
4626 * @since Added in version 3.1.
4630 GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
4632 /*! @brief Destroys a cursor.
4634 * This function destroys a cursor previously created with @ref
4635 * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
4638 * If the specified cursor is current for any window, that window will be
4639 * reverted to the default cursor. This does not affect the cursor mode.
4641 * @param[in] cursor The cursor object to destroy.
4643 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4644 * GLFW_PLATFORM_ERROR.
4646 * @reentrancy This function must not be called from a callback.
4648 * @thread_safety This function must only be called from the main thread.
4650 * @sa @ref cursor_object
4651 * @sa @ref glfwCreateCursor
4653 * @since Added in version 3.1.
4657 GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
4659 /*! @brief Sets the cursor for the window.
4661 * This function sets the cursor image to be used when the cursor is over the
4662 * content area of the specified window. The set cursor will only be visible
4663 * when the [cursor mode](@ref cursor_mode) of the window is
4664 * `GLFW_CURSOR_NORMAL`.
4666 * On some platforms, the set cursor may not be visible unless the window also
4669 * @param[in] window The window to set the cursor for.
4670 * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
4673 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4674 * GLFW_PLATFORM_ERROR.
4676 * @thread_safety This function must only be called from the main thread.
4678 * @sa @ref cursor_object
4680 * @since Added in version 3.1.
4684 GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
4686 /*! @brief Sets the key callback.
4688 * This function sets the key callback of the specified window, which is called
4689 * when a key is pressed, repeated or released.
4691 * The key functions deal with physical keys, with layout independent
4692 * [key tokens](@ref keys) named after their values in the standard US keyboard
4693 * layout. If you want to input text, use the
4694 * [character callback](@ref glfwSetCharCallback) instead.
4696 * When a window loses input focus, it will generate synthetic key release
4697 * events for all pressed keys. You can tell these events from user-generated
4698 * events by the fact that the synthetic ones are generated after the focus
4699 * loss event has been processed, i.e. after the
4700 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
4702 * The scancode of a key is specific to that platform or sometimes even to that
4703 * machine. Scancodes are intended to allow users to bind keys that don't have
4704 * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
4705 * state is not saved and so it cannot be queried with @ref glfwGetKey.
4707 * Sometimes GLFW needs to generate synthetic key events, in which case the
4708 * scancode may be zero.
4710 * @param[in] window The window whose callback to set.
4711 * @param[in] callback The new key callback, or `NULL` to remove the currently
4713 * @return The previously set callback, or `NULL` if no callback was set or the
4714 * library had not been [initialized](@ref intro_init).
4716 * @callback_signature
4718 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
4720 * For more information about the callback parameters, see the
4721 * [function pointer type](@ref GLFWkeyfun).
4723 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4725 * @thread_safety This function must only be called from the main thread.
4727 * @sa @ref input_key
4729 * @since Added in version 1.0.
4730 * @glfw3 Added window handle parameter and return value.
4734 GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
4736 /*! @brief Sets the Unicode character callback.
4738 * This function sets the character callback of the specified window, which is
4739 * called when a Unicode character is input.
4741 * The character callback is intended for Unicode text input. As it deals with
4742 * characters, it is keyboard layout dependent, whereas the
4743 * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
4744 * to physical keys, as a key may produce zero, one or more characters. If you
4745 * want to know whether a specific physical key was pressed or released, see
4746 * the key callback instead.
4748 * The character callback behaves as system text input normally does and will
4749 * not be called if modifier keys are held down that would prevent normal text
4750 * input on that platform, for example a Super (Command) key on macOS or Alt key
4753 * @param[in] window The window whose callback to set.
4754 * @param[in] callback The new callback, or `NULL` to remove the currently set
4756 * @return The previously set callback, or `NULL` if no callback was set or the
4757 * library had not been [initialized](@ref intro_init).
4759 * @callback_signature
4761 * void function_name(GLFWwindow* window, unsigned int codepoint)
4763 * For more information about the callback parameters, see the
4764 * [function pointer type](@ref GLFWcharfun).
4766 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4768 * @thread_safety This function must only be called from the main thread.
4770 * @sa @ref input_char
4772 * @since Added in version 2.4.
4773 * @glfw3 Added window handle parameter and return value.
4777 GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
4779 /*! @brief Sets the Unicode character with modifiers callback.
4781 * This function sets the character with modifiers callback of the specified
4782 * window, which is called when a Unicode character is input regardless of what
4783 * modifier keys are used.
4785 * The character with modifiers callback is intended for implementing custom
4786 * Unicode character input. For regular Unicode text input, see the
4787 * [character callback](@ref glfwSetCharCallback). Like the character
4788 * callback, the character with modifiers callback deals with characters and is
4789 * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
4790 * a key may produce zero, one or more characters. If you want to know whether
4791 * a specific physical key was pressed or released, see the
4792 * [key callback](@ref glfwSetKeyCallback) instead.
4794 * @param[in] window The window whose callback to set.
4795 * @param[in] callback The new callback, or `NULL` to remove the currently set
4797 * @return The previously set callback, or `NULL` if no callback was set or an
4798 * [error](@ref error_handling) occurred.
4800 * @callback_signature
4802 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
4804 * For more information about the callback parameters, see the
4805 * [function pointer type](@ref GLFWcharmodsfun).
4807 * @deprecated Scheduled for removal in version 4.0.
4809 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4811 * @thread_safety This function must only be called from the main thread.
4813 * @sa @ref input_char
4815 * @since Added in version 3.1.
4819 GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
4821 /*! @brief Sets the mouse button callback.
4823 * This function sets the mouse button callback of the specified window, which
4824 * is called when a mouse button is pressed or released.
4826 * When a window loses input focus, it will generate synthetic mouse button
4827 * release events for all pressed mouse buttons. You can tell these events
4828 * from user-generated events by the fact that the synthetic ones are generated
4829 * after the focus loss event has been processed, i.e. after the
4830 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
4832 * @param[in] window The window whose callback to set.
4833 * @param[in] callback The new callback, or `NULL` to remove the currently set
4835 * @return The previously set callback, or `NULL` if no callback was set or the
4836 * library had not been [initialized](@ref intro_init).
4838 * @callback_signature
4840 * void function_name(GLFWwindow* window, int button, int action, int mods)
4842 * For more information about the callback parameters, see the
4843 * [function pointer type](@ref GLFWmousebuttonfun).
4845 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4847 * @thread_safety This function must only be called from the main thread.
4849 * @sa @ref input_mouse_button
4851 * @since Added in version 1.0.
4852 * @glfw3 Added window handle parameter and return value.
4856 GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
4858 /*! @brief Sets the cursor position callback.
4860 * This function sets the cursor position callback of the specified window,
4861 * which is called when the cursor is moved. The callback is provided with the
4862 * position, in screen coordinates, relative to the upper-left corner of the
4863 * content area of the window.
4865 * @param[in] window The window whose callback to set.
4866 * @param[in] callback The new callback, or `NULL` to remove the currently set
4868 * @return The previously set callback, or `NULL` if no callback was set or the
4869 * library had not been [initialized](@ref intro_init).
4871 * @callback_signature
4873 * void function_name(GLFWwindow* window, double xpos, double ypos);
4875 * For more information about the callback parameters, see the
4876 * [function pointer type](@ref GLFWcursorposfun).
4878 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4880 * @thread_safety This function must only be called from the main thread.
4882 * @sa @ref cursor_pos
4884 * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
4888 GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
4890 /*! @brief Sets the cursor enter/leave callback.
4892 * This function sets the cursor boundary crossing callback of the specified
4893 * window, which is called when the cursor enters or leaves the content area of
4896 * @param[in] window The window whose callback to set.
4897 * @param[in] callback The new callback, or `NULL` to remove the currently set
4899 * @return The previously set callback, or `NULL` if no callback was set or the
4900 * library had not been [initialized](@ref intro_init).
4902 * @callback_signature
4904 * void function_name(GLFWwindow* window, int entered)
4906 * For more information about the callback parameters, see the
4907 * [function pointer type](@ref GLFWcursorenterfun).
4909 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4911 * @thread_safety This function must only be called from the main thread.
4913 * @sa @ref cursor_enter
4915 * @since Added in version 3.0.
4919 GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
4921 /*! @brief Sets the scroll callback.
4923 * This function sets the scroll callback of the specified window, which is
4924 * called when a scrolling device is used, such as a mouse wheel or scrolling
4925 * area of a touchpad.
4927 * The scroll callback receives all scrolling input, like that from a mouse
4928 * wheel or a touchpad scrolling area.
4930 * @param[in] window The window whose callback to set.
4931 * @param[in] callback The new scroll callback, or `NULL` to remove the
4932 * currently set callback.
4933 * @return The previously set callback, or `NULL` if no callback was set or the
4934 * library had not been [initialized](@ref intro_init).
4936 * @callback_signature
4938 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
4940 * For more information about the callback parameters, see the
4941 * [function pointer type](@ref GLFWscrollfun).
4943 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4945 * @thread_safety This function must only be called from the main thread.
4947 * @sa @ref scrolling
4949 * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
4953 GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
4955 /*! @brief Sets the path drop callback.
4957 * This function sets the path drop callback of the specified window, which is
4958 * called when one or more dragged paths are dropped on the window.
4960 * Because the path array and its strings may have been generated specifically
4961 * for that event, they are not guaranteed to be valid after the callback has
4962 * returned. If you wish to use them after the callback returns, you need to
4965 * @param[in] window The window whose callback to set.
4966 * @param[in] callback The new file drop callback, or `NULL` to remove the
4967 * currently set callback.
4968 * @return The previously set callback, or `NULL` if no callback was set or the
4969 * library had not been [initialized](@ref intro_init).
4971 * @callback_signature
4973 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
4975 * For more information about the callback parameters, see the
4976 * [function pointer type](@ref GLFWdropfun).
4978 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4980 * @remark @wayland File drop is currently unimplemented.
4982 * @thread_safety This function must only be called from the main thread.
4984 * @sa @ref path_drop
4986 * @since Added in version 3.1.
4990 GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
4992 /*! @brief Returns whether the specified joystick is present.
4994 * This function returns whether the specified joystick is present.
4996 * There is no need to call this function before other functions that accept
4997 * a joystick ID, as they all check for presence before performing any other
5000 * @param[in] jid The [joystick](@ref joysticks) to query.
5001 * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
5003 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5004 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5006 * @thread_safety This function must only be called from the main thread.
5010 * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
5014 GLFWAPI int glfwJoystickPresent(int jid);
5016 /*! @brief Returns the values of all axes of the specified joystick.
5018 * This function returns the values of all axes of the specified joystick.
5019 * Each element in the array is a value between -1.0 and 1.0.
5021 * If the specified joystick is not present this function will return `NULL`
5022 * but will not generate an error. This can be used instead of first calling
5023 * @ref glfwJoystickPresent.
5025 * @param[in] jid The [joystick](@ref joysticks) to query.
5026 * @param[out] count Where to store the number of axis values in the returned
5027 * array. This is set to zero if the joystick is not present or an error
5029 * @return An array of axis values, or `NULL` if the joystick is not present or
5030 * an [error](@ref error_handling) occurred.
5032 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5033 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5035 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5036 * should not free it yourself. It is valid until the specified joystick is
5037 * disconnected or the library is terminated.
5039 * @thread_safety This function must only be called from the main thread.
5041 * @sa @ref joystick_axis
5043 * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
5047 GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
5049 /*! @brief Returns the state of all buttons of the specified joystick.
5051 * This function returns the state of all buttons of the specified joystick.
5052 * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
5054 * For backward compatibility with earlier versions that did not have @ref
5055 * glfwGetJoystickHats, the button array also includes all hats, each
5056 * represented as four buttons. The hats are in the same order as returned by
5057 * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
5058 * _left_. To disable these extra buttons, set the @ref
5059 * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
5061 * If the specified joystick is not present this function will return `NULL`
5062 * but will not generate an error. This can be used instead of first calling
5063 * @ref glfwJoystickPresent.
5065 * @param[in] jid The [joystick](@ref joysticks) to query.
5066 * @param[out] count Where to store the number of button states in the returned
5067 * array. This is set to zero if the joystick is not present or an error
5069 * @return An array of button states, or `NULL` if the joystick is not present
5070 * or an [error](@ref error_handling) occurred.
5072 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5073 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5075 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5076 * should not free it yourself. It is valid until the specified joystick is
5077 * disconnected or the library is terminated.
5079 * @thread_safety This function must only be called from the main thread.
5081 * @sa @ref joystick_button
5083 * @since Added in version 2.2.
5084 * @glfw3 Changed to return a dynamic array.
5088 GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
5090 /*! @brief Returns the state of all hats of the specified joystick.
5092 * This function returns the state of all hats of the specified joystick.
5093 * Each element in the array is one of the following values:
5097 * `GLFW_HAT_CENTERED` | 0
5099 * `GLFW_HAT_RIGHT` | 2
5100 * `GLFW_HAT_DOWN` | 4
5101 * `GLFW_HAT_LEFT` | 8
5102 * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
5103 * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
5104 * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
5105 * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
5107 * The diagonal directions are bitwise combinations of the primary (up, right,
5108 * down and left) directions and you can test for these individually by ANDing
5109 * it with the corresponding direction.
5112 * if (hats[2] & GLFW_HAT_RIGHT)
5114 * // State of hat 2 could be right-up, right or right-down
5118 * If the specified joystick is not present this function will return `NULL`
5119 * but will not generate an error. This can be used instead of first calling
5120 * @ref glfwJoystickPresent.
5122 * @param[in] jid The [joystick](@ref joysticks) to query.
5123 * @param[out] count Where to store the number of hat states in the returned
5124 * array. This is set to zero if the joystick is not present or an error
5126 * @return An array of hat states, or `NULL` if the joystick is not present
5127 * or an [error](@ref error_handling) occurred.
5129 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5130 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5132 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5133 * should not free it yourself. It is valid until the specified joystick is
5134 * disconnected, this function is called again for that joystick or the library
5137 * @thread_safety This function must only be called from the main thread.
5139 * @sa @ref joystick_hat
5141 * @since Added in version 3.3.
5145 GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
5147 /*! @brief Returns the name of the specified joystick.
5149 * This function returns the name, encoded as UTF-8, of the specified joystick.
5150 * The returned string is allocated and freed by GLFW. You should not free it
5153 * If the specified joystick is not present this function will return `NULL`
5154 * but will not generate an error. This can be used instead of first calling
5155 * @ref glfwJoystickPresent.
5157 * @param[in] jid The [joystick](@ref joysticks) to query.
5158 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
5159 * is not present or an [error](@ref error_handling) occurred.
5161 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5162 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5164 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5165 * should not free it yourself. It is valid until the specified joystick is
5166 * disconnected or the library is terminated.
5168 * @thread_safety This function must only be called from the main thread.
5170 * @sa @ref joystick_name
5172 * @since Added in version 3.0.
5176 GLFWAPI const char* glfwGetJoystickName(int jid);
5178 /*! @brief Returns the SDL compatible GUID of the specified joystick.
5180 * This function returns the SDL compatible GUID, as a UTF-8 encoded
5181 * hexadecimal string, of the specified joystick. The returned string is
5182 * allocated and freed by GLFW. You should not free it yourself.
5184 * The GUID is what connects a joystick to a gamepad mapping. A connected
5185 * joystick will always have a GUID even if there is no gamepad mapping
5188 * If the specified joystick is not present this function will return `NULL`
5189 * but will not generate an error. This can be used instead of first calling
5190 * @ref glfwJoystickPresent.
5192 * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
5193 * uniquely identify the make and model of a joystick but does not identify
5194 * a specific unit, e.g. all wired Xbox 360 controllers will have the same
5195 * GUID on that platform. The GUID for a unit may vary between platforms
5196 * depending on what hardware information the platform specific APIs provide.
5198 * @param[in] jid The [joystick](@ref joysticks) to query.
5199 * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
5200 * is not present or an [error](@ref error_handling) occurred.
5202 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5203 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5205 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5206 * should not free it yourself. It is valid until the specified joystick is
5207 * disconnected or the library is terminated.
5209 * @thread_safety This function must only be called from the main thread.
5213 * @since Added in version 3.3.
5217 GLFWAPI const char* glfwGetJoystickGUID(int jid);
5219 /*! @brief Sets the user pointer of the specified joystick.
5221 * This function sets the user-defined pointer of the specified joystick. The
5222 * current value is retained until the joystick is disconnected. The initial
5225 * This function may be called from the joystick callback, even for a joystick
5226 * that is being disconnected.
5228 * @param[in] jid The joystick whose pointer to set.
5229 * @param[in] pointer The new value.
5231 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5233 * @thread_safety This function may be called from any thread. Access is not
5236 * @sa @ref joystick_userptr
5237 * @sa @ref glfwGetJoystickUserPointer
5239 * @since Added in version 3.3.
5243 GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
5245 /*! @brief Returns the user pointer of the specified joystick.
5247 * This function returns the current value of the user-defined pointer of the
5248 * specified joystick. The initial value is `NULL`.
5250 * This function may be called from the joystick callback, even for a joystick
5251 * that is being disconnected.
5253 * @param[in] jid The joystick whose pointer to return.
5255 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5257 * @thread_safety This function may be called from any thread. Access is not
5260 * @sa @ref joystick_userptr
5261 * @sa @ref glfwSetJoystickUserPointer
5263 * @since Added in version 3.3.
5267 GLFWAPI void* glfwGetJoystickUserPointer(int jid);
5269 /*! @brief Returns whether the specified joystick has a gamepad mapping.
5271 * This function returns whether the specified joystick is both present and has
5272 * a gamepad mapping.
5274 * If the specified joystick is present but does not have a gamepad mapping
5275 * this function will return `GLFW_FALSE` but will not generate an error. Call
5276 * @ref glfwJoystickPresent to check if a joystick is present regardless of
5277 * whether it has a mapping.
5279 * @param[in] jid The [joystick](@ref joysticks) to query.
5280 * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
5281 * or `GLFW_FALSE` otherwise.
5283 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5284 * GLFW_INVALID_ENUM.
5286 * @thread_safety This function must only be called from the main thread.
5289 * @sa @ref glfwGetGamepadState
5291 * @since Added in version 3.3.
5295 GLFWAPI int glfwJoystickIsGamepad(int jid);
5297 /*! @brief Sets the joystick configuration callback.
5299 * This function sets the joystick configuration callback, or removes the
5300 * currently set callback. This is called when a joystick is connected to or
5301 * disconnected from the system.
5303 * For joystick connection and disconnection events to be delivered on all
5304 * platforms, you need to call one of the [event processing](@ref events)
5305 * functions. Joystick disconnection may also be detected and the callback
5306 * called by joystick functions. The function will then return whatever it
5307 * returns if the joystick is not present.
5309 * @param[in] callback The new callback, or `NULL` to remove the currently set
5311 * @return The previously set callback, or `NULL` if no callback was set or the
5312 * library had not been [initialized](@ref intro_init).
5314 * @callback_signature
5316 * void function_name(int jid, int event)
5318 * For more information about the callback parameters, see the
5319 * [function pointer type](@ref GLFWjoystickfun).
5321 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5323 * @thread_safety This function must only be called from the main thread.
5325 * @sa @ref joystick_event
5327 * @since Added in version 3.2.
5331 GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
5333 /*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
5335 * This function parses the specified ASCII encoded string and updates the
5336 * internal list with any gamepad mappings it finds. This string may
5337 * contain either a single gamepad mapping or many mappings separated by
5338 * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
5339 * source file including empty lines and comments.
5341 * See @ref gamepad_mapping for a description of the format.
5343 * If there is already a gamepad mapping for a given GUID in the internal list,
5344 * it will be replaced by the one passed to this function. If the library is
5345 * terminated and re-initialized the internal list will revert to the built-in
5348 * @param[in] string The string containing the gamepad mappings.
5349 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
5350 * [error](@ref error_handling) occurred.
5352 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5353 * GLFW_INVALID_VALUE.
5355 * @thread_safety This function must only be called from the main thread.
5358 * @sa @ref glfwJoystickIsGamepad
5359 * @sa @ref glfwGetGamepadName
5361 * @since Added in version 3.3.
5365 GLFWAPI int glfwUpdateGamepadMappings(const char* string);
5367 /*! @brief Returns the human-readable gamepad name for the specified joystick.
5369 * This function returns the human-readable name of the gamepad from the
5370 * gamepad mapping assigned to the specified joystick.
5372 * If the specified joystick is not present or does not have a gamepad mapping
5373 * this function will return `NULL` but will not generate an error. Call
5374 * @ref glfwJoystickPresent to check whether it is present regardless of
5375 * whether it has a mapping.
5377 * @param[in] jid The [joystick](@ref joysticks) to query.
5378 * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
5379 * joystick is not present, does not have a mapping or an
5380 * [error](@ref error_handling) occurred.
5382 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5383 * should not free it yourself. It is valid until the specified joystick is
5384 * disconnected, the gamepad mappings are updated or the library is terminated.
5386 * @thread_safety This function must only be called from the main thread.
5389 * @sa @ref glfwJoystickIsGamepad
5391 * @since Added in version 3.3.
5395 GLFWAPI const char* glfwGetGamepadName(int jid);
5397 /*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
5399 * This function retrieves the state of the specified joystick remapped to
5400 * an Xbox-like gamepad.
5402 * If the specified joystick is not present or does not have a gamepad mapping
5403 * this function will return `GLFW_FALSE` but will not generate an error. Call
5404 * @ref glfwJoystickPresent to check whether it is present regardless of
5405 * whether it has a mapping.
5407 * The Guide button may not be available for input as it is often hooked by the
5408 * system or the Steam client.
5410 * Not all devices have all the buttons or axes provided by @ref
5411 * GLFWgamepadstate. Unavailable buttons and axes will always report
5412 * `GLFW_RELEASE` and 0.0 respectively.
5414 * @param[in] jid The [joystick](@ref joysticks) to query.
5415 * @param[out] state The gamepad input state of the joystick.
5416 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
5417 * connected, it has no gamepad mapping or an [error](@ref error_handling)
5420 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5421 * GLFW_INVALID_ENUM.
5423 * @thread_safety This function must only be called from the main thread.
5426 * @sa @ref glfwUpdateGamepadMappings
5427 * @sa @ref glfwJoystickIsGamepad
5429 * @since Added in version 3.3.
5433 GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
5435 /*! @brief Sets the clipboard to the specified string.
5437 * This function sets the system clipboard to the specified, UTF-8 encoded
5440 * @param[in] window Deprecated. Any valid window or `NULL`.
5441 * @param[in] string A UTF-8 encoded string.
5443 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5444 * GLFW_PLATFORM_ERROR.
5446 * @pointer_lifetime The specified string is copied before this function
5449 * @thread_safety This function must only be called from the main thread.
5451 * @sa @ref clipboard
5452 * @sa @ref glfwGetClipboardString
5454 * @since Added in version 3.0.
5458 GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
5460 /*! @brief Returns the contents of the clipboard as a string.
5462 * This function returns the contents of the system clipboard, if it contains
5463 * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
5464 * if its contents cannot be converted, `NULL` is returned and a @ref
5465 * GLFW_FORMAT_UNAVAILABLE error is generated.
5467 * @param[in] window Deprecated. Any valid window or `NULL`.
5468 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
5469 * if an [error](@ref error_handling) occurred.
5471 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5472 * GLFW_PLATFORM_ERROR.
5474 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5475 * should not free it yourself. It is valid until the next call to @ref
5476 * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
5479 * @thread_safety This function must only be called from the main thread.
5481 * @sa @ref clipboard
5482 * @sa @ref glfwSetClipboardString
5484 * @since Added in version 3.0.
5488 GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
5490 /*! @brief Returns the GLFW time.
5492 * This function returns the current GLFW time, in seconds. Unless the time
5493 * has been set using @ref glfwSetTime it measures time elapsed since GLFW was
5496 * This function and @ref glfwSetTime are helper functions on top of @ref
5497 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
5499 * The resolution of the timer is system dependent, but is usually on the order
5500 * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
5501 * time source on each supported platform.
5503 * @return The current time, in seconds, or zero if an
5504 * [error](@ref error_handling) occurred.
5506 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5508 * @thread_safety This function may be called from any thread. Reading and
5509 * writing of the internal base time is not atomic, so it needs to be
5510 * externally synchronized with calls to @ref glfwSetTime.
5514 * @since Added in version 1.0.
5518 GLFWAPI double glfwGetTime(void);
5520 /*! @brief Sets the GLFW time.
5522 * This function sets the current GLFW time, in seconds. The value must be
5523 * a positive finite number less than or equal to 18446744073.0, which is
5524 * approximately 584.5 years.
5526 * This function and @ref glfwGetTime are helper functions on top of @ref
5527 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
5529 * @param[in] time The new value, in seconds.
5531 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5532 * GLFW_INVALID_VALUE.
5534 * @remark The upper limit of GLFW time is calculated as
5535 * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
5536 * storing nanoseconds in 64 bits. The limit may be increased in the future.
5538 * @thread_safety This function may be called from any thread. Reading and
5539 * writing of the internal base time is not atomic, so it needs to be
5540 * externally synchronized with calls to @ref glfwGetTime.
5544 * @since Added in version 2.2.
5548 GLFWAPI void glfwSetTime(double time);
5550 /*! @brief Returns the current value of the raw timer.
5552 * This function returns the current value of the raw timer, measured in
5553 * 1 / frequency seconds. To get the frequency, call @ref
5554 * glfwGetTimerFrequency.
5556 * @return The value of the timer, or zero if an
5557 * [error](@ref error_handling) occurred.
5559 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5561 * @thread_safety This function may be called from any thread.
5564 * @sa @ref glfwGetTimerFrequency
5566 * @since Added in version 3.2.
5570 GLFWAPI uint64_t glfwGetTimerValue(void);
5572 /*! @brief Returns the frequency, in Hz, of the raw timer.
5574 * This function returns the frequency, in Hz, of the raw timer.
5576 * @return The frequency of the timer, in Hz, or zero if an
5577 * [error](@ref error_handling) occurred.
5579 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5581 * @thread_safety This function may be called from any thread.
5584 * @sa @ref glfwGetTimerValue
5586 * @since Added in version 3.2.
5590 GLFWAPI uint64_t glfwGetTimerFrequency(void);
5592 /*! @brief Makes the context of the specified window current for the calling
5595 * This function makes the OpenGL or OpenGL ES context of the specified window
5596 * current on the calling thread. A context must only be made current on
5597 * a single thread at a time and each thread can have only a single current
5598 * context at a time.
5600 * When moving a context between threads, you must make it non-current on the
5601 * old thread before making it current on the new one.
5603 * By default, making a context non-current implicitly forces a pipeline flush.
5604 * On machines that support `GL_KHR_context_flush_control`, you can control
5605 * whether a context performs this flush by setting the
5606 * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
5609 * The specified window must have an OpenGL or OpenGL ES context. Specifying
5610 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
5613 * @param[in] window The window whose context to make current, or `NULL` to
5614 * detach the current context.
5616 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5617 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5619 * @thread_safety This function may be called from any thread.
5621 * @sa @ref context_current
5622 * @sa @ref glfwGetCurrentContext
5624 * @since Added in version 3.0.
5628 GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
5630 /*! @brief Returns the window whose context is current on the calling thread.
5632 * This function returns the window whose OpenGL or OpenGL ES context is
5633 * current on the calling thread.
5635 * @return The window whose context is current, or `NULL` if no window's
5636 * context is current.
5638 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5640 * @thread_safety This function may be called from any thread.
5642 * @sa @ref context_current
5643 * @sa @ref glfwMakeContextCurrent
5645 * @since Added in version 3.0.
5649 GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
5651 /*! @brief Swaps the front and back buffers of the specified window.
5653 * This function swaps the front and back buffers of the specified window when
5654 * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
5655 * zero, the GPU driver waits the specified number of screen updates before
5656 * swapping the buffers.
5658 * The specified window must have an OpenGL or OpenGL ES context. Specifying
5659 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
5662 * This function does not apply to Vulkan. If you are rendering with Vulkan,
5663 * see `vkQueuePresentKHR` instead.
5665 * @param[in] window The window whose buffers to swap.
5667 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5668 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5670 * @remark __EGL:__ The context of the specified window must be current on the
5673 * @thread_safety This function may be called from any thread.
5675 * @sa @ref buffer_swap
5676 * @sa @ref glfwSwapInterval
5678 * @since Added in version 1.0.
5679 * @glfw3 Added window handle parameter.
5683 GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
5685 /*! @brief Sets the swap interval for the current context.
5687 * This function sets the swap interval for the current OpenGL or OpenGL ES
5688 * context, i.e. the number of screen updates to wait from the time @ref
5689 * glfwSwapBuffers was called before swapping the buffers and returning. This
5690 * is sometimes called _vertical synchronization_, _vertical retrace
5691 * synchronization_ or just _vsync_.
5693 * A context that supports either of the `WGL_EXT_swap_control_tear` and
5694 * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
5695 * intervals, which allows the driver to swap immediately even if a frame
5696 * arrives a little bit late. You can check for these extensions with @ref
5697 * glfwExtensionSupported.
5699 * A context must be current on the calling thread. Calling this function
5700 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
5702 * This function does not apply to Vulkan. If you are rendering with Vulkan,
5703 * see the present mode of your swapchain instead.
5705 * @param[in] interval The minimum number of screen updates to wait for
5706 * until the buffers are swapped by @ref glfwSwapBuffers.
5708 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5709 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5711 * @remark This function is not called during context creation, leaving the
5712 * swap interval set to whatever is the default on that platform. This is done
5713 * because some swap interval extensions used by GLFW do not allow the swap
5714 * interval to be reset to zero once it has been set to a non-zero value.
5716 * @remark Some GPU drivers do not honor the requested swap interval, either
5717 * because of a user setting that overrides the application's request or due to
5718 * bugs in the driver.
5720 * @thread_safety This function may be called from any thread.
5722 * @sa @ref buffer_swap
5723 * @sa @ref glfwSwapBuffers
5725 * @since Added in version 1.0.
5729 GLFWAPI void glfwSwapInterval(int interval);
5731 /*! @brief Returns whether the specified extension is available.
5733 * This function returns whether the specified
5734 * [API extension](@ref context_glext) is supported by the current OpenGL or
5735 * OpenGL ES context. It searches both for client API extension and context
5736 * creation API extensions.
5738 * A context must be current on the calling thread. Calling this function
5739 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
5741 * As this functions retrieves and searches one or more extension strings each
5742 * call, it is recommended that you cache its results if it is going to be used
5743 * frequently. The extension strings will not change during the lifetime of
5744 * a context, so there is no danger in doing this.
5746 * This function does not apply to Vulkan. If you are using Vulkan, see @ref
5747 * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
5748 * and `vkEnumerateDeviceExtensionProperties` instead.
5750 * @param[in] extension The ASCII encoded name of the extension.
5751 * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
5754 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5755 * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
5756 * GLFW_PLATFORM_ERROR.
5758 * @thread_safety This function may be called from any thread.
5760 * @sa @ref context_glext
5761 * @sa @ref glfwGetProcAddress
5763 * @since Added in version 1.0.
5767 GLFWAPI int glfwExtensionSupported(const char* extension);
5769 /*! @brief Returns the address of the specified function for the current
5772 * This function returns the address of the specified OpenGL or OpenGL ES
5773 * [core or extension function](@ref context_glext), if it is supported
5774 * by the current context.
5776 * A context must be current on the calling thread. Calling this function
5777 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
5779 * This function does not apply to Vulkan. If you are rendering with Vulkan,
5780 * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
5781 * `vkGetDeviceProcAddr` instead.
5783 * @param[in] procname The ASCII encoded name of the function.
5784 * @return The address of the function, or `NULL` if an
5785 * [error](@ref error_handling) occurred.
5787 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5788 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5790 * @remark The address of a given function is not guaranteed to be the same
5793 * @remark This function may return a non-`NULL` address despite the
5794 * associated version or extension not being available. Always check the
5795 * context version or extension string first.
5797 * @pointer_lifetime The returned function pointer is valid until the context
5798 * is destroyed or the library is terminated.
5800 * @thread_safety This function may be called from any thread.
5802 * @sa @ref context_glext
5803 * @sa @ref glfwExtensionSupported
5805 * @since Added in version 1.0.
5809 GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
5811 /*! @brief Returns whether the Vulkan loader and an ICD have been found.
5813 * This function returns whether the Vulkan loader and any minimally functional
5814 * ICD have been found.
5816 * The availability of a Vulkan loader and even an ICD does not by itself
5817 * guarantee that surface creation or even instance creation is possible.
5818 * For example, on Fermi systems Nvidia will install an ICD that provides no
5819 * actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
5820 * whether the extensions necessary for Vulkan surface creation are available
5821 * and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
5822 * family of a physical device supports image presentation.
5824 * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
5827 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5829 * @thread_safety This function may be called from any thread.
5831 * @sa @ref vulkan_support
5833 * @since Added in version 3.2.
5837 GLFWAPI int glfwVulkanSupported(void);
5839 /*! @brief Returns the Vulkan instance extensions required by GLFW.
5841 * This function returns an array of names of Vulkan instance extensions required
5842 * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
5843 * list will always contain `VK_KHR_surface`, so if you don't require any
5844 * additional extensions you can pass this list directly to the
5845 * `VkInstanceCreateInfo` struct.
5847 * If Vulkan is not available on the machine, this function returns `NULL` and
5848 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
5849 * to check whether Vulkan is at least minimally available.
5851 * If Vulkan is available but no set of extensions allowing window surface
5852 * creation was found, this function returns `NULL`. You may still use Vulkan
5853 * for off-screen rendering and compute work.
5855 * @param[out] count Where to store the number of extensions in the returned
5856 * array. This is set to zero if an error occurred.
5857 * @return An array of ASCII encoded extension names, or `NULL` if an
5858 * [error](@ref error_handling) occurred.
5860 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5861 * GLFW_API_UNAVAILABLE.
5863 * @remark Additional extensions may be required by future versions of GLFW.
5864 * You should check if any extensions you wish to enable are already in the
5865 * returned array, as it is an error to specify an extension more than once in
5866 * the `VkInstanceCreateInfo` struct.
5868 * @remark @macos This function currently supports either the
5869 * `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
5872 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5873 * should not free it yourself. It is guaranteed to be valid only until the
5874 * library is terminated.
5876 * @thread_safety This function may be called from any thread.
5878 * @sa @ref vulkan_ext
5879 * @sa @ref glfwCreateWindowSurface
5881 * @since Added in version 3.2.
5885 GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
5887 #if defined(VK_VERSION_1_0)
5889 /*! @brief Returns the address of the specified Vulkan instance function.
5891 * This function returns the address of the specified Vulkan core or extension
5892 * function for the specified instance. If instance is set to `NULL` it can
5893 * return any function exported from the Vulkan loader, including at least the
5894 * following functions:
5896 * - `vkEnumerateInstanceExtensionProperties`
5897 * - `vkEnumerateInstanceLayerProperties`
5898 * - `vkCreateInstance`
5899 * - `vkGetInstanceProcAddr`
5901 * If Vulkan is not available on the machine, this function returns `NULL` and
5902 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
5903 * to check whether Vulkan is at least minimally available.
5905 * This function is equivalent to calling `vkGetInstanceProcAddr` with
5906 * a platform-specific query of the Vulkan loader as a fallback.
5908 * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
5909 * functions related to instance creation.
5910 * @param[in] procname The ASCII encoded name of the function.
5911 * @return The address of the function, or `NULL` if an
5912 * [error](@ref error_handling) occurred.
5914 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5915 * GLFW_API_UNAVAILABLE.
5917 * @pointer_lifetime The returned function pointer is valid until the library
5920 * @thread_safety This function may be called from any thread.
5922 * @sa @ref vulkan_proc
5924 * @since Added in version 3.2.
5928 GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
5930 /*! @brief Returns whether the specified queue family can present images.
5932 * This function returns whether the specified queue family of the specified
5933 * physical device supports presentation to the platform GLFW was built for.
5935 * If Vulkan or the required window surface creation instance extensions are
5936 * not available on the machine, or if the specified instance was not created
5937 * with the required extensions, this function returns `GLFW_FALSE` and
5938 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
5939 * to check whether Vulkan is at least minimally available and @ref
5940 * glfwGetRequiredInstanceExtensions to check what instance extensions are
5943 * @param[in] instance The instance that the physical device belongs to.
5944 * @param[in] device The physical device that the queue family belongs to.
5945 * @param[in] queuefamily The index of the queue family to query.
5946 * @return `GLFW_TRUE` if the queue family supports presentation, or
5947 * `GLFW_FALSE` otherwise.
5949 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5950 * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
5952 * @remark @macos This function currently always returns `GLFW_TRUE`, as the
5953 * `VK_MVK_macos_surface` extension does not provide
5954 * a `vkGetPhysicalDevice*PresentationSupport` type function.
5956 * @thread_safety This function may be called from any thread. For
5957 * synchronization details of Vulkan objects, see the Vulkan specification.
5959 * @sa @ref vulkan_present
5961 * @since Added in version 3.2.
5965 GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
5967 /*! @brief Creates a Vulkan surface for the specified window.
5969 * This function creates a Vulkan surface for the specified window.
5971 * If the Vulkan loader or at least one minimally functional ICD were not found,
5972 * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
5973 * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
5974 * Vulkan is at least minimally available.
5976 * If the required window surface creation instance extensions are not
5977 * available or if the specified instance was not created with these extensions
5978 * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
5979 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
5980 * glfwGetRequiredInstanceExtensions to check what instance extensions are
5983 * The window surface cannot be shared with another API so the window must
5984 * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
5985 * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
5986 * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
5988 * The window surface must be destroyed before the specified Vulkan instance.
5989 * It is the responsibility of the caller to destroy the window surface. GLFW
5990 * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
5993 * @param[in] instance The Vulkan instance to create the surface in.
5994 * @param[in] window The window to create the surface for.
5995 * @param[in] allocator The allocator to use, or `NULL` to use the default
5997 * @param[out] surface Where to store the handle of the surface. This is set
5998 * to `VK_NULL_HANDLE` if an error occurred.
5999 * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
6000 * [error](@ref error_handling) occurred.
6002 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6003 * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
6005 * @remark If an error occurs before the creation call is made, GLFW returns
6006 * the Vulkan error code most appropriate for the error. Appropriate use of
6007 * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
6008 * eliminate almost all occurrences of these errors.
6010 * @remark @macos This function currently only supports the
6011 * `VK_MVK_macos_surface` extension from MoltenVK.
6013 * @remark @macos This function creates and sets a `CAMetalLayer` instance for
6014 * the window content view, which is required for MoltenVK to function.
6016 * @thread_safety This function may be called from any thread. For
6017 * synchronization details of Vulkan objects, see the Vulkan specification.
6019 * @sa @ref vulkan_surface
6020 * @sa @ref glfwGetRequiredInstanceExtensions
6022 * @since Added in version 3.2.
6026 GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
6028 #endif /*VK_VERSION_1_0*/
6031 /*************************************************************************
6032 * Global definition cleanup
6033 *************************************************************************/
6035 /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
6037 #ifdef GLFW_WINGDIAPI_DEFINED
6039 #undef GLFW_WINGDIAPI_DEFINED
6042 #ifdef GLFW_CALLBACK_DEFINED
6044 #undef GLFW_CALLBACK_DEFINED
6047 /* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
6048 * defined by some gl.h variants (OpenBSD) so define it after if needed.
6051 #define GLAPIENTRY APIENTRY
6054 /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
6061 #endif /* _glfw3_h_ */