1 module deimos.glfw.glfw3; 2 /************************************************************************* 3 * GLFW - An OpenGL library 4 * API version: 3.0 5 * WWW: http://www.glfw.org/ 6 *------------------------------------------------------------------------ 7 * Copyright (c) 2002-2006 Marcus Geelnard 8 * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org> 9 * 10 * This software is provided 'as-is', without any express or implied 11 * warranty. In no event will the authors be held liable for any damages 12 * arising from the use of this software. 13 * 14 * Permission is granted to anyone to use this software for any purpose, 15 * including commercial applications, and to alter it and redistribute it 16 * freely, subject to the following restrictions: 17 * 18 * 1. The origin of this software must not be misrepresented; you must not 19 * claim that you wrote the original software. If you use this software 20 * in a product, an acknowledgment in the product documentation would 21 * be appreciated but is not required. 22 * 23 * 2. Altered source versions must be plainly marked as such, and must not 24 * be misrepresented as being the original software. 25 * 26 * 3. This notice may not be removed or altered from any source 27 * distribution. 28 * 29 *************************************************************************/ 30 31 32 extern(C) { 33 34 35 /************************************************************************* 36 * Doxygen documentation 37 *************************************************************************/ 38 39 /*! @defgroup clipboard Clipboard support 40 */ 41 /*! @defgroup context Context handling 42 */ 43 /*! @defgroup error Error handling 44 */ 45 /*! @defgroup init Initialization and version information 46 */ 47 /*! @defgroup input Input handling 48 */ 49 /*! @defgroup monitor Monitor handling 50 * 51 * This is the reference documentation for monitor related functions and types. 52 * For more information, see the @ref monitor. 53 */ 54 /*! @defgroup time Time input 55 */ 56 /*! @defgroup window Window handling 57 * 58 * This is the reference documentation for window related functions and types, 59 * including creation, deletion and event polling. For more information, see 60 * the @ref window. 61 */ 62 63 64 /************************************************************************* 65 * Global definitions 66 *************************************************************************/ 67 68 69 70 /* Include the chosen client API headers. 71 */ 72 73 74 /************************************************************************* 75 * GLFW API tokens 76 *************************************************************************/ 77 78 /*! @name GLFW version macros 79 * @{ */ 80 /*! @brief The major version number of the GLFW library. 81 * 82 * This is incremented when the API is changed in non-compatible ways. 83 * @ingroup init 84 */ 85 enum GLFW_VERSION_MAJOR = 3; 86 /*! @brief The minor version number of the GLFW library. 87 * 88 * This is incremented when features are added to the API but it remains 89 * backward-compatible. 90 * @ingroup init 91 */ 92 enum GLFW_VERSION_MINOR = 0; 93 /*! @brief The revision number of the GLFW library. 94 * 95 * This is incremented when a bug fix release is made that does not contain any 96 * API changes. 97 * @ingroup init 98 */ 99 enum GLFW_VERSION_REVISION = 2; 100 /*! @} */ 101 102 /*! @name Key and button actions 103 * @{ */ 104 /*! @brief The key or button was released. 105 * @ingroup input 106 */ 107 enum GLFW_RELEASE = 0; 108 /*! @brief The key or button was pressed. 109 * @ingroup input 110 */ 111 enum GLFW_PRESS = 1; 112 /*! @brief The key was held down until it repeated. 113 * @ingroup input 114 */ 115 enum GLFW_REPEAT = 2; 116 /*! @} */ 117 118 /*! @defgroup keys Keyboard keys 119 * 120 * These key codes are inspired by the *USB HID Usage Tables v1.12* (p. 53-60), 121 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are 122 * put in the 256+ range). 123 * 124 * The naming of the key codes follow these rules: 125 * - The US keyboard layout is used 126 * - Names of printable alpha-numeric characters are used (e.g. "A", "R", 127 * "3", etc.) 128 * - For non-alphanumeric characters, Unicode:ish names are used (e.g. 129 * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not 130 * correspond to the Unicode standard (usually for brevity) 131 * - Keys that lack a clear US mapping are named "WORLD_x" 132 * - For non-printable keys, custom names are used (e.g. "F4", 133 * "BACKSPACE", etc.) 134 * 135 * @ingroup input 136 * @{ 137 */ 138 139 /* The unknown key */ 140 enum GLFW_KEY_UNKNOWN = -1; 141 142 /* Printable keys */ 143 enum GLFW_KEY_SPACE = 32; 144 enum GLFW_KEY_APOSTROPHE = 39; /* ' */ 145 enum GLFW_KEY_COMMA = 44; /* , */ 146 enum GLFW_KEY_MINUS = 45; /* - */ 147 enum GLFW_KEY_PERIOD = 46; /* . */ 148 enum GLFW_KEY_SLASH = 47; /* / */ 149 enum GLFW_KEY_0 = 48; 150 enum GLFW_KEY_1 = 49; 151 enum GLFW_KEY_2 = 50; 152 enum GLFW_KEY_3 = 51; 153 enum GLFW_KEY_4 = 52; 154 enum GLFW_KEY_5 = 53; 155 enum GLFW_KEY_6 = 54; 156 enum GLFW_KEY_7 = 55; 157 enum GLFW_KEY_8 = 56; 158 enum GLFW_KEY_9 = 57; 159 enum GLFW_KEY_SEMICOLON = 59; /* ; */ 160 enum GLFW_KEY_EQUAL = 61; /* = */ 161 enum GLFW_KEY_A = 65; 162 enum GLFW_KEY_B = 66; 163 enum GLFW_KEY_C = 67; 164 enum GLFW_KEY_D = 68; 165 enum GLFW_KEY_E = 69; 166 enum GLFW_KEY_F = 70; 167 enum GLFW_KEY_G = 71; 168 enum GLFW_KEY_H = 72; 169 enum GLFW_KEY_I = 73; 170 enum GLFW_KEY_J = 74; 171 enum GLFW_KEY_K = 75; 172 enum GLFW_KEY_L = 76; 173 enum GLFW_KEY_M = 77; 174 enum GLFW_KEY_N = 78; 175 enum GLFW_KEY_O = 79; 176 enum GLFW_KEY_P = 80; 177 enum GLFW_KEY_Q = 81; 178 enum GLFW_KEY_R = 82; 179 enum GLFW_KEY_S = 83; 180 enum GLFW_KEY_T = 84; 181 enum GLFW_KEY_U = 85; 182 enum GLFW_KEY_V = 86; 183 enum GLFW_KEY_W = 87; 184 enum GLFW_KEY_X = 88; 185 enum GLFW_KEY_Y = 89; 186 enum GLFW_KEY_Z = 90; 187 enum GLFW_KEY_LEFT_BRACKET = 91; /* [ */ 188 enum GLFW_KEY_BACKSLASH = 92; /* \ */ 189 enum GLFW_KEY_RIGHT_BRACKET = 93; /* ] */ 190 enum GLFW_KEY_GRAVE_ACCENT = 96; /* ` */ 191 enum GLFW_KEY_WORLD_1 = 161; /* non-US #1 */ 192 enum GLFW_KEY_WORLD_2 = 162; /* non-US #2 */ 193 194 /* Function keys */ 195 enum GLFW_KEY_ESCAPE = 256; 196 enum GLFW_KEY_ENTER = 257; 197 enum GLFW_KEY_TAB = 258; 198 enum GLFW_KEY_BACKSPACE = 259; 199 enum GLFW_KEY_INSERT = 260; 200 enum GLFW_KEY_DELETE = 261; 201 enum GLFW_KEY_RIGHT = 262; 202 enum GLFW_KEY_LEFT = 263; 203 enum GLFW_KEY_DOWN = 264; 204 enum GLFW_KEY_UP = 265; 205 enum GLFW_KEY_PAGE_UP = 266; 206 enum GLFW_KEY_PAGE_DOWN = 267; 207 enum GLFW_KEY_HOME = 268; 208 enum GLFW_KEY_END = 269; 209 enum GLFW_KEY_CAPS_LOCK = 280; 210 enum GLFW_KEY_SCROLL_LOCK = 281; 211 enum GLFW_KEY_NUM_LOCK = 282; 212 enum GLFW_KEY_PRINT_SCREEN = 283; 213 enum GLFW_KEY_PAUSE = 284; 214 enum GLFW_KEY_F1 = 290; 215 enum GLFW_KEY_F2 = 291; 216 enum GLFW_KEY_F3 = 292; 217 enum GLFW_KEY_F4 = 293; 218 enum GLFW_KEY_F5 = 294; 219 enum GLFW_KEY_F6 = 295; 220 enum GLFW_KEY_F7 = 296; 221 enum GLFW_KEY_F8 = 297; 222 enum GLFW_KEY_F9 = 298; 223 enum GLFW_KEY_F10 = 299; 224 enum GLFW_KEY_F11 = 300; 225 enum GLFW_KEY_F12 = 301; 226 enum GLFW_KEY_F13 = 302; 227 enum GLFW_KEY_F14 = 303; 228 enum GLFW_KEY_F15 = 304; 229 enum GLFW_KEY_F16 = 305; 230 enum GLFW_KEY_F17 = 306; 231 enum GLFW_KEY_F18 = 307; 232 enum GLFW_KEY_F19 = 308; 233 enum GLFW_KEY_F20 = 309; 234 enum GLFW_KEY_F21 = 310; 235 enum GLFW_KEY_F22 = 311; 236 enum GLFW_KEY_F23 = 312; 237 enum GLFW_KEY_F24 = 313; 238 enum GLFW_KEY_F25 = 314; 239 enum GLFW_KEY_KP_0 = 320; 240 enum GLFW_KEY_KP_1 = 321; 241 enum GLFW_KEY_KP_2 = 322; 242 enum GLFW_KEY_KP_3 = 323; 243 enum GLFW_KEY_KP_4 = 324; 244 enum GLFW_KEY_KP_5 = 325; 245 enum GLFW_KEY_KP_6 = 326; 246 enum GLFW_KEY_KP_7 = 327; 247 enum GLFW_KEY_KP_8 = 328; 248 enum GLFW_KEY_KP_9 = 329; 249 enum GLFW_KEY_KP_DECIMAL = 330; 250 enum GLFW_KEY_KP_DIVIDE = 331; 251 enum GLFW_KEY_KP_MULTIPLY = 332; 252 enum GLFW_KEY_KP_SUBTRACT = 333; 253 enum GLFW_KEY_KP_ADD = 334; 254 enum GLFW_KEY_KP_ENTER = 335; 255 enum GLFW_KEY_KP_EQUAL = 336; 256 enum GLFW_KEY_LEFT_SHIFT = 340; 257 enum GLFW_KEY_LEFT_CONTROL = 341; 258 enum GLFW_KEY_LEFT_ALT = 342; 259 enum GLFW_KEY_LEFT_SUPER = 343; 260 enum GLFW_KEY_RIGHT_SHIFT = 344; 261 enum GLFW_KEY_RIGHT_CONTROL = 345; 262 enum GLFW_KEY_RIGHT_ALT = 346; 263 enum GLFW_KEY_RIGHT_SUPER = 347; 264 enum GLFW_KEY_MENU = 348; 265 enum GLFW_KEY_LAST = GLFW_KEY_MENU; 266 267 /*! @} */ 268 269 /*! @defgroup mods Modifier key flags 270 * @ingroup input 271 * @{ */ 272 273 /*! @brief If this bit is set one or more Shift keys were held down. 274 */ 275 enum GLFW_MOD_SHIFT = 0x0001; 276 /*! @brief If this bit is set one or more Control keys were held down. 277 */ 278 enum GLFW_MOD_CONTROL = 0x0002; 279 /*! @brief If this bit is set one or more Alt keys were held down. 280 */ 281 enum GLFW_MOD_ALT = 0x0004; 282 /*! @brief If this bit is set one or more Super keys were held down. 283 */ 284 enum GLFW_MOD_SUPER = 0x0008; 285 286 /*! @} */ 287 288 /*! @defgroup buttons Mouse buttons 289 * @ingroup input 290 * @{ */ 291 enum GLFW_MOUSE_BUTTON_1 = 0; 292 enum GLFW_MOUSE_BUTTON_2 = 1; 293 enum GLFW_MOUSE_BUTTON_3 = 2; 294 enum GLFW_MOUSE_BUTTON_4 = 3; 295 enum GLFW_MOUSE_BUTTON_5 = 4; 296 enum GLFW_MOUSE_BUTTON_6 = 5; 297 enum GLFW_MOUSE_BUTTON_7 = 6; 298 enum GLFW_MOUSE_BUTTON_8 = 7; 299 enum GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8; 300 enum GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1; 301 enum GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2; 302 enum GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3; 303 /*! @} */ 304 305 /*! @defgroup joysticks Joysticks 306 * @ingroup input 307 * @{ */ 308 enum GLFW_JOYSTICK_1 = 0; 309 enum GLFW_JOYSTICK_2 = 1; 310 enum GLFW_JOYSTICK_3 = 2; 311 enum GLFW_JOYSTICK_4 = 3; 312 enum GLFW_JOYSTICK_5 = 4; 313 enum GLFW_JOYSTICK_6 = 5; 314 enum GLFW_JOYSTICK_7 = 6; 315 enum GLFW_JOYSTICK_8 = 7; 316 enum GLFW_JOYSTICK_9 = 8; 317 enum GLFW_JOYSTICK_10 = 9; 318 enum GLFW_JOYSTICK_11 = 10; 319 enum GLFW_JOYSTICK_12 = 11; 320 enum GLFW_JOYSTICK_13 = 12; 321 enum GLFW_JOYSTICK_14 = 13; 322 enum GLFW_JOYSTICK_15 = 14; 323 enum GLFW_JOYSTICK_16 = 15; 324 enum GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16; 325 /*! @} */ 326 327 /*! @defgroup errors Error codes 328 * @ingroup error 329 * @{ */ 330 /*! @brief GLFW has not been initialized. 331 */ 332 enum GLFW_NOT_INITIALIZED = 0x00010001; 333 /*! @brief No context is current for this thread. 334 */ 335 enum GLFW_NO_CURRENT_CONTEXT = 0x00010002; 336 /*! @brief One of the enum parameters for the function was given an invalid 337 * enum. 338 */ 339 enum GLFW_INVALID_ENUM = 0x00010003; 340 /*! @brief One of the parameters for the function was given an invalid value. 341 */ 342 enum GLFW_INVALID_VALUE = 0x00010004; 343 /*! @brief A memory allocation failed. 344 */ 345 enum GLFW_OUT_OF_MEMORY = 0x00010005; 346 /*! @brief GLFW could not find support for the requested client API on the 347 * system. 348 */ 349 enum GLFW_API_UNAVAILABLE = 0x00010006; 350 /*! @brief The requested client API version is not available. 351 */ 352 enum GLFW_VERSION_UNAVAILABLE = 0x00010007; 353 /*! @brief A platform-specific error occurred that does not match any of the 354 * more specific categories. 355 */ 356 enum GLFW_PLATFORM_ERROR = 0x00010008; 357 /*! @brief The clipboard did not contain data in the requested format. 358 */ 359 enum GLFW_FORMAT_UNAVAILABLE = 0x00010009; 360 /*! @} */ 361 362 enum GLFW_FOCUSED = 0x00020001; 363 enum GLFW_ICONIFIED = 0x00020002; 364 enum GLFW_RESIZABLE = 0x00020003; 365 enum GLFW_VISIBLE = 0x00020004; 366 enum GLFW_DECORATED = 0x00020005; 367 368 enum GLFW_RED_BITS = 0x00021001; 369 enum GLFW_GREEN_BITS = 0x00021002; 370 enum GLFW_BLUE_BITS = 0x00021003; 371 enum GLFW_ALPHA_BITS = 0x00021004; 372 enum GLFW_DEPTH_BITS = 0x00021005; 373 enum GLFW_STENCIL_BITS = 0x00021006; 374 enum GLFW_ACCUM_RED_BITS = 0x00021007; 375 enum GLFW_ACCUM_GREEN_BITS = 0x00021008; 376 enum GLFW_ACCUM_BLUE_BITS = 0x00021009; 377 enum GLFW_ACCUM_ALPHA_BITS = 0x0002100A; 378 enum GLFW_AUX_BUFFERS = 0x0002100B; 379 enum GLFW_STEREO = 0x0002100C; 380 enum GLFW_SAMPLES = 0x0002100D; 381 enum GLFW_SRGB_CAPABLE = 0x0002100E; 382 enum GLFW_REFRESH_RATE = 0x0002100F; 383 384 enum GLFW_CLIENT_API = 0x00022001; 385 enum GLFW_CONTEXT_VERSION_MAJOR = 0x00022002; 386 enum GLFW_CONTEXT_VERSION_MINOR = 0x00022003; 387 enum GLFW_CONTEXT_REVISION = 0x00022004; 388 enum GLFW_CONTEXT_ROBUSTNESS = 0x00022005; 389 enum GLFW_OPENGL_FORWARD_COMPAT = 0x00022006; 390 enum GLFW_OPENGL_DEBUG_CONTEXT = 0x00022007; 391 enum GLFW_OPENGL_PROFILE = 0x00022008; 392 393 enum GLFW_OPENGL_API = 0x00030001; 394 enum GLFW_OPENGL_ES_API = 0x00030002; 395 396 enum GLFW_NO_ROBUSTNESS = 0; 397 enum GLFW_NO_RESET_NOTIFICATION = 0x00031001; 398 enum GLFW_LOSE_CONTEXT_ON_RESET = 0x00031002; 399 400 enum GLFW_OPENGL_ANY_PROFILE = 0; 401 enum GLFW_OPENGL_CORE_PROFILE = 0x00032001; 402 enum GLFW_OPENGL_COMPAT_PROFILE = 0x00032002; 403 404 enum GLFW_CURSOR = 0x00033001; 405 enum GLFW_STICKY_KEYS = 0x00033002; 406 enum GLFW_STICKY_MOUSE_BUTTONS = 0x00033003; 407 408 enum GLFW_CURSOR_NORMAL = 0x00034001; 409 enum GLFW_CURSOR_HIDDEN = 0x00034002; 410 enum GLFW_CURSOR_DISABLED = 0x00034003; 411 412 enum GLFW_CONNECTED = 0x00040001; 413 enum GLFW_DISCONNECTED = 0x00040002; 414 415 416 /************************************************************************* 417 * GLFW API types 418 *************************************************************************/ 419 420 /*! @brief Client API function pointer type. 421 * 422 * Generic function pointer used for returning client API function pointers 423 * without forcing a cast from a regular pointer. 424 * 425 * @ingroup context 426 */ 427 alias GLFWglproc = void function(); 428 429 /*! @brief Opaque monitor object. 430 * 431 * Opaque monitor object. 432 * 433 * @ingroup monitor 434 */ 435 struct GLFWmonitor; 436 437 /*! @brief Opaque window object. 438 * 439 * Opaque window object. 440 * 441 * @ingroup window 442 */ 443 struct GLFWwindow; 444 445 /*! @brief The function signature for error callbacks. 446 * 447 * This is the function signature for error callback functions. 448 * 449 * @param[in] error An [error code](@ref errors). 450 * @param[in] description A UTF-8 encoded string describing the error. 451 * 452 * @sa glfwSetErrorCallback 453 * 454 * @ingroup error 455 */ 456 alias GLFWerrorfun = void function(int,const(char)*); 457 458 /*! @brief The function signature for window position callbacks. 459 * 460 * This is the function signature for window position callback functions. 461 * 462 * @param[in] window The window that the user moved. 463 * @param[in] xpos The new x-coordinate, in screen coordinates, of the 464 * upper-left corner of the client area of the window. 465 * @param[in] ypos The new y-coordinate, in screen coordinates, of the 466 * upper-left corner of the client area of the window. 467 * 468 * @sa glfwSetWindowPosCallback 469 * 470 * @ingroup window 471 */ 472 alias GLFWwindowposfun = void function(GLFWwindow*,int,int); 473 474 /*! @brief The function signature for window resize callbacks. 475 * 476 * This is the function signature for window size callback functions. 477 * 478 * @param[in] window The window that the user resized. 479 * @param[in] width The new width, in screen coordinates, of the window. 480 * @param[in] height The new height, in screen coordinates, of the window. 481 * 482 * @sa glfwSetWindowSizeCallback 483 * 484 * @ingroup window 485 */ 486 alias GLFWwindowsizefun = void function(GLFWwindow*,int,int); 487 488 /*! @brief The function signature for window close callbacks. 489 * 490 * This is the function signature for window close callback functions. 491 * 492 * @param[in] window The window that the user attempted to close. 493 * 494 * @sa glfwSetWindowCloseCallback 495 * 496 * @ingroup window 497 */ 498 alias GLFWwindowclosefun = void function(GLFWwindow*); 499 500 /*! @brief The function signature for window content refresh callbacks. 501 * 502 * This is the function signature for window refresh callback functions. 503 * 504 * @param[in] window The window whose content needs to be refreshed. 505 * 506 * @sa glfwSetWindowRefreshCallback 507 * 508 * @ingroup window 509 */ 510 alias GLFWwindowrefreshfun = void function(GLFWwindow*); 511 512 /*! @brief The function signature for window focus/defocus callbacks. 513 * 514 * This is the function signature for window focus callback functions. 515 * 516 * @param[in] window The window that was focused or defocused. 517 * @param[in] focused `GL_TRUE` if the window was focused, or `GL_FALSE` if 518 * it was defocused. 519 * 520 * @sa glfwSetWindowFocusCallback 521 * 522 * @ingroup window 523 */ 524 alias GLFWwindowfocusfun = void function(GLFWwindow*,int); 525 526 /*! @brief The function signature for window iconify/restore callbacks. 527 * 528 * This is the function signature for window iconify/restore callback 529 * functions. 530 * 531 * @param[in] window The window that was iconified or restored. 532 * @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE` 533 * if it was restored. 534 * 535 * @sa glfwSetWindowIconifyCallback 536 * 537 * @ingroup window 538 */ 539 alias GLFWwindowiconifyfun = void function(GLFWwindow*,int); 540 541 /*! @brief The function signature for framebuffer resize callbacks. 542 * 543 * This is the function signature for framebuffer resize callback 544 * functions. 545 * 546 * @param[in] window The window whose framebuffer was resized. 547 * @param[in] width The new width, in pixels, of the framebuffer. 548 * @param[in] height The new height, in pixels, of the framebuffer. 549 * 550 * @sa glfwSetFramebufferSizeCallback 551 * 552 * @ingroup window 553 */ 554 alias GLFWframebuffersizefun = void function(GLFWwindow*,int,int); 555 556 /*! @brief The function signature for mouse button callbacks. 557 * 558 * This is the function signature for mouse button callback functions. 559 * 560 * @param[in] window The window that received the event. 561 * @param[in] button The [mouse button](@ref buttons) that was pressed or 562 * released. 563 * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. 564 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were 565 * held down. 566 * 567 * @sa glfwSetMouseButtonCallback 568 * 569 * @ingroup input 570 */ 571 alias GLFWmousebuttonfun = void function(GLFWwindow*,int,int,int); 572 573 /*! @brief The function signature for cursor position callbacks. 574 * 575 * This is the function signature for cursor position callback functions. 576 * 577 * @param[in] window The window that received the event. 578 * @param[in] xpos The new x-coordinate of the cursor. 579 * @param[in] ypos The new y-coordinate of the cursor. 580 * 581 * @sa glfwSetCursorPosCallback 582 * 583 * @ingroup input 584 */ 585 alias GLFWcursorposfun = void function(GLFWwindow*,double,double); 586 587 /*! @brief The function signature for cursor enter/leave callbacks. 588 * 589 * This is the function signature for cursor enter/leave callback functions. 590 * 591 * @param[in] window The window that received the event. 592 * @param[in] entered `GL_TRUE` if the cursor entered the window's client 593 * area, or `GL_FALSE` if it left it. 594 * 595 * @sa glfwSetCursorEnterCallback 596 * 597 * @ingroup input 598 */ 599 alias GLFWcursorenterfun = void function(GLFWwindow*,int); 600 601 /*! @brief The function signature for scroll callbacks. 602 * 603 * This is the function signature for scroll callback functions. 604 * 605 * @param[in] window The window that received the event. 606 * @param[in] xoffset The scroll offset along the x-axis. 607 * @param[in] yoffset The scroll offset along the y-axis. 608 * 609 * @sa glfwSetScrollCallback 610 * 611 * @ingroup input 612 */ 613 alias GLFWscrollfun = void function(GLFWwindow*,double,double); 614 615 /*! @brief The function signature for keyboard key callbacks. 616 * 617 * This is the function signature for keyboard key callback functions. 618 * 619 * @param[in] window The window that received the event. 620 * @param[in] key The [keyboard key](@ref keys) that was pressed or released. 621 * @param[in] scancode The system-specific scancode of the key. 622 * @param[in] action @ref GLFW_PRESS, @ref GLFW_RELEASE or @ref GLFW_REPEAT. 623 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were 624 * held down. 625 * 626 * @sa glfwSetKeyCallback 627 * 628 * @ingroup input 629 */ 630 alias GLFWkeyfun = void function(GLFWwindow*,int,int,int,int); 631 632 /*! @brief The function signature for Unicode character callbacks. 633 * 634 * This is the function signature for Unicode character callback functions. 635 * 636 * @param[in] window The window that received the event. 637 * @param[in] character The Unicode code point of the character. 638 * 639 * @sa glfwSetCharCallback 640 * 641 * @ingroup input 642 */ 643 alias GLFWcharfun = void function(GLFWwindow*,uint); 644 645 /*! @brief The function signature for monitor configuration callbacks. 646 * 647 * This is the function signature for monitor configuration callback functions. 648 * 649 * @param[in] monitor The monitor that was connected or disconnected. 650 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. 651 * 652 * @sa glfwSetMonitorCallback 653 * 654 * @ingroup monitor 655 */ 656 alias GLFWmonitorfun = void function(GLFWmonitor*,int); 657 658 /*! @brief Video mode type. 659 * 660 * This describes a single video mode. 661 * 662 * @ingroup monitor 663 */ 664 struct GLFWvidmode { 665 /*! The width, in screen coordinates, of the video mode. 666 */ 667 int width; 668 /*! The height, in screen coordinates, of the video mode. 669 */ 670 int height; 671 /*! The bit depth of the red channel of the video mode. 672 */ 673 int redBits; 674 /*! The bit depth of the green channel of the video mode. 675 */ 676 int greenBits; 677 /*! The bit depth of the blue channel of the video mode. 678 */ 679 int blueBits; 680 /*! The refresh rate, in Hz, of the video mode. 681 */ 682 int refreshRate; 683 } 684 685 /*! @brief Gamma ramp. 686 * 687 * This describes the gamma ramp for a monitor. 688 * 689 * @sa glfwGetGammaRamp glfwSetGammaRamp 690 * 691 * @ingroup monitor 692 */ 693 struct GLFWgammaramp { 694 /*! An array of value describing the response of the red channel. 695 */ 696 ushort* red; 697 /*! An array of value describing the response of the green channel. 698 */ 699 ushort* green; 700 /*! An array of value describing the response of the blue channel. 701 */ 702 ushort* blue; 703 /*! The number of elements in each array. 704 */ 705 uint size; 706 } 707 708 709 /************************************************************************* 710 * GLFW API functions 711 *************************************************************************/ 712 713 /*! @brief Initializes the GLFW library. 714 * 715 * This function initializes the GLFW library. Before most GLFW functions can 716 * be used, GLFW must be initialized, and before a program terminates GLFW 717 * should be terminated in order to free any resources allocated during or 718 * after initialization. 719 * 720 * If this function fails, it calls @ref glfwTerminate before returning. If it 721 * succeeds, you should call @ref glfwTerminate before the program exits. 722 * 723 * Additional calls to this function after successful initialization but before 724 * termination will succeed but will do nothing. 725 * 726 * @return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred. 727 * 728 * @par New in GLFW 3 729 * This function no longer registers @ref glfwTerminate with `atexit`. 730 * 731 * @note This function may only be called from the main thread. 732 * 733 * @note This function may take several seconds to complete on some systems, 734 * while on other systems it may take only a fraction of a second to complete. 735 * 736 * @note **Mac OS X:** This function will change the current directory of the 737 * application to the `Contents/Resources` subdirectory of the application's 738 * bundle, if present. 739 * 740 * @sa glfwTerminate 741 * 742 * @ingroup init 743 */ 744 int glfwInit(); 745 746 /*! @brief Terminates the GLFW library. 747 * 748 * This function destroys all remaining windows, frees any allocated resources 749 * and sets the library to an uninitialized state. Once this is called, you 750 * must again call @ref glfwInit successfully before you will be able to use 751 * most GLFW functions. 752 * 753 * If GLFW has been successfully initialized, this function should be called 754 * before the program exits. If initialization fails, there is no need to call 755 * this function, as it is called by @ref glfwInit before it returns failure. 756 * 757 * @remarks This function may be called before @ref glfwInit. 758 * 759 * @note This function may only be called from the main thread. 760 * 761 * @warning No window's context may be current on another thread when this 762 * function is called. 763 * 764 * @sa glfwInit 765 * 766 * @ingroup init 767 */ 768 void glfwTerminate(); 769 770 /*! @brief Retrieves the version of the GLFW library. 771 * 772 * This function retrieves the major, minor and revision numbers of the GLFW 773 * library. It is intended for when you are using GLFW as a shared library and 774 * want to ensure that you are using the minimum required version. 775 * 776 * @param[out] major Where to store the major version number, or `NULL`. 777 * @param[out] minor Where to store the minor version number, or `NULL`. 778 * @param[out] rev Where to store the revision number, or `NULL`. 779 * 780 * @remarks This function may be called before @ref glfwInit. 781 * 782 * @remarks This function may be called from any thread. 783 * 784 * @sa glfwGetVersionString 785 * 786 * @ingroup init 787 */ 788 void glfwGetVersion(int* major, int* minor, int* rev); 789 790 /*! @brief Returns a string describing the compile-time configuration. 791 * 792 * This function returns a static string generated at compile-time according to 793 * which configuration macros were defined. This is intended for use when 794 * submitting bug reports, to allow developers to see which code paths are 795 * enabled in a binary. 796 * 797 * The format of the string is as follows: 798 * - The version of GLFW 799 * - The name of the window system API 800 * - The name of the context creation API 801 * - Any additional options or APIs 802 * 803 * For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL 804 * back ends, the version string may look something like this: 805 * 806 * 3.0.0 Win32 WGL MinGW 807 * 808 * @return The GLFW version string. 809 * 810 * @remarks This function may be called before @ref glfwInit. 811 * 812 * @remarks This function may be called from any thread. 813 * 814 * @sa glfwGetVersion 815 * 816 * @ingroup init 817 */ 818 const(char)* glfwGetVersionString(); 819 820 /*! @brief Sets the error callback. 821 * 822 * This function sets the error callback, which is called with an error code 823 * and a human-readable description each time a GLFW error occurs. 824 * 825 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 826 * callback. 827 * @return The previously set callback, or `NULL` if no callback was set or an 828 * error occurred. 829 * 830 * @remarks This function may be called before @ref glfwInit. 831 * 832 * @note The error callback is called by the thread where the error was 833 * generated. If you are using GLFW from multiple threads, your error callback 834 * needs to be written accordingly. 835 * 836 * @note Because the description string provided to the callback may have been 837 * generated specifically for that error, it is not guaranteed to be valid 838 * after the callback has returned. If you wish to use it after that, you need 839 * to make your own copy of it before returning. 840 * 841 * @ingroup error 842 */ 843 GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun); 844 845 /*! @brief Returns the currently connected monitors. 846 * 847 * This function returns an array of handles for all currently connected 848 * monitors. 849 * 850 * @param[out] count Where to store the size of the returned array. This is 851 * set to zero if an error occurred. 852 * @return An array of monitor handles, or `NULL` if an error occurred. 853 * 854 * @note The returned array is allocated and freed by GLFW. You should not 855 * free it yourself. 856 * 857 * @note The returned array is valid only until the monitor configuration 858 * changes. See @ref glfwSetMonitorCallback to receive notifications of 859 * configuration changes. 860 * 861 * @sa glfwGetPrimaryMonitor 862 * 863 * @ingroup monitor 864 */ 865 GLFWmonitor** glfwGetMonitors(int* count); 866 867 /*! @brief Returns the primary monitor. 868 * 869 * This function returns the primary monitor. This is usually the monitor 870 * where elements like the Windows task bar or the OS X menu bar is located. 871 * 872 * @return The primary monitor, or `NULL` if an error occurred. 873 * 874 * @sa glfwGetMonitors 875 * 876 * @ingroup monitor 877 */ 878 GLFWmonitor* glfwGetPrimaryMonitor(); 879 880 /*! @brief Returns the position of the monitor's viewport on the virtual screen. 881 * 882 * This function returns the position, in screen coordinates, of the upper-left 883 * corner of the specified monitor. 884 * 885 * @param[in] monitor The monitor to query. 886 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`. 887 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`. 888 * 889 * @ingroup monitor 890 */ 891 void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); 892 893 /*! @brief Returns the physical size of the monitor. 894 * 895 * This function returns the size, in millimetres, of the display area of the 896 * specified monitor. 897 * 898 * @param[in] monitor The monitor to query. 899 * @param[out] width Where to store the width, in mm, of the monitor's display 900 * area, or `NULL`. 901 * @param[out] height Where to store the height, in mm, of the monitor's 902 * display area, or `NULL`. 903 * 904 * @note Some operating systems do not provide accurate information, either 905 * because the monitor's EDID data is incorrect, or because the driver does not 906 * report it accurately. 907 * 908 * @ingroup monitor 909 */ 910 void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height); 911 912 /*! @brief Returns the name of the specified monitor. 913 * 914 * This function returns a human-readable name, encoded as UTF-8, of the 915 * specified monitor. 916 * 917 * @param[in] monitor The monitor to query. 918 * @return The UTF-8 encoded name of the monitor, or `NULL` if an error 919 * occurred. 920 * 921 * @note The returned string is allocated and freed by GLFW. You should not 922 * free it yourself. 923 * 924 * @ingroup monitor 925 */ 926 const(char)* glfwGetMonitorName(GLFWmonitor* monitor); 927 928 /*! @brief Sets the monitor configuration callback. 929 * 930 * This function sets the monitor configuration callback, or removes the 931 * currently set callback. This is called when a monitor is connected to or 932 * disconnected from the system. 933 * 934 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 935 * callback. 936 * @return The previously set callback, or `NULL` if no callback was set or an 937 * error occurred. 938 * 939 * @bug **X11:** This callback is not yet called on monitor configuration 940 * changes. 941 * 942 * @ingroup monitor 943 */ 944 GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); 945 946 /*! @brief Returns the available video modes for the specified monitor. 947 * 948 * This function returns an array of all video modes supported by the specified 949 * monitor. The returned array is sorted in ascending order, first by color 950 * bit depth (the sum of all channel depths) and then by resolution area (the 951 * product of width and height). 952 * 953 * @param[in] monitor The monitor to query. 954 * @param[out] count Where to store the number of video modes in the returned 955 * array. This is set to zero if an error occurred. 956 * @return An array of video modes, or `NULL` if an error occurred. 957 * 958 * @note The returned array is allocated and freed by GLFW. You should not 959 * free it yourself. 960 * 961 * @note The returned array is valid only until this function is called again 962 * for the specified monitor. 963 * 964 * @sa glfwGetVideoMode 965 * 966 * @ingroup monitor 967 */ 968 const(GLFWvidmode)* glfwGetVideoModes(GLFWmonitor* monitor, int* count); 969 970 /*! @brief Returns the current mode of the specified monitor. 971 * 972 * This function returns the current video mode of the specified monitor. If 973 * you are using a full screen window, the return value will therefore depend 974 * on whether it is focused. 975 * 976 * @param[in] monitor The monitor to query. 977 * @return The current mode of the monitor, or `NULL` if an error occurred. 978 * 979 * @note The returned struct is allocated and freed by GLFW. You should not 980 * free it yourself. 981 * 982 * @sa glfwGetVideoModes 983 * 984 * @ingroup monitor 985 */ 986 const(GLFWvidmode)* glfwGetVideoMode(GLFWmonitor* monitor); 987 988 /*! @brief Generates a gamma ramp and sets it for the specified monitor. 989 * 990 * This function generates a 256-element gamma ramp from the specified exponent 991 * and then calls @ref glfwSetGammaRamp with it. 992 * 993 * @param[in] monitor The monitor whose gamma ramp to set. 994 * @param[in] gamma The desired exponent. 995 * 996 * @ingroup monitor 997 */ 998 void glfwSetGamma(GLFWmonitor* monitor, float gamma); 999 1000 /*! @brief Retrieves the current gamma ramp for the specified monitor. 1001 * 1002 * This function retrieves the current gamma ramp of the specified monitor. 1003 * 1004 * @param[in] monitor The monitor to query. 1005 * @return The current gamma ramp, or `NULL` if an error occurred. 1006 * 1007 * @note The value arrays of the returned ramp are allocated and freed by GLFW. 1008 * You should not free them yourself. 1009 * 1010 * @ingroup monitor 1011 */ 1012 const(GLFWgammaramp)* glfwGetGammaRamp(GLFWmonitor* monitor); 1013 1014 /*! @brief Sets the current gamma ramp for the specified monitor. 1015 * 1016 * This function sets the current gamma ramp for the specified monitor. 1017 * 1018 * @param[in] monitor The monitor whose gamma ramp to set. 1019 * @param[in] ramp The gamma ramp to use. 1020 * 1021 * @note Gamma ramp sizes other than 256 are not supported by all hardware. 1022 * 1023 * @ingroup monitor 1024 */ 1025 void glfwSetGammaRamp(GLFWmonitor* monitor, const(GLFWgammaramp)* ramp); 1026 1027 /*! @brief Resets all window hints to their default values. 1028 * 1029 * This function resets all window hints to their 1030 * [default values](@ref window_hints_values). 1031 * 1032 * @note This function may only be called from the main thread. 1033 * 1034 * @sa glfwWindowHint 1035 * 1036 * @ingroup window 1037 */ 1038 void glfwDefaultWindowHints(); 1039 1040 /*! @brief Sets the specified window hint to the desired value. 1041 * 1042 * This function sets hints for the next call to @ref glfwCreateWindow. The 1043 * hints, once set, retain their values until changed by a call to @ref 1044 * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is 1045 * terminated with @ref glfwTerminate. 1046 * 1047 * @param[in] target The [window hint](@ref window_hints) to set. 1048 * @param[in] hint The new value of the window hint. 1049 * 1050 * @par New in GLFW 3 1051 * Hints are no longer reset to their default values on window creation. To 1052 * set default hint values, use @ref glfwDefaultWindowHints. 1053 * 1054 * @note This function may only be called from the main thread. 1055 * 1056 * @sa glfwDefaultWindowHints 1057 * 1058 * @ingroup window 1059 */ 1060 void glfwWindowHint(int target, int hint); 1061 1062 /*! @brief Creates a window and its associated context. 1063 * 1064 * This function creates a window and its associated context. Most of the 1065 * options controlling how the window and its context should be created are 1066 * specified through @ref glfwWindowHint. 1067 * 1068 * Successful creation does not change which context is current. Before you 1069 * can use the newly created context, you need to make it current using @ref 1070 * glfwMakeContextCurrent. 1071 * 1072 * Note that the created window and context may differ from what you requested, 1073 * as not all parameters and hints are 1074 * [hard constraints](@ref window_hints_hard). This includes the size of the 1075 * window, especially for full screen windows. To retrieve the actual 1076 * attributes of the created window and context, use queries like @ref 1077 * glfwGetWindowAttrib and @ref glfwGetWindowSize. 1078 * 1079 * To create the window at a specific position, make it initially invisible 1080 * using the `GLFW_VISIBLE` window hint, set its position and then show it. 1081 * 1082 * If a fullscreen window is active, the screensaver is prohibited from 1083 * starting. 1084 * 1085 * @param[in] width The desired width, in screen coordinates, of the window. 1086 * This must be greater than zero. 1087 * @param[in] height The desired height, in screen coordinates, of the window. 1088 * This must be greater than zero. 1089 * @param[in] title The initial, UTF-8 encoded window title. 1090 * @param[in] monitor The monitor to use for full screen mode, or `NULL` to use 1091 * windowed mode. 1092 * @param[in] share The window whose context to share resources with, or `NULL` 1093 * to not share resources. 1094 * @return The handle of the created window, or `NULL` if an error occurred. 1095 * 1096 * @remarks **Windows:** If the executable has an icon resource named 1097 * `GLFW_ICON,` it will be set as the icon for the window. If no such icon is 1098 * present, the `IDI_WINLOGO` icon will be used instead. 1099 * 1100 * @remarks **Mac OS X:** The GLFW window has no icon, as it is not a document 1101 * window, but the dock icon will be the same as the application bundle's icon. 1102 * Also, the first time a window is opened the menu bar is populated with 1103 * common commands like Hide, Quit and About. The (minimal) about dialog uses 1104 * information from the application's bundle. For more information on bundles, 1105 * see the Bundle Programming Guide provided by Apple. 1106 * 1107 * @note This function may only be called from the main thread. 1108 * 1109 * @sa glfwDestroyWindow 1110 * 1111 * @ingroup window 1112 */ 1113 GLFWwindow* glfwCreateWindow(int width, int height, const(char)* title, GLFWmonitor* monitor, GLFWwindow* share); 1114 1115 /*! @brief Destroys the specified window and its context. 1116 * 1117 * This function destroys the specified window and its context. On calling 1118 * this function, no further callbacks will be called for that window. 1119 * 1120 * @param[in] window The window to destroy. 1121 * 1122 * @note This function may only be called from the main thread. 1123 * 1124 * @note This function may not be called from a callback. 1125 * 1126 * @note If the window's context is current on the main thread, it is 1127 * detached before being destroyed. 1128 * 1129 * @warning The window's context must not be current on any other thread. 1130 * 1131 * @sa glfwCreateWindow 1132 * 1133 * @ingroup window 1134 */ 1135 void glfwDestroyWindow(GLFWwindow* window); 1136 1137 /*! @brief Checks the close flag of the specified window. 1138 * 1139 * This function returns the value of the close flag of the specified window. 1140 * 1141 * @param[in] window The window to query. 1142 * @return The value of the close flag. 1143 * 1144 * @ingroup window 1145 */ 1146 int glfwWindowShouldClose(GLFWwindow* window); 1147 1148 /*! @brief Sets the close flag of the specified window. 1149 * 1150 * This function sets the value of the close flag of the specified window. 1151 * This can be used to override the user's attempt to close the window, or 1152 * to signal that it should be closed. 1153 * 1154 * @param[in] window The window whose flag to change. 1155 * @param[in] value The new value. 1156 * 1157 * @ingroup window 1158 */ 1159 void glfwSetWindowShouldClose(GLFWwindow* window, int value); 1160 1161 /*! @brief Sets the title of the specified window. 1162 * 1163 * This function sets the window title, encoded as UTF-8, of the specified 1164 * window. 1165 * 1166 * @param[in] window The window whose title to change. 1167 * @param[in] title The UTF-8 encoded window title. 1168 * 1169 * @note This function may only be called from the main thread. 1170 * 1171 * @ingroup window 1172 */ 1173 void glfwSetWindowTitle(GLFWwindow* window, const(char)* title); 1174 1175 /*! @brief Retrieves the position of the client area of the specified window. 1176 * 1177 * This function retrieves the position, in screen coordinates, of the 1178 * upper-left corner of the client area of the specified window. 1179 * 1180 * @param[in] window The window to query. 1181 * @param[out] xpos Where to store the x-coordinate of the upper-left corner of 1182 * the client area, or `NULL`. 1183 * @param[out] ypos Where to store the y-coordinate of the upper-left corner of 1184 * the client area, or `NULL`. 1185 * 1186 * @sa glfwSetWindowPos 1187 * 1188 * @ingroup window 1189 */ 1190 void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); 1191 1192 /*! @brief Sets the position of the client area of the specified window. 1193 * 1194 * This function sets the position, in screen coordinates, of the upper-left 1195 * corner of the client area of the window. 1196 * 1197 * If the specified window is a full screen window, this function does nothing. 1198 * 1199 * If you wish to set an initial window position you should create a hidden 1200 * window (using @ref glfwWindowHint and `GLFW_VISIBLE`), set its position and 1201 * then show it. 1202 * 1203 * @param[in] window The window to query. 1204 * @param[in] xpos The x-coordinate of the upper-left corner of the client area. 1205 * @param[in] ypos The y-coordinate of the upper-left corner of the client area. 1206 * 1207 * @note It is very rarely a good idea to move an already visible window, as it 1208 * will confuse and annoy the user. 1209 * 1210 * @note This function may only be called from the main thread. 1211 * 1212 * @note The window manager may put limits on what positions are allowed. 1213 * 1214 * @bug **X11:** Some window managers ignore the set position of hidden (i.e. 1215 * unmapped) windows, instead placing them where it thinks is appropriate once 1216 * they are shown. 1217 * 1218 * @sa glfwGetWindowPos 1219 * 1220 * @ingroup window 1221 */ 1222 void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); 1223 1224 /*! @brief Retrieves the size of the client area of the specified window. 1225 * 1226 * This function retrieves the size, in screen coordinates, of the client area 1227 * of the specified window. 1228 * 1229 * @param[in] window The window whose size to retrieve. 1230 * @param[out] width Where to store the width, in screen coordinates, of the 1231 * client area, or `NULL`. 1232 * @param[out] height Where to store the height, in screen coordinates, of the 1233 * client area, or `NULL`. 1234 * 1235 * @sa glfwSetWindowSize 1236 * 1237 * @ingroup window 1238 */ 1239 void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); 1240 1241 /*! @brief Sets the size of the client area of the specified window. 1242 * 1243 * This function sets the size, in screen coordinates, of the client area of 1244 * the specified window. 1245 * 1246 * For full screen windows, this function selects and switches to the resolution 1247 * closest to the specified size, without affecting the window's context. As 1248 * the context is unaffected, the bit depths of the framebuffer remain 1249 * unchanged. 1250 * 1251 * @param[in] window The window to resize. 1252 * @param[in] width The desired width of the specified window. 1253 * @param[in] height The desired height of the specified window. 1254 * 1255 * @note This function may only be called from the main thread. 1256 * 1257 * @note The window manager may put limits on what window sizes are allowed. 1258 * 1259 * @sa glfwGetWindowSize 1260 * 1261 * @ingroup window 1262 */ 1263 void glfwSetWindowSize(GLFWwindow* window, int width, int height); 1264 1265 /*! @brief Retrieves the size of the framebuffer of the specified window. 1266 * 1267 * This function retrieves the size, in pixels, of the framebuffer of the 1268 * specified window. 1269 * 1270 * @param[in] window The window whose framebuffer to query. 1271 * @param[out] width Where to store the width, in pixels, of the framebuffer, 1272 * or `NULL`. 1273 * @param[out] height Where to store the height, in pixels, of the framebuffer, 1274 * or `NULL`. 1275 * 1276 * @sa glfwSetFramebufferSizeCallback 1277 * 1278 * @ingroup window 1279 */ 1280 void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); 1281 1282 /*! @brief Iconifies the specified window. 1283 * 1284 * This function iconifies/minimizes the specified window, if it was previously 1285 * restored. If it is a full screen window, the original monitor resolution is 1286 * restored until the window is restored. If the window is already iconified, 1287 * this function does nothing. 1288 * 1289 * @param[in] window The window to iconify. 1290 * 1291 * @note This function may only be called from the main thread. 1292 * 1293 * @sa glfwRestoreWindow 1294 * 1295 * @ingroup window 1296 */ 1297 void glfwIconifyWindow(GLFWwindow* window); 1298 1299 /*! @brief Restores the specified window. 1300 * 1301 * This function restores the specified window, if it was previously 1302 * iconified/minimized. If it is a full screen window, the resolution chosen 1303 * for the window is restored on the selected monitor. If the window is 1304 * already restored, this function does nothing. 1305 * 1306 * @param[in] window The window to restore. 1307 * 1308 * @note This function may only be called from the main thread. 1309 * 1310 * @sa glfwIconifyWindow 1311 * 1312 * @ingroup window 1313 */ 1314 void glfwRestoreWindow(GLFWwindow* window); 1315 1316 /*! @brief Makes the specified window visible. 1317 * 1318 * This function makes the specified window visible, if it was previously 1319 * hidden. If the window is already visible or is in full screen mode, this 1320 * function does nothing. 1321 * 1322 * @param[in] window The window to make visible. 1323 * 1324 * @note This function may only be called from the main thread. 1325 * 1326 * @sa glfwHideWindow 1327 * 1328 * @ingroup window 1329 */ 1330 void glfwShowWindow(GLFWwindow* window); 1331 1332 /*! @brief Hides the specified window. 1333 * 1334 * This function hides the specified window, if it was previously visible. If 1335 * the window is already hidden or is in full screen mode, this function does 1336 * nothing. 1337 * 1338 * @param[in] window The window to hide. 1339 * 1340 * @note This function may only be called from the main thread. 1341 * 1342 * @sa glfwShowWindow 1343 * 1344 * @ingroup window 1345 */ 1346 void glfwHideWindow(GLFWwindow* window); 1347 1348 /*! @brief Returns the monitor that the window uses for full screen mode. 1349 * 1350 * This function returns the handle of the monitor that the specified window is 1351 * in full screen on. 1352 * 1353 * @param[in] window The window to query. 1354 * @return The monitor, or `NULL` if the window is in windowed mode. 1355 * 1356 * @ingroup window 1357 */ 1358 GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); 1359 1360 /*! @brief Returns an attribute of the specified window. 1361 * 1362 * This function returns an attribute of the specified window. There are many 1363 * attributes, some related to the window and others to its context. 1364 * 1365 * @param[in] window The window to query. 1366 * @param[in] attrib The [window attribute](@ref window_attribs) whose value to 1367 * return. 1368 * @return The value of the attribute, or zero if an error occurred. 1369 * 1370 * @ingroup window 1371 */ 1372 int glfwGetWindowAttrib(GLFWwindow* window, int attrib); 1373 1374 /*! @brief Sets the user pointer of the specified window. 1375 * 1376 * This function sets the user-defined pointer of the specified window. The 1377 * current value is retained until the window is destroyed. The initial value 1378 * is `NULL`. 1379 * 1380 * @param[in] window The window whose pointer to set. 1381 * @param[in] pointer The new value. 1382 * 1383 * @sa glfwGetWindowUserPointer 1384 * 1385 * @ingroup window 1386 */ 1387 void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); 1388 1389 /*! @brief Returns the user pointer of the specified window. 1390 * 1391 * This function returns the current value of the user-defined pointer of the 1392 * specified window. The initial value is `NULL`. 1393 * 1394 * @param[in] window The window whose pointer to return. 1395 * 1396 * @sa glfwSetWindowUserPointer 1397 * 1398 * @ingroup window 1399 */ 1400 void* glfwGetWindowUserPointer(GLFWwindow* window); 1401 1402 /*! @brief Sets the position callback for the specified window. 1403 * 1404 * This function sets the position callback of the specified window, which is 1405 * called when the window is moved. The callback is provided with the screen 1406 * position of the upper-left corner of the client area of the window. 1407 * 1408 * @param[in] window The window whose callback to set. 1409 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1410 * callback. 1411 * @return The previously set callback, or `NULL` if no callback was set or an 1412 * error occurred. 1413 * 1414 * @ingroup window 1415 */ 1416 GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun); 1417 1418 /*! @brief Sets the size callback for the specified window. 1419 * 1420 * This function sets the size callback of the specified window, which is 1421 * called when the window is resized. The callback is provided with the size, 1422 * in screen coordinates, of the client area of the window. 1423 * 1424 * @param[in] window The window whose callback to set. 1425 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1426 * callback. 1427 * @return The previously set callback, or `NULL` if no callback was set or an 1428 * error occurred. 1429 * 1430 * @ingroup window 1431 */ 1432 GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); 1433 1434 /*! @brief Sets the close callback for the specified window. 1435 * 1436 * This function sets the close callback of the specified window, which is 1437 * called when the user attempts to close the window, for example by clicking 1438 * the close widget in the title bar. 1439 * 1440 * The close flag is set before this callback is called, but you can modify it 1441 * at any time with @ref glfwSetWindowShouldClose. 1442 * 1443 * The close callback is not triggered by @ref glfwDestroyWindow. 1444 * 1445 * @param[in] window The window whose callback to set. 1446 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1447 * callback. 1448 * @return The previously set callback, or `NULL` if no callback was set or an 1449 * error occurred. 1450 * 1451 * @remarks **Mac OS X:** Selecting Quit from the application menu will 1452 * trigger the close callback for all windows. 1453 * 1454 * @ingroup window 1455 */ 1456 GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun); 1457 1458 /*! @brief Sets the refresh callback for the specified window. 1459 * 1460 * This function sets the refresh callback of the specified window, which is 1461 * called when the client area of the window needs to be redrawn, for example 1462 * if the window has been exposed after having been covered by another window. 1463 * 1464 * On compositing window systems such as Aero, Compiz or Aqua, where the window 1465 * contents are saved off-screen, this callback may be called only very 1466 * infrequently or never at all. 1467 * 1468 * @param[in] window The window whose callback to set. 1469 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1470 * callback. 1471 * @return The previously set callback, or `NULL` if no callback was set or an 1472 * error occurred. 1473 * 1474 * @note On compositing window systems such as Aero, Compiz or Aqua, where the 1475 * window contents are saved off-screen, this callback may be called only very 1476 * infrequently or never at all. 1477 * 1478 * @ingroup window 1479 */ 1480 GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun); 1481 1482 /*! @brief Sets the focus callback for the specified window. 1483 * 1484 * This function sets the focus callback of the specified window, which is 1485 * called when the window gains or loses focus. 1486 * 1487 * After the focus callback is called for a window that lost focus, synthetic 1488 * key and mouse button release events will be generated for all such that had 1489 * been pressed. For more information, see @ref glfwSetKeyCallback and @ref 1490 * glfwSetMouseButtonCallback. 1491 * 1492 * @param[in] window The window whose callback to set. 1493 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1494 * callback. 1495 * @return The previously set callback, or `NULL` if no callback was set or an 1496 * error occurred. 1497 * 1498 * @ingroup window 1499 */ 1500 GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun); 1501 1502 /*! @brief Sets the iconify callback for the specified window. 1503 * 1504 * This function sets the iconification callback of the specified window, which 1505 * is called when the window is iconified or restored. 1506 * 1507 * @param[in] window The window whose callback to set. 1508 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1509 * callback. 1510 * @return The previously set callback, or `NULL` if no callback was set or an 1511 * error occurred. 1512 * 1513 * @ingroup window 1514 */ 1515 GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun); 1516 1517 /*! @brief Sets the framebuffer resize callback for the specified window. 1518 * 1519 * This function sets the framebuffer resize callback of the specified window, 1520 * which is called when the framebuffer of the specified window is resized. 1521 * 1522 * @param[in] window The window whose callback to set. 1523 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1524 * callback. 1525 * @return The previously set callback, or `NULL` if no callback was set or an 1526 * error occurred. 1527 * 1528 * @ingroup window 1529 */ 1530 GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun); 1531 1532 /*! @brief Processes all pending events. 1533 * 1534 * This function processes only those events that have already been received 1535 * and then returns immediately. Processing events will cause the window and 1536 * input callbacks associated with those events to be called. 1537 * 1538 * This function is not required for joystick input to work. 1539 * 1540 * @par New in GLFW 3 1541 * This function is no longer called by @ref glfwSwapBuffers. You need to call 1542 * it or @ref glfwWaitEvents yourself. 1543 * 1544 * @note This function may only be called from the main thread. 1545 * 1546 * @note This function may not be called from a callback. 1547 * 1548 * @note On some platforms, certain callbacks may be called outside of a call 1549 * to one of the event processing functions. 1550 * 1551 * @sa glfwWaitEvents 1552 * 1553 * @ingroup window 1554 */ 1555 void glfwPollEvents(); 1556 1557 /*! @brief Waits until events are pending and processes them. 1558 * 1559 * This function puts the calling thread to sleep until at least one event has 1560 * been received. Once one or more events have been received, it behaves as if 1561 * @ref glfwPollEvents was called, i.e. the events are processed and the 1562 * function then returns immediately. Processing events will cause the window 1563 * and input callbacks associated with those events to be called. 1564 * 1565 * Since not all events are associated with callbacks, this function may return 1566 * without a callback having been called even if you are monitoring all 1567 * callbacks. 1568 * 1569 * This function is not required for joystick input to work. 1570 * 1571 * @note This function may only be called from the main thread. 1572 * 1573 * @note This function may not be called from a callback. 1574 * 1575 * @note On some platforms, certain callbacks may be called outside of a call 1576 * to one of the event processing functions. 1577 * 1578 * @sa glfwPollEvents 1579 * 1580 * @ingroup window 1581 */ 1582 void glfwWaitEvents(); 1583 1584 /*! @brief Returns the value of an input option for the specified window. 1585 * 1586 * @param[in] window The window to query. 1587 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or 1588 * `GLFW_STICKY_MOUSE_BUTTONS`. 1589 * 1590 * @sa glfwSetInputMode 1591 * 1592 * @ingroup input 1593 */ 1594 int glfwGetInputMode(GLFWwindow* window, int mode); 1595 1596 /*! @brief Sets an input option for the specified window. 1597 * @param[in] window The window whose input mode to set. 1598 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or 1599 * `GLFW_STICKY_MOUSE_BUTTONS`. 1600 * @param[in] value The new value of the specified input mode. 1601 * 1602 * If `mode` is `GLFW_CURSOR`, the value must be one of the supported input 1603 * modes: 1604 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally. 1605 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client 1606 * area of the window. 1607 * - `GLFW_CURSOR_DISABLED` disables the cursor and removes any limitations on 1608 * cursor movement. 1609 * 1610 * If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to 1611 * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are 1612 * enabled, a key press will ensure that @ref glfwGetKey returns @ref 1613 * GLFW_PRESS the next time it is called even if the key had been released 1614 * before the call. This is useful when you are only interested in whether 1615 * keys have been pressed but not when or in which order. 1616 * 1617 * If `mode` is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either `GL_TRUE` 1618 * to enable sticky mouse buttons, or `GL_FALSE` to disable it. If sticky 1619 * mouse buttons are enabled, a mouse button press will ensure that @ref 1620 * glfwGetMouseButton returns @ref GLFW_PRESS the next time it is called even 1621 * if the mouse button had been released before the call. This is useful when 1622 * you are only interested in whether mouse buttons have been pressed but not 1623 * when or in which order. 1624 * 1625 * @sa glfwGetInputMode 1626 * 1627 * @ingroup input 1628 */ 1629 void glfwSetInputMode(GLFWwindow* window, int mode, int value); 1630 1631 /*! @brief Returns the last reported state of a keyboard key for the specified 1632 * window. 1633 * 1634 * This function returns the last state reported for the specified key to the 1635 * specified window. The returned state is one of `GLFW_PRESS` or 1636 * `GLFW_RELEASE`. The higher-level state `GLFW_REPEAT` is only reported to 1637 * the key callback. 1638 * 1639 * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns 1640 * `GLFW_PRESS` the first time you call this function after a key has been 1641 * pressed, even if the key has already been released. 1642 * 1643 * The key functions deal with physical keys, with [key tokens](@ref keys) 1644 * named after their use on the standard US keyboard layout. If you want to 1645 * input text, use the Unicode character callback instead. 1646 * 1647 * @param[in] window The desired window. 1648 * @param[in] key The desired [keyboard key](@ref keys). 1649 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. 1650 * 1651 * @note `GLFW_KEY_UNKNOWN` is not a valid key for this function. 1652 * 1653 * @ingroup input 1654 */ 1655 int glfwGetKey(GLFWwindow* window, int key); 1656 1657 /*! @brief Returns the last reported state of a mouse button for the specified 1658 * window. 1659 * 1660 * This function returns the last state reported for the specified mouse button 1661 * to the specified window. 1662 * 1663 * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function 1664 * returns `GLFW_PRESS` the first time you call this function after a mouse 1665 * button has been pressed, even if the mouse button has already been released. 1666 * 1667 * @param[in] window The desired window. 1668 * @param[in] button The desired [mouse button](@ref buttons). 1669 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. 1670 * 1671 * @ingroup input 1672 */ 1673 int glfwGetMouseButton(GLFWwindow* window, int button); 1674 1675 /*! @brief Retrieves the last reported cursor position, relative to the client 1676 * area of the window. 1677 * 1678 * This function returns the last reported position of the cursor to the 1679 * specified window. 1680 * 1681 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor 1682 * position is unbounded and limited only by the minimum and maximum values of 1683 * a `double`. 1684 * 1685 * The coordinate can be converted to their integer equivalents with the 1686 * `floor` function. Casting directly to an integer type works for positive 1687 * coordinates, but fails for negative ones. 1688 * 1689 * @param[in] window The desired window. 1690 * @param[out] xpos Where to store the cursor x-coordinate, relative to the 1691 * left edge of the client area, or `NULL`. 1692 * @param[out] ypos Where to store the cursor y-coordinate, relative to the to 1693 * top edge of the client area, or `NULL`. 1694 * 1695 * @sa glfwSetCursorPos 1696 * 1697 * @ingroup input 1698 */ 1699 void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); 1700 1701 /*! @brief Sets the position of the cursor, relative to the client area of the window. 1702 * 1703 * This function sets the position of the cursor. The specified window must be 1704 * focused. If the window does not have focus when this function is called, it 1705 * fails silently. 1706 * 1707 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor 1708 * position is unbounded and limited only by the minimum and maximum values of 1709 * a `double`. 1710 * 1711 * @param[in] window The desired window. 1712 * @param[in] xpos The desired x-coordinate, relative to the left edge of the 1713 * client area, or `NULL`. 1714 * @param[in] ypos The desired y-coordinate, relative to the top edge of the 1715 * client area, or `NULL`. 1716 * 1717 * @sa glfwGetCursorPos 1718 * 1719 * @ingroup input 1720 */ 1721 void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); 1722 1723 /*! @brief Sets the key callback. 1724 * 1725 * This function sets the key callback of the specific window, which is called 1726 * when a key is pressed, repeated or released. 1727 * 1728 * The key functions deal with physical keys, with layout independent 1729 * [key tokens](@ref keys) named after their values in the standard US keyboard 1730 * layout. If you want to input text, use the 1731 * [character callback](@ref glfwSetCharCallback) instead. 1732 * 1733 * When a window loses focus, it will generate synthetic key release events 1734 * for all pressed keys. You can tell these events from user-generated events 1735 * by the fact that the synthetic ones are generated after the window has lost 1736 * focus, i.e. `GLFW_FOCUSED` will be false and the focus callback will have 1737 * already been called. 1738 * 1739 * The scancode of a key is specific to that platform or sometimes even to that 1740 * machine. Scancodes are intended to allow users to bind keys that don't have 1741 * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their 1742 * state is not saved and so it cannot be retrieved with @ref glfwGetKey. 1743 * 1744 * Sometimes GLFW needs to generate synthetic key events, in which case the 1745 * scancode may be zero. 1746 * 1747 * @param[in] window The window whose callback to set. 1748 * @param[in] cbfun The new key callback, or `NULL` to remove the currently 1749 * set callback. 1750 * @return The previously set callback, or `NULL` if no callback was set or an 1751 * error occurred. 1752 * 1753 * @ingroup input 1754 */ 1755 GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); 1756 1757 /*! @brief Sets the Unicode character callback. 1758 * 1759 * This function sets the character callback of the specific window, which is 1760 * called when a Unicode character is input. 1761 * 1762 * The character callback is intended for text input. If you want to know 1763 * whether a specific key was pressed or released, use the 1764 * [key callback](@ref glfwSetKeyCallback) instead. 1765 * 1766 * @param[in] window The window whose callback to set. 1767 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1768 * callback. 1769 * @return The previously set callback, or `NULL` if no callback was set or an 1770 * error occurred. 1771 * 1772 * @ingroup input 1773 */ 1774 GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); 1775 1776 /*! @brief Sets the mouse button callback. 1777 * 1778 * This function sets the mouse button callback of the specified window, which 1779 * is called when a mouse button is pressed or released. 1780 * 1781 * When a window loses focus, it will generate synthetic mouse button release 1782 * events for all pressed mouse buttons. You can tell these events from 1783 * user-generated events by the fact that the synthetic ones are generated 1784 * after the window has lost focus, i.e. `GLFW_FOCUSED` will be false and the 1785 * focus callback will have already been called. 1786 * 1787 * @param[in] window The window whose callback to set. 1788 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1789 * callback. 1790 * @return The previously set callback, or `NULL` if no callback was set or an 1791 * error occurred. 1792 * 1793 * @ingroup input 1794 */ 1795 GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun); 1796 1797 /*! @brief Sets the cursor position callback. 1798 * 1799 * This function sets the cursor position callback of the specified window, 1800 * which is called when the cursor is moved. The callback is provided with the 1801 * position relative to the upper-left corner of the client area of the window. 1802 * 1803 * @param[in] window The window whose callback to set. 1804 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1805 * callback. 1806 * @return The previously set callback, or `NULL` if no callback was set or an 1807 * error occurred. 1808 * 1809 * @ingroup input 1810 */ 1811 GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun); 1812 1813 /*! @brief Sets the cursor enter/exit callback. 1814 * 1815 * This function sets the cursor boundary crossing callback of the specified 1816 * window, which is called when the cursor enters or leaves the client area of 1817 * the window. 1818 * 1819 * @param[in] window The window whose callback to set. 1820 * @param[in] cbfun The new callback, or `NULL` to remove the currently set 1821 * callback. 1822 * @return The previously set callback, or `NULL` if no callback was set or an 1823 * error occurred. 1824 * 1825 * @ingroup input 1826 */ 1827 GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun); 1828 1829 /*! @brief Sets the scroll callback. 1830 * 1831 * This function sets the scroll callback of the specified window, which is 1832 * called when a scrolling device is used, such as a mouse wheel or scrolling 1833 * area of a touchpad. 1834 * 1835 * The scroll callback receives all scrolling input, like that from a mouse 1836 * wheel or a touchpad scrolling area. 1837 * 1838 * @param[in] window The window whose callback to set. 1839 * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently 1840 * set callback. 1841 * @return The previously set callback, or `NULL` if no callback was set or an 1842 * error occurred. 1843 * 1844 * @ingroup input 1845 */ 1846 GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun); 1847 1848 /*! @brief Returns whether the specified joystick is present. 1849 * 1850 * This function returns whether the specified joystick is present. 1851 * 1852 * @param[in] joy The joystick to query. 1853 * @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise. 1854 * 1855 * @ingroup input 1856 */ 1857 int glfwJoystickPresent(int joy); 1858 1859 /*! @brief Returns the values of all axes of the specified joystick. 1860 * 1861 * This function returns the values of all axes of the specified joystick. 1862 * 1863 * @param[in] joy The joystick to query. 1864 * @param[out] count Where to store the size of the returned array. This is 1865 * set to zero if an error occurred. 1866 * @return An array of axis values, or `NULL` if the joystick is not present. 1867 * 1868 * @note The returned array is allocated and freed by GLFW. You should not 1869 * free it yourself. 1870 * 1871 * @note The returned array is valid only until the next call to @ref 1872 * glfwGetJoystickAxes for that joystick. 1873 * 1874 * @ingroup input 1875 */ 1876 const(float)* glfwGetJoystickAxes(int joy, int* count); 1877 1878 /*! @brief Returns the state of all buttons of the specified joystick. 1879 * 1880 * This function returns the state of all buttons of the specified joystick. 1881 * 1882 * @param[in] joy The joystick to query. 1883 * @param[out] count Where to store the size of the returned array. This is 1884 * set to zero if an error occurred. 1885 * @return An array of button states, or `NULL` if the joystick is not present. 1886 * 1887 * @note The returned array is allocated and freed by GLFW. You should not 1888 * free it yourself. 1889 * 1890 * @note The returned array is valid only until the next call to @ref 1891 * glfwGetJoystickButtons for that joystick. 1892 * 1893 * @ingroup input 1894 */ 1895 const(ubyte)* glfwGetJoystickButtons(int joy, int* count); 1896 1897 /*! @brief Returns the name of the specified joystick. 1898 * 1899 * This function returns the name, encoded as UTF-8, of the specified joystick. 1900 * 1901 * @param[in] joy The joystick to query. 1902 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick 1903 * is not present. 1904 * 1905 * @note The returned string is allocated and freed by GLFW. You should not 1906 * free it yourself. 1907 * 1908 * @note The returned string is valid only until the next call to @ref 1909 * glfwGetJoystickName for that joystick. 1910 * 1911 * @ingroup input 1912 */ 1913 const(char)* glfwGetJoystickName(int joy); 1914 1915 /*! @brief Sets the clipboard to the specified string. 1916 * 1917 * This function sets the system clipboard to the specified, UTF-8 encoded 1918 * string. The string is copied before returning, so you don't have to retain 1919 * it afterwards. 1920 * 1921 * @param[in] window The window that will own the clipboard contents. 1922 * @param[in] string A UTF-8 encoded string. 1923 * 1924 * @note This function may only be called from the main thread. 1925 * 1926 * @sa glfwGetClipboardString 1927 * 1928 * @ingroup clipboard 1929 */ 1930 void glfwSetClipboardString(GLFWwindow* window, const(char)* string); 1931 1932 /*! @brief Retrieves the contents of the clipboard as a string. 1933 * 1934 * This function returns the contents of the system clipboard, if it contains 1935 * or is convertible to a UTF-8 encoded string. 1936 * 1937 * @param[in] window The window that will request the clipboard contents. 1938 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL` 1939 * if an error occurred. 1940 * 1941 * @note This function may only be called from the main thread. 1942 * 1943 * @note The returned string is allocated and freed by GLFW. You should not 1944 * free it yourself. 1945 * 1946 * @note The returned string is valid only until the next call to @ref 1947 * glfwGetClipboardString or @ref glfwSetClipboardString. 1948 * 1949 * @sa glfwSetClipboardString 1950 * 1951 * @ingroup clipboard 1952 */ 1953 const(char)* glfwGetClipboardString(GLFWwindow* window); 1954 1955 /*! @brief Returns the value of the GLFW timer. 1956 * 1957 * This function returns the value of the GLFW timer. Unless the timer has 1958 * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW 1959 * was initialized. 1960 * 1961 * @return The current value, in seconds, or zero if an error occurred. 1962 * 1963 * @remarks This function may be called from secondary threads. 1964 * 1965 * @note The resolution of the timer is system dependent, but is usually on the 1966 * order of a few micro- or nanoseconds. It uses the highest-resolution 1967 * monotonic time source on each supported platform. 1968 * 1969 * @ingroup time 1970 */ 1971 double glfwGetTime(); 1972 1973 /*! @brief Sets the GLFW timer. 1974 * 1975 * This function sets the value of the GLFW timer. It then continues to count 1976 * up from that value. 1977 * 1978 * @param[in] time The new value, in seconds. 1979 * 1980 * @note The resolution of the timer is system dependent, but is usually on the 1981 * order of a few micro- or nanoseconds. It uses the highest-resolution 1982 * monotonic time source on each supported platform. 1983 * 1984 * @ingroup time 1985 */ 1986 void glfwSetTime(double time); 1987 1988 /*! @brief Makes the context of the specified window current for the calling 1989 * thread. 1990 * 1991 * This function makes the context of the specified window current on the 1992 * calling thread. A context can only be made current on a single thread at 1993 * a time and each thread can have only a single current context at a time. 1994 * 1995 * @param[in] window The window whose context to make current, or `NULL` to 1996 * detach the current context. 1997 * 1998 * @remarks This function may be called from secondary threads. 1999 * 2000 * @sa glfwGetCurrentContext 2001 * 2002 * @ingroup context 2003 */ 2004 void glfwMakeContextCurrent(GLFWwindow* window); 2005 2006 /*! @brief Returns the window whose context is current on the calling thread. 2007 * 2008 * This function returns the window whose context is current on the calling 2009 * thread. 2010 * 2011 * @return The window whose context is current, or `NULL` if no window's 2012 * context is current. 2013 * 2014 * @remarks This function may be called from secondary threads. 2015 * 2016 * @sa glfwMakeContextCurrent 2017 * 2018 * @ingroup context 2019 */ 2020 GLFWwindow* glfwGetCurrentContext(); 2021 2022 /*! @brief Swaps the front and back buffers of the specified window. 2023 * 2024 * This function swaps the front and back buffers of the specified window. If 2025 * the swap interval is greater than zero, the GPU driver waits the specified 2026 * number of screen updates before swapping the buffers. 2027 * 2028 * @param[in] window The window whose buffers to swap. 2029 * 2030 * @remarks This function may be called from secondary threads. 2031 * 2032 * @par New in GLFW 3 2033 * This function no longer calls @ref glfwPollEvents. You need to call it or 2034 * @ref glfwWaitEvents yourself. 2035 * 2036 * @sa glfwSwapInterval 2037 * 2038 * @ingroup context 2039 */ 2040 void glfwSwapBuffers(GLFWwindow* window); 2041 2042 /*! @brief Sets the swap interval for the current context. 2043 * 2044 * This function sets the swap interval for the current context, i.e. the 2045 * number of screen updates to wait before swapping the buffers of a window and 2046 * returning from @ref glfwSwapBuffers. This is sometimes called 'vertical 2047 * synchronization', 'vertical retrace synchronization' or 'vsync'. 2048 * 2049 * Contexts that support either of the `WGL_EXT_swap_control_tear` and 2050 * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals, 2051 * which allow the driver to swap even if a frame arrives a little bit late. 2052 * You can check for the presence of these extensions using @ref 2053 * glfwExtensionSupported. For more information about swap tearing, see the 2054 * extension specifications. 2055 * 2056 * @param[in] interval The minimum number of screen updates to wait for 2057 * until the buffers are swapped by @ref glfwSwapBuffers. 2058 * 2059 * @remarks This function may be called from secondary threads. 2060 * 2061 * @note Some GPU drivers do not honor the requested swap interval, either 2062 * because of user settings that override the request or due to bugs in the 2063 * driver. 2064 * 2065 * @sa glfwSwapBuffers 2066 * 2067 * @ingroup context 2068 */ 2069 void glfwSwapInterval(int interval); 2070 2071 /*! @brief Returns whether the specified extension is available. 2072 * 2073 * This function returns whether the specified 2074 * [OpenGL or context creation API extension](@ref context_glext) is supported 2075 * by the current context. For example, on Windows both the OpenGL and WGL 2076 * extension strings are checked. 2077 * 2078 * @param[in] extension The ASCII encoded name of the extension. 2079 * @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise. 2080 * 2081 * @remarks This function may be called from secondary threads. 2082 * 2083 * @note As this functions searches one or more extension strings on each call, 2084 * it is recommended that you cache its results if it's going to be used 2085 * frequently. The extension strings will not change during the lifetime of 2086 * a context, so there is no danger in doing this. 2087 * 2088 * @ingroup context 2089 */ 2090 int glfwExtensionSupported(const(char)* extension); 2091 2092 /*! @brief Returns the address of the specified function for the current 2093 * context. 2094 * 2095 * This function returns the address of the specified 2096 * [client API or extension function](@ref context_glext), if it is supported 2097 * by the current context. 2098 * 2099 * @param[in] procname The ASCII encoded name of the function. 2100 * @return The address of the function, or `NULL` if the function is 2101 * unavailable. 2102 * 2103 * @remarks This function may be called from secondary threads. 2104 * 2105 * @note The addresses of these functions are not guaranteed to be the same for 2106 * all contexts, especially if they use different client APIs or even different 2107 * context creation hints. 2108 * 2109 * @ingroup context 2110 */ 2111 GLFWglproc glfwGetProcAddress(const(char)* procname); 2112 2113 2114 /************************************************************************* 2115 * Global definition cleanup 2116 *************************************************************************/ 2117 2118 2119 2120 2121 } 2122 2123