Camilla Berglund | 2955cd3 | 2010-11-17 15:42:55 +0100 | [diff] [blame] | 1 | /************************************************************************* |
Camilla Berglund | 6e553c7 | 2011-03-06 01:46:39 +0100 | [diff] [blame] | 2 | * GLFW - An OpenGL library |
Camilla Berglund | 38b0ccb | 2010-09-07 17:41:26 +0200 | [diff] [blame] | 3 | * API version: 3.0 |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 4 | * WWW: http://www.glfw.org/ |
| 5 | *------------------------------------------------------------------------ |
| 6 | * Copyright (c) 2002-2006 Marcus Geelnard |
Camilla Berglund | f8105ed | 2010-11-09 02:57:46 +0100 | [diff] [blame] | 7 | * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org> |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 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 | |
Camilla Berglund | 36e5409 | 2010-11-09 02:58:35 +0100 | [diff] [blame] | 30 | #ifndef __glfw3_h__ |
| 31 | #define __glfw3_h__ |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 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 |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 47 | #define NULL ((void*) 0) |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 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 <GL/gl.h>) |
| 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 | * <GL/gl.h> files happy. Theoretically we could include <windows.h>, 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 <GL/glu.h> 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 <GL*glu.h> 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 */ |
Camilla Berglund | 2955cd3 | 2010-11-17 15:42:55 +0100 | [diff] [blame] | 130 | #define GLFWAPI __declspec(dllexport) |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 131 | |
| 132 | #elif defined(_WIN32) && defined(GLFW_DLL) |
| 133 | |
| 134 | /* We are calling a Win32 DLL */ |
| 135 | #if defined(__LCC__) |
Camilla Berglund | 2955cd3 | 2010-11-17 15:42:55 +0100 | [diff] [blame] | 136 | #define GLFWAPI extern |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 137 | #else |
Camilla Berglund | 2955cd3 | 2010-11-17 15:42:55 +0100 | [diff] [blame] | 138 | #define GLFWAPI __declspec(dllimport) |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 139 | #endif |
| 140 | |
| 141 | #else |
| 142 | |
| 143 | /* We are either building/calling a static lib or we are non-win32 */ |
| 144 | #define GLFWAPI |
| 145 | |
| 146 | #endif |
| 147 | |
| 148 | /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ |
| 149 | |
| 150 | /* Include standard OpenGL headers: GLFW uses GL_FALSE/GL_TRUE, and it is |
| 151 | * convenient for the user to only have to include <GL/glfw.h>. This also |
| 152 | * solves the problem with Windows <GL/gl.h> and <GL/glu.h> needing some |
| 153 | * special defines which normally requires the user to include <windows.h> |
| 154 | * (which is not a nice solution for portable programs). |
| 155 | */ |
| 156 | #if defined(__APPLE_CC__) |
Camilla Berglund | 3e6d00a | 2010-10-27 14:13:24 +0200 | [diff] [blame] | 157 | #define GL_GLEXT_LEGACY |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 158 | #include <OpenGL/gl.h> |
| 159 | #ifndef GLFW_NO_GLU |
| 160 | #include <OpenGL/glu.h> |
| 161 | #endif |
| 162 | #else |
| 163 | #include <GL/gl.h> |
| 164 | #ifndef GLFW_NO_GLU |
| 165 | #include <GL/glu.h> |
| 166 | #endif |
| 167 | #endif |
| 168 | |
| 169 | |
| 170 | /************************************************************************* |
| 171 | * GLFW version |
| 172 | *************************************************************************/ |
| 173 | |
Camilla Berglund | 38b0ccb | 2010-09-07 17:41:26 +0200 | [diff] [blame] | 174 | #define GLFW_VERSION_MAJOR 3 |
| 175 | #define GLFW_VERSION_MINOR 0 |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 176 | #define GLFW_VERSION_REVISION 0 |
| 177 | |
| 178 | |
| 179 | /************************************************************************* |
| 180 | * Input handling definitions |
| 181 | *************************************************************************/ |
| 182 | |
| 183 | /* Key and button state/action definitions */ |
| 184 | #define GLFW_RELEASE 0 |
| 185 | #define GLFW_PRESS 1 |
| 186 | |
Marcus | c0cb4c2 | 2011-01-02 11:18:14 +0100 | [diff] [blame] | 187 | /* Keyboard raw key codes. |
| 188 | * These key codes are inspired by the USB HID Usage Tables v1.12 (p. 53-60), |
| 189 | * but re-arranged to map to 7-bit ASCII for printable keys (function keys are |
| 190 | * put in the 256+ range). |
| 191 | * The naming of the key codes follow these rules: |
| 192 | * - The US keyboard layout is used. |
| 193 | * - Names of printable alpha-numeric characters are used (e.g. "A", "R", |
| 194 | * "3", etc). |
| 195 | * - For non-alphanumeric characters, Unicode:ish names are used (e.g. |
| 196 | * "COMMA", "LEFT_SQUARE_BRACKET", etc). Note that some names do not |
| 197 | * correspond to the Unicode standard (usually for brevity). |
| 198 | * - Keys that lack a clear US mapping are named "WORLD_x". |
| 199 | * - For non-printable keys, custom names are used (e.g. "F4", |
| 200 | * "BACKSPACE", etc). |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 201 | */ |
Marcus | c0cb4c2 | 2011-01-02 11:18:14 +0100 | [diff] [blame] | 202 | |
| 203 | /* Printable keys */ |
| 204 | #define GLFW_KEY_SPACE 32 |
| 205 | #define GLFW_KEY_APOSTROPHE 39 /* ' */ |
| 206 | #define GLFW_KEY_COMMA 44 /* , */ |
| 207 | #define GLFW_KEY_MINUS 45 /* - */ |
| 208 | #define GLFW_KEY_PERIOD 46 /* . */ |
| 209 | #define GLFW_KEY_SLASH 47 /* / */ |
| 210 | #define GLFW_KEY_0 48 |
| 211 | #define GLFW_KEY_1 49 |
| 212 | #define GLFW_KEY_2 50 |
| 213 | #define GLFW_KEY_3 51 |
| 214 | #define GLFW_KEY_4 52 |
| 215 | #define GLFW_KEY_5 53 |
| 216 | #define GLFW_KEY_6 54 |
| 217 | #define GLFW_KEY_7 55 |
| 218 | #define GLFW_KEY_8 56 |
| 219 | #define GLFW_KEY_9 57 |
| 220 | #define GLFW_KEY_SEMICOLON 59 /* ; */ |
| 221 | #define GLFW_KEY_EQUAL 61 /* = */ |
| 222 | #define GLFW_KEY_A 65 |
| 223 | #define GLFW_KEY_B 66 |
| 224 | #define GLFW_KEY_C 67 |
| 225 | #define GLFW_KEY_D 68 |
| 226 | #define GLFW_KEY_E 69 |
| 227 | #define GLFW_KEY_F 70 |
| 228 | #define GLFW_KEY_G 71 |
| 229 | #define GLFW_KEY_H 72 |
| 230 | #define GLFW_KEY_I 73 |
| 231 | #define GLFW_KEY_J 74 |
| 232 | #define GLFW_KEY_K 75 |
| 233 | #define GLFW_KEY_L 76 |
| 234 | #define GLFW_KEY_M 77 |
| 235 | #define GLFW_KEY_N 78 |
| 236 | #define GLFW_KEY_O 79 |
| 237 | #define GLFW_KEY_P 80 |
| 238 | #define GLFW_KEY_Q 81 |
| 239 | #define GLFW_KEY_R 82 |
| 240 | #define GLFW_KEY_S 83 |
| 241 | #define GLFW_KEY_T 84 |
| 242 | #define GLFW_KEY_U 85 |
| 243 | #define GLFW_KEY_V 86 |
| 244 | #define GLFW_KEY_W 87 |
| 245 | #define GLFW_KEY_X 88 |
| 246 | #define GLFW_KEY_Y 89 |
| 247 | #define GLFW_KEY_Z 90 |
Marcus | 3b00847 | 2011-01-03 22:07:01 +0100 | [diff] [blame] | 248 | #define GLFW_KEY_LEFT_BRACKET 91 /* [ */ |
Marcus | c0cb4c2 | 2011-01-02 11:18:14 +0100 | [diff] [blame] | 249 | #define GLFW_KEY_BACKSLASH 92 /* \ */ |
Marcus | 3b00847 | 2011-01-03 22:07:01 +0100 | [diff] [blame] | 250 | #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */ |
Marcus | c0cb4c2 | 2011-01-02 11:18:14 +0100 | [diff] [blame] | 251 | #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */ |
| 252 | #define GLFW_KEY_WORLD_1 161 /* non-US #1 */ |
| 253 | #define GLFW_KEY_WORLD_2 162 /* non-US #2 */ |
| 254 | |
| 255 | /* Function keys */ |
| 256 | #define GLFW_KEY_ESCAPE 256 |
| 257 | #define GLFW_KEY_ENTER 257 |
| 258 | #define GLFW_KEY_TAB 258 |
| 259 | #define GLFW_KEY_BACKSPACE 259 |
| 260 | #define GLFW_KEY_INSERT 260 |
| 261 | #define GLFW_KEY_DELETE 261 |
| 262 | #define GLFW_KEY_RIGHT 262 |
| 263 | #define GLFW_KEY_LEFT 263 |
| 264 | #define GLFW_KEY_DOWN 264 |
| 265 | #define GLFW_KEY_UP 265 |
| 266 | #define GLFW_KEY_PAGE_UP 266 |
| 267 | #define GLFW_KEY_PAGE_DOWN 267 |
| 268 | #define GLFW_KEY_HOME 268 |
| 269 | #define GLFW_KEY_END 269 |
| 270 | #define GLFW_KEY_CAPS_LOCK 280 |
| 271 | #define GLFW_KEY_SCROLL_LOCK 281 |
| 272 | #define GLFW_KEY_NUM_LOCK 282 |
| 273 | #define GLFW_KEY_PRINT_SCREEN 283 |
| 274 | #define GLFW_KEY_PAUSE 284 |
| 275 | #define GLFW_KEY_F1 290 |
| 276 | #define GLFW_KEY_F2 291 |
| 277 | #define GLFW_KEY_F3 292 |
| 278 | #define GLFW_KEY_F4 293 |
| 279 | #define GLFW_KEY_F5 294 |
| 280 | #define GLFW_KEY_F6 295 |
| 281 | #define GLFW_KEY_F7 296 |
| 282 | #define GLFW_KEY_F8 297 |
| 283 | #define GLFW_KEY_F9 298 |
| 284 | #define GLFW_KEY_F10 299 |
| 285 | #define GLFW_KEY_F11 300 |
| 286 | #define GLFW_KEY_F12 301 |
| 287 | #define GLFW_KEY_F13 302 |
| 288 | #define GLFW_KEY_F14 303 |
| 289 | #define GLFW_KEY_F15 304 |
| 290 | #define GLFW_KEY_F16 305 |
| 291 | #define GLFW_KEY_F17 306 |
| 292 | #define GLFW_KEY_F18 307 |
| 293 | #define GLFW_KEY_F19 308 |
| 294 | #define GLFW_KEY_F20 309 |
| 295 | #define GLFW_KEY_F21 310 |
| 296 | #define GLFW_KEY_F22 311 |
| 297 | #define GLFW_KEY_F23 312 |
| 298 | #define GLFW_KEY_F24 313 |
| 299 | #define GLFW_KEY_F25 314 |
| 300 | #define GLFW_KEY_KP_0 320 |
| 301 | #define GLFW_KEY_KP_1 321 |
| 302 | #define GLFW_KEY_KP_2 322 |
| 303 | #define GLFW_KEY_KP_3 323 |
| 304 | #define GLFW_KEY_KP_4 324 |
| 305 | #define GLFW_KEY_KP_5 325 |
| 306 | #define GLFW_KEY_KP_6 326 |
| 307 | #define GLFW_KEY_KP_7 327 |
| 308 | #define GLFW_KEY_KP_8 328 |
| 309 | #define GLFW_KEY_KP_9 329 |
| 310 | #define GLFW_KEY_KP_DECIMAL 330 |
| 311 | #define GLFW_KEY_KP_DIVIDE 331 |
| 312 | #define GLFW_KEY_KP_MULTIPLY 332 |
| 313 | #define GLFW_KEY_KP_SUBTRACT 333 |
| 314 | #define GLFW_KEY_KP_ADD 334 |
| 315 | #define GLFW_KEY_KP_ENTER 335 |
| 316 | #define GLFW_KEY_KP_EQUAL 336 |
| 317 | #define GLFW_KEY_LEFT_SHIFT 340 |
| 318 | #define GLFW_KEY_LEFT_CONTROL 341 |
| 319 | #define GLFW_KEY_LEFT_ALT 342 |
| 320 | #define GLFW_KEY_LEFT_SUPER 343 |
| 321 | #define GLFW_KEY_RIGHT_SHIFT 344 |
| 322 | #define GLFW_KEY_RIGHT_CONTROL 345 |
| 323 | #define GLFW_KEY_RIGHT_ALT 346 |
| 324 | #define GLFW_KEY_RIGHT_SUPER 347 |
| 325 | #define GLFW_KEY_MENU 348 |
| 326 | #define GLFW_KEY_LAST GLFW_KEY_MENU |
| 327 | |
| 328 | /* GLFW 2.x key name aliases (deprecated) */ |
| 329 | #define GLFW_KEY_ESC GLFW_KEY_ESCAPE |
| 330 | #define GLFW_KEY_DEL GLFW_KEY_DELETE |
| 331 | #define GLFW_KEY_PAGEUP GLFW_KEY_PAGE_UP |
| 332 | #define GLFW_KEY_PAGEDOWN GLFW_KEY_PAGE_DOWN |
| 333 | #define GLFW_KEY_KP_NUM_LOCK GLFW_KEY_NUM_LOCK |
| 334 | #define GLFW_KEY_LCTRL GLFW_KEY_LEFT_CONTROL |
| 335 | #define GLFW_KEY_LSHIFT GLFW_KEY_LEFT_SHIFT |
| 336 | #define GLFW_KEY_LALT GLFW_KEY_LEFT_ALT |
| 337 | #define GLFW_KEY_LSUPER GLFW_KEY_LEFT_SUPER |
| 338 | #define GLFW_KEY_RCTRL GLFW_KEY_RIGHT_CONTROL |
| 339 | #define GLFW_KEY_RSHIFT GLFW_KEY_RIGHT_SHIFT |
| 340 | #define GLFW_KEY_RALT GLFW_KEY_RIGHT_ALT |
| 341 | #define GLFW_KEY_RSUPER GLFW_KEY_RIGHT_SUPER |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 342 | |
| 343 | /* Mouse button definitions */ |
| 344 | #define GLFW_MOUSE_BUTTON_1 0 |
| 345 | #define GLFW_MOUSE_BUTTON_2 1 |
| 346 | #define GLFW_MOUSE_BUTTON_3 2 |
| 347 | #define GLFW_MOUSE_BUTTON_4 3 |
| 348 | #define GLFW_MOUSE_BUTTON_5 4 |
| 349 | #define GLFW_MOUSE_BUTTON_6 5 |
| 350 | #define GLFW_MOUSE_BUTTON_7 6 |
| 351 | #define GLFW_MOUSE_BUTTON_8 7 |
| 352 | #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8 |
| 353 | |
| 354 | /* Mouse button aliases */ |
| 355 | #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1 |
| 356 | #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2 |
| 357 | #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3 |
| 358 | |
| 359 | /* Joystick identifiers */ |
| 360 | #define GLFW_JOYSTICK_1 0 |
| 361 | #define GLFW_JOYSTICK_2 1 |
| 362 | #define GLFW_JOYSTICK_3 2 |
| 363 | #define GLFW_JOYSTICK_4 3 |
| 364 | #define GLFW_JOYSTICK_5 4 |
| 365 | #define GLFW_JOYSTICK_6 5 |
| 366 | #define GLFW_JOYSTICK_7 6 |
| 367 | #define GLFW_JOYSTICK_8 7 |
| 368 | #define GLFW_JOYSTICK_9 8 |
| 369 | #define GLFW_JOYSTICK_10 9 |
| 370 | #define GLFW_JOYSTICK_11 10 |
| 371 | #define GLFW_JOYSTICK_12 11 |
| 372 | #define GLFW_JOYSTICK_13 12 |
| 373 | #define GLFW_JOYSTICK_14 13 |
| 374 | #define GLFW_JOYSTICK_15 14 |
| 375 | #define GLFW_JOYSTICK_16 15 |
| 376 | #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16 |
| 377 | |
| 378 | |
| 379 | /************************************************************************* |
| 380 | * Other definitions |
| 381 | *************************************************************************/ |
| 382 | |
| 383 | /* glfwOpenWindow modes */ |
Camilla Berglund | 484a271 | 2010-09-10 13:24:19 +0200 | [diff] [blame] | 384 | #define GLFW_WINDOWED 0x00010001 |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 385 | #define GLFW_FULLSCREEN 0x00010002 |
| 386 | |
| 387 | /* glfwGetWindowParam tokens */ |
Camilla Berglund | 39dfa7d | 2010-11-15 21:39:46 +0100 | [diff] [blame] | 388 | #define GLFW_ACTIVE 0x00020001 |
| 389 | #define GLFW_ICONIFIED 0x00020002 |
| 390 | #define GLFW_ACCELERATED 0x00020003 |
Camilla Berglund | 950a3be | 2010-09-09 19:58:51 +0200 | [diff] [blame] | 391 | |
| 392 | /* The following constants are used for both glfwGetWindowParam |
| 393 | * and glfwOpenWindowHint |
| 394 | */ |
Camilla Berglund | 39dfa7d | 2010-11-15 21:39:46 +0100 | [diff] [blame] | 395 | #define GLFW_RED_BITS 0x00020004 |
| 396 | #define GLFW_GREEN_BITS 0x00020005 |
| 397 | #define GLFW_BLUE_BITS 0x00020006 |
| 398 | #define GLFW_ALPHA_BITS 0x00020007 |
| 399 | #define GLFW_DEPTH_BITS 0x00020008 |
| 400 | #define GLFW_STENCIL_BITS 0x00020009 |
| 401 | #define GLFW_REFRESH_RATE 0x0002000A |
| 402 | #define GLFW_ACCUM_RED_BITS 0x0002000B |
| 403 | #define GLFW_ACCUM_GREEN_BITS 0x0002000C |
| 404 | #define GLFW_ACCUM_BLUE_BITS 0x0002000D |
| 405 | #define GLFW_ACCUM_ALPHA_BITS 0x0002000E |
| 406 | #define GLFW_AUX_BUFFERS 0x0002000F |
| 407 | #define GLFW_STEREO 0x00020010 |
| 408 | #define GLFW_WINDOW_NO_RESIZE 0x00020011 |
| 409 | #define GLFW_FSAA_SAMPLES 0x00020012 |
Camilla Berglund | 77e3b42 | 2011-01-02 00:11:47 +0100 | [diff] [blame] | 410 | #define GLFW_OPENGL_VERSION_MAJOR 0x00020013 |
| 411 | #define GLFW_OPENGL_VERSION_MINOR 0x00020014 |
| 412 | #define GLFW_OPENGL_FORWARD_COMPAT 0x00020015 |
| 413 | #define GLFW_OPENGL_DEBUG_CONTEXT 0x00020016 |
| 414 | #define GLFW_OPENGL_PROFILE 0x00020017 |
Camilla Berglund | d43e0b5 | 2011-03-07 20:51:34 +0100 | [diff] [blame^] | 415 | #define GLFW_OPENGL_ROBUSTNESS 0x00020018 |
| 416 | |
| 417 | /* GLFW_OPENGL_ROBUSTNESS mode tokens */ |
| 418 | #define GLFW_OPENGL_NO_ROBUSTNESS 0x00000000 |
| 419 | #define GLFW_OPENGL_NO_RESET_NOTIFICATION 0x00000001 |
| 420 | #define GLFW_OPENGL_LOSE_CONTEXT_ON_RESET 0x00000002 |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 421 | |
Camilla Berglund | 20662dd | 2010-11-15 21:40:43 +0100 | [diff] [blame] | 422 | /* GLFW_OPENGL_PROFILE bit tokens */ |
| 423 | #define GLFW_OPENGL_CORE_PROFILE 0x00000001 |
| 424 | #define GLFW_OPENGL_COMPAT_PROFILE 0x00000002 |
| 425 | #define GLFW_OPENGL_ES2_PROFILE 0x00000004 |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 426 | |
| 427 | /* glfwEnable/glfwDisable tokens */ |
| 428 | #define GLFW_MOUSE_CURSOR 0x00030001 |
| 429 | #define GLFW_STICKY_KEYS 0x00030002 |
| 430 | #define GLFW_STICKY_MOUSE_BUTTONS 0x00030003 |
| 431 | #define GLFW_SYSTEM_KEYS 0x00030004 |
| 432 | #define GLFW_KEY_REPEAT 0x00030005 |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 433 | |
| 434 | /* glfwGetJoystickParam tokens */ |
| 435 | #define GLFW_PRESENT 0x00050001 |
| 436 | #define GLFW_AXES 0x00050002 |
| 437 | #define GLFW_BUTTONS 0x00050003 |
| 438 | |
Camilla Berglund | e28543c | 2010-09-09 21:08:50 +0200 | [diff] [blame] | 439 | /* glfwGetError/glfwErrorString tokens */ |
| 440 | #define GLFW_NO_ERROR 0 |
| 441 | #define GLFW_NOT_INITIALIZED 0x00070001 |
Camilla Berglund | 5254617 | 2010-10-05 00:08:19 +0200 | [diff] [blame] | 442 | #define GLFW_NO_CURRENT_WINDOW 0x00070002 |
| 443 | #define GLFW_INVALID_ENUM 0x00070003 |
| 444 | #define GLFW_INVALID_VALUE 0x00070004 |
| 445 | #define GLFW_OUT_OF_MEMORY 0x00070005 |
| 446 | #define GLFW_OPENGL_UNAVAILABLE 0x00070006 |
| 447 | #define GLFW_VERSION_UNAVAILABLE 0x00070007 |
| 448 | #define GLFW_PLATFORM_ERROR 0x00070008 |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 449 | |
Camilla Berglund | 2630d49 | 2010-10-13 04:04:43 +0200 | [diff] [blame] | 450 | /* Gamma ramps */ |
| 451 | #define GLFW_GAMMA_RAMP_SIZE 256 |
Camilla Berglund | 2c09157 | 2010-09-09 21:09:11 +0200 | [diff] [blame] | 452 | |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 453 | /************************************************************************* |
| 454 | * Typedefs |
| 455 | *************************************************************************/ |
| 456 | |
Camilla Berglund | 8d8eb0c | 2010-09-16 06:05:50 +0200 | [diff] [blame] | 457 | /* Window handle type */ |
Camilla Berglund | a66a4cd | 2011-02-09 12:37:42 +0100 | [diff] [blame] | 458 | typedef void* GLFWwindow; |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 459 | |
Camilla Berglund | 897558f | 2011-03-07 13:34:58 +0100 | [diff] [blame] | 460 | /* Function pointer types */ |
| 461 | typedef void (* GLFWerrorfun)(int,const char*); |
| 462 | typedef void (* GLFWwindowsizefun)(GLFWwindow,int,int); |
| 463 | typedef int (* GLFWwindowclosefun)(GLFWwindow); |
| 464 | typedef void (* GLFWwindowrefreshfun)(GLFWwindow); |
| 465 | typedef void (* GLFWwindowfocusfun)(GLFWwindow,int); |
| 466 | typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int); |
| 467 | typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int); |
| 468 | typedef void (* GLFWmouseposfun)(GLFWwindow,int,int); |
| 469 | typedef void (* GLFWscrollfun)(GLFWwindow,int,int); |
| 470 | typedef void (* GLFWkeyfun)(GLFWwindow,int,int); |
| 471 | typedef void (* GLFWcharfun)(GLFWwindow,int); |
Camilla Berglund | ccbb956 | 2011-03-07 14:09:13 +0100 | [diff] [blame] | 472 | typedef void* (* GLFWmallocfun)(size_t); |
| 473 | typedef void (* GLFWfreefun)(void*); |
Camilla Berglund | 897558f | 2011-03-07 13:34:58 +0100 | [diff] [blame] | 474 | |
Camilla Berglund | 8d8eb0c | 2010-09-16 06:05:50 +0200 | [diff] [blame] | 475 | /* The video mode structure used by glfwGetVideoModes */ |
Camilla Berglund | 5fd3fc7 | 2010-09-09 19:44:43 +0200 | [diff] [blame] | 476 | typedef struct |
| 477 | { |
| 478 | int width; |
| 479 | int height; |
| 480 | int redBits; |
| 481 | int blueBits; |
| 482 | int greenBits; |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 483 | } GLFWvidmode; |
| 484 | |
Camilla Berglund | 2630d49 | 2010-10-13 04:04:43 +0200 | [diff] [blame] | 485 | /* Gamma ramp */ |
| 486 | typedef struct |
| 487 | { |
| 488 | unsigned short red[GLFW_GAMMA_RAMP_SIZE]; |
| 489 | unsigned short green[GLFW_GAMMA_RAMP_SIZE]; |
| 490 | unsigned short blue[GLFW_GAMMA_RAMP_SIZE]; |
| 491 | } GLFWgammaramp; |
| 492 | |
Camilla Berglund | ccbb956 | 2011-03-07 14:09:13 +0100 | [diff] [blame] | 493 | /* Custom memory allocator interface */ |
| 494 | typedef struct |
| 495 | { |
| 496 | GLFWmallocfun malloc; |
| 497 | GLFWfreefun free; |
| 498 | } GLFWallocator; |
| 499 | |
| 500 | /* Custom threading model interface */ |
| 501 | typedef struct |
| 502 | { |
| 503 | } GLFWthreadmodel; |
| 504 | |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 505 | |
| 506 | /************************************************************************* |
| 507 | * Prototypes |
| 508 | *************************************************************************/ |
| 509 | |
Camilla Berglund | 16cf53b | 2010-09-20 00:38:06 +0200 | [diff] [blame] | 510 | /* Initialization, termination and version querying */ |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 511 | GLFWAPI int glfwInit(void); |
Camilla Berglund | ccbb956 | 2011-03-07 14:09:13 +0100 | [diff] [blame] | 512 | GLFWAPI int glfwInitWithModels(GLFWthreadmodel* threading, GLFWallocator* allocator); |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 513 | GLFWAPI void glfwTerminate(void); |
| 514 | GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); |
Camilla Berglund | d6fe447 | 2010-09-13 18:05:59 +0200 | [diff] [blame] | 515 | GLFWAPI const char* glfwGetVersionString(void); |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 516 | |
Camilla Berglund | f5d74c4 | 2010-09-09 21:06:59 +0200 | [diff] [blame] | 517 | /* Error handling */ |
| 518 | GLFWAPI int glfwGetError(void); |
| 519 | GLFWAPI const char* glfwErrorString(int error); |
Camilla Berglund | f1e7d7c | 2010-11-23 17:45:23 +0100 | [diff] [blame] | 520 | GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun); |
Camilla Berglund | f5d74c4 | 2010-09-09 21:06:59 +0200 | [diff] [blame] | 521 | |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 522 | /* Video mode functions */ |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 523 | GLFWAPI int glfwGetVideoModes(GLFWvidmode* list, int maxcount); |
| 524 | GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode); |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 525 | |
Camilla Berglund | 2630d49 | 2010-10-13 04:04:43 +0200 | [diff] [blame] | 526 | /* Gamma ramp functions */ |
| 527 | GLFWAPI void glfwSetGammaFormula(float gamma, float blacklevel, float gain); |
| 528 | GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp); |
| 529 | GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp); |
| 530 | |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 531 | /* Window handling */ |
Camilla Berglund | 99ddce3 | 2010-10-04 18:17:53 +0200 | [diff] [blame] | 532 | GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share); |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 533 | GLFWAPI void glfwOpenWindowHint(int target, int hint); |
| 534 | GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window); |
Camilla Berglund | 29a0ca4 | 2010-09-09 18:42:41 +0200 | [diff] [blame] | 535 | GLFWAPI int glfwIsWindow(GLFWwindow window); |
Camilla Berglund | 419f9f1 | 2010-10-04 23:13:33 +0200 | [diff] [blame] | 536 | GLFWAPI GLFWwindow glfwGetCurrentWindow(void); |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 537 | GLFWAPI void glfwCloseWindow(GLFWwindow window); |
| 538 | GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title); |
| 539 | GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height); |
| 540 | GLFWAPI void glfwSetWindowSize(GLFWwindow, int width, int height); |
Camilla Berglund | e0ba9e4 | 2011-02-09 12:57:11 +0100 | [diff] [blame] | 541 | GLFWAPI void glfwGetWindowPos(GLFWwindow, int* xpos, int* ypos); |
| 542 | GLFWAPI void glfwSetWindowPos(GLFWwindow, int xpos, int ypos); |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 543 | GLFWAPI void glfwIconifyWindow(GLFWwindow window); |
| 544 | GLFWAPI void glfwRestoreWindow(GLFWwindow window); |
| 545 | GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param); |
Camilla Berglund | 48f5a7e | 2010-09-09 22:44:38 +0200 | [diff] [blame] | 546 | GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer); |
| 547 | GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window); |
Camilla Berglund | 4044c2d | 2010-10-24 18:28:55 +0200 | [diff] [blame] | 548 | GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun); |
| 549 | GLFWAPI void glfwSetWindowCloseCallback(GLFWwindowclosefun cbfun); |
| 550 | GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindowrefreshfun cbfun); |
| 551 | GLFWAPI void glfwSetWindowFocusCallback(GLFWwindowfocusfun cbfun); |
| 552 | GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindowiconifyfun cbfun); |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 553 | |
| 554 | /* Event handling */ |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 555 | GLFWAPI void glfwPollEvents(void); |
| 556 | GLFWAPI void glfwWaitEvents(void); |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 557 | |
| 558 | /* Input handling */ |
| 559 | GLFWAPI int glfwGetKey(GLFWwindow window, int key); |
| 560 | GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button); |
| 561 | GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos); |
| 562 | GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos); |
Camilla Berglund | e0ba9e4 | 2011-02-09 12:57:11 +0100 | [diff] [blame] | 563 | GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* xoffset, int* yoffset); |
Camilla Berglund | 4044c2d | 2010-10-24 18:28:55 +0200 | [diff] [blame] | 564 | GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun); |
| 565 | GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun); |
| 566 | GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun); |
| 567 | GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun); |
| 568 | GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun); |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 569 | |
| 570 | /* Joystick input */ |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 571 | GLFWAPI int glfwGetJoystickParam(int joy, int param); |
| 572 | GLFWAPI int glfwGetJoystickPos(int joy, float* pos, int numaxes); |
| 573 | GLFWAPI int glfwGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons); |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 574 | |
| 575 | /* Time */ |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 576 | GLFWAPI double glfwGetTime(void); |
| 577 | GLFWAPI void glfwSetTime(double time); |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 578 | |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 579 | /* OpenGL support */ |
| 580 | GLFWAPI void glfwSwapBuffers(void); |
| 581 | GLFWAPI void glfwSwapInterval(int interval); |
Camilla Berglund | 9a71669 | 2010-09-08 16:40:43 +0200 | [diff] [blame] | 582 | GLFWAPI int glfwExtensionSupported(const char* extension); |
| 583 | GLFWAPI void* glfwGetProcAddress(const char* procname); |
| 584 | GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev); |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 585 | |
| 586 | /* Enable/disable functions */ |
Camilla Berglund | 135194a | 2010-09-09 18:15:32 +0200 | [diff] [blame] | 587 | GLFWAPI void glfwEnable(GLFWwindow window, int token); |
| 588 | GLFWAPI void glfwDisable(GLFWwindow window, int token); |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 589 | |
| 590 | |
| 591 | #ifdef __cplusplus |
| 592 | } |
| 593 | #endif |
| 594 | |
Camilla Berglund | 36e5409 | 2010-11-09 02:58:35 +0100 | [diff] [blame] | 595 | #endif /* __glfw3_h__ */ |
Camilla Berglund | 3249f81 | 2010-09-07 17:34:51 +0200 | [diff] [blame] | 596 | |