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