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