blob: f20fd1c74e51d2d707f44f84003472e1476c680b [file] [log] [blame]
Camilla Berglund2955cd32010-11-17 15:42:55 +01001/*************************************************************************
Camilla Berglund6e553c72011-03-06 01:46:39 +01002 * GLFW - An OpenGL library
Camilla Berglund38b0ccb2010-09-07 17:41:26 +02003 * API version: 3.0
Camilla Berglund3249f812010-09-07 17:34:51 +02004 * WWW: http://www.glfw.org/
5 *------------------------------------------------------------------------
6 * Copyright (c) 2002-2006 Marcus Geelnard
Camilla Berglundf8105ed2010-11-09 02:57:46 +01007 * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
Camilla Berglund3249f812010-09-07 17:34:51 +02008 *
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 Berglund36e54092010-11-09 02:58:35 +010030#ifndef __glfw3_h__
31#define __glfw3_h__
Camilla Berglund3249f812010-09-07 17:34:51 +020032
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37
38/*************************************************************************
Camilla Berglundbce2cd62012-11-22 16:38:24 +010039 * Doxygen documentation
40 *************************************************************************/
41
42/*! @mainpage notitle
43 *
44 * @section intro Introduction
45 *
46 * This is the reference documentation for the GLFW library.
47 */
48
49/*! @defgroup clipboard Clipboard support
50 */
51/*! @defgroup error Error handling
52 */
53/*! @defgroup gamma Gamma ramp support
54 */
55/*! @defgroup init Initialization and version information
56 */
57/*! @defgroup input Input handling
58 */
59/*! @defgroup opengl OpenGL support
60 */
61/*! @defgroup time Time input
62 */
63/*! @defgroup window Window handling
64 *
65 * The primary purpose of GLFW is to provide a simple interface to OpenGL
66 * context creation and window management. GLFW supports multiple windows,
67 * which can be either a normal desktop window or a fullscreen window.
68 */
69/*! @defgroup monitor Monitor handling
70 */
71
72
73/*************************************************************************
Camilla Berglund3249f812010-09-07 17:34:51 +020074 * Global definitions
75 *************************************************************************/
76
Camilla Berglund3249f812010-09-07 17:34:51 +020077/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
78
Camilla Berglund06e7a962012-11-22 19:14:27 +010079/* Please report any problems that you find with your compiler, which may
Camilla Berglund3249f812010-09-07 17:34:51 +020080 * be solved in this section! There are several compilers that I have not
81 * been able to test this file with yet.
82 *
83 * First: If we are we on Windows, we want a single define for it (_WIN32)
84 * (Note: For Cygwin the compiler flag -mwin32 should be used, but to
85 * make sure that things run smoothly for Cygwin users, we add __CYGWIN__
86 * to the list of "valid Win32 identifiers", which removes the need for
87 * -mwin32)
88 */
89#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
90 #define _WIN32
91#endif /* _WIN32 */
92
93/* In order for extension support to be portable, we need to define an
94 * OpenGL function call method. We use the keyword APIENTRY, which is
95 * defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
96 */
97#ifndef APIENTRY
98 #ifdef _WIN32
99 #define APIENTRY __stdcall
100 #else
101 #define APIENTRY
102 #endif
Camilla Berglund3249f812010-09-07 17:34:51 +0200103#endif /* APIENTRY */
104
Camilla Berglund3249f812010-09-07 17:34:51 +0200105/* The following three defines are here solely to make some Windows-based
106 * <GL/gl.h> files happy. Theoretically we could include <windows.h>, but
107 * it has the major drawback of severely polluting our namespace.
108 */
109
110/* Under Windows, we need WINGDIAPI defined */
111#if !defined(WINGDIAPI) && defined(_WIN32)
112 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
113 /* Microsoft Visual C++, Borland C++ Builder and Pelles C */
114 #define WINGDIAPI __declspec(dllimport)
115 #elif defined(__LCC__)
116 /* LCC-Win32 */
117 #define WINGDIAPI __stdcall
118 #else
119 /* Others (e.g. MinGW, Cygwin) */
120 #define WINGDIAPI extern
121 #endif
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200122 #define GLFW_WINGDIAPI_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200123#endif /* WINGDIAPI */
124
125/* Some <GL/glu.h> files also need CALLBACK defined */
126#if !defined(CALLBACK) && defined(_WIN32)
127 #if defined(_MSC_VER)
128 /* Microsoft Visual C++ */
129 #if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
130 #define CALLBACK __stdcall
131 #else
132 #define CALLBACK
133 #endif
134 #else
135 /* Other Windows compilers */
136 #define CALLBACK __stdcall
137 #endif
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200138 #define GLFW_CALLBACK_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200139#endif /* CALLBACK */
140
Camilla Berglund3c912cb2012-08-02 21:25:00 +0200141/* Most <GL/glu.h> variants on Windows need wchar_t */
142#if defined(_WIN32)
143 #include <stddef.h>
144#endif
Camilla Berglund3249f812010-09-07 17:34:51 +0200145
146
147/* ---------------- GLFW related system specific defines ----------------- */
148
Camilla Berglundcc5d7cd2012-03-25 17:43:02 +0200149#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
150 #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
151#endif
152
Camilla Berglund2588c9b2012-03-25 17:40:30 +0200153#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
Camilla Berglund3249f812010-09-07 17:34:51 +0200154
155 /* We are building a Win32 DLL */
Camilla Berglund2955cd32010-11-17 15:42:55 +0100156 #define GLFWAPI __declspec(dllexport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200157
158#elif defined(_WIN32) && defined(GLFW_DLL)
159
160 /* We are calling a Win32 DLL */
161 #if defined(__LCC__)
Camilla Berglund2955cd32010-11-17 15:42:55 +0100162 #define GLFWAPI extern
Camilla Berglund3249f812010-09-07 17:34:51 +0200163 #else
Camilla Berglund2955cd32010-11-17 15:42:55 +0100164 #define GLFWAPI __declspec(dllimport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200165 #endif
166
167#else
168
169 /* We are either building/calling a static lib or we are non-win32 */
170 #define GLFWAPI
171
172#endif
173
174/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
175
Camilla Berglund22134502012-06-05 23:55:10 +0200176/* Include the chosen OpenGL header and, optionally, the GLU header.
Camilla Berglund3249f812010-09-07 17:34:51 +0200177 */
178#if defined(__APPLE_CC__)
Camilla Berglund410a4e22012-09-27 22:28:04 +0200179 #if defined(GLFW_INCLUDE_GLCOREARB)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200180 #include <OpenGL/gl3.h>
181 #else
182 #define GL_GLEXT_LEGACY
183 #include <OpenGL/gl.h>
184 #endif
Camilla Berglund22134502012-06-05 23:55:10 +0200185 #if defined(GLFW_INCLUDE_GLU)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200186 #include <OpenGL/glu.h>
187 #endif
Camilla Berglund3249f812010-09-07 17:34:51 +0200188#else
Camilla Berglund410a4e22012-09-27 22:28:04 +0200189 #if defined(GLFW_INCLUDE_GLCOREARB)
190 #include <GL/glcorearb.h>
Camilla Berglundd88789e2011-09-16 04:44:40 +0200191 #else
192 #include <GL/gl.h>
193 #endif
Camilla Berglund22134502012-06-05 23:55:10 +0200194 #if defined(GLFW_INCLUDE_GLU)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200195 #include <GL/glu.h>
196 #endif
Camilla Berglund3249f812010-09-07 17:34:51 +0200197#endif
198
199
200/*************************************************************************
201 * GLFW version
202 *************************************************************************/
203
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100204/*! @name GLFW version macros
205 * @{ */
206/*! @brief The major version number of the GLFW library.
207 *
208 * This is incremented when the API is changed in non-compatible ways.
209 * @ingroup init
210 */
Camilla Berglund38b0ccb2010-09-07 17:41:26 +0200211#define GLFW_VERSION_MAJOR 3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100212/*! @brief The minor version number of the GLFW library.
213 *
214 * This is incremented when features are added to the API but it remains
215 * backward-compatible.
216 * @ingroup init
217 */
Camilla Berglund38b0ccb2010-09-07 17:41:26 +0200218#define GLFW_VERSION_MINOR 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100219/*! @brief The revision number of the GLFW library.
220 *
221 * This is incremented when a bug fix release is made that does not contain any
222 * API changes.
223 * @ingroup init
224 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200225#define GLFW_VERSION_REVISION 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100226/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200227
228
229/*************************************************************************
230 * Input handling definitions
231 *************************************************************************/
232
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100233/*! @name Key and button actions
234 * @{ */
235/*! @brief The key or button was released.
236 * @ingroup input
237 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200238#define GLFW_RELEASE 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100239/*! @brief The key or button was pressed.
240 * @ingroup input
241 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200242#define GLFW_PRESS 1
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100243/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200244
Marcusc0cb4c22011-01-02 11:18:14 +0100245/* Keyboard raw key codes.
246 * These key codes are inspired by the USB HID Usage Tables v1.12 (p. 53-60),
247 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
248 * put in the 256+ range).
249 * The naming of the key codes follow these rules:
250 * - The US keyboard layout is used.
251 * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
252 * "3", etc).
253 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
254 * "COMMA", "LEFT_SQUARE_BRACKET", etc). Note that some names do not
255 * correspond to the Unicode standard (usually for brevity).
256 * - Keys that lack a clear US mapping are named "WORLD_x".
257 * - For non-printable keys, custom names are used (e.g. "F4",
258 * "BACKSPACE", etc).
Camilla Berglund3249f812010-09-07 17:34:51 +0200259 */
Marcusc0cb4c22011-01-02 11:18:14 +0100260
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100261/*! @defgroup keys Keyboard keys
262 * @ingroup input
263 * @{
264 */
265
Marcusc0cb4c22011-01-02 11:18:14 +0100266/* Printable keys */
267#define GLFW_KEY_SPACE 32
268#define GLFW_KEY_APOSTROPHE 39 /* ' */
269#define GLFW_KEY_COMMA 44 /* , */
270#define GLFW_KEY_MINUS 45 /* - */
271#define GLFW_KEY_PERIOD 46 /* . */
272#define GLFW_KEY_SLASH 47 /* / */
273#define GLFW_KEY_0 48
274#define GLFW_KEY_1 49
275#define GLFW_KEY_2 50
276#define GLFW_KEY_3 51
277#define GLFW_KEY_4 52
278#define GLFW_KEY_5 53
279#define GLFW_KEY_6 54
280#define GLFW_KEY_7 55
281#define GLFW_KEY_8 56
282#define GLFW_KEY_9 57
283#define GLFW_KEY_SEMICOLON 59 /* ; */
284#define GLFW_KEY_EQUAL 61 /* = */
285#define GLFW_KEY_A 65
286#define GLFW_KEY_B 66
287#define GLFW_KEY_C 67
288#define GLFW_KEY_D 68
289#define GLFW_KEY_E 69
290#define GLFW_KEY_F 70
291#define GLFW_KEY_G 71
292#define GLFW_KEY_H 72
293#define GLFW_KEY_I 73
294#define GLFW_KEY_J 74
295#define GLFW_KEY_K 75
296#define GLFW_KEY_L 76
297#define GLFW_KEY_M 77
298#define GLFW_KEY_N 78
299#define GLFW_KEY_O 79
300#define GLFW_KEY_P 80
301#define GLFW_KEY_Q 81
302#define GLFW_KEY_R 82
303#define GLFW_KEY_S 83
304#define GLFW_KEY_T 84
305#define GLFW_KEY_U 85
306#define GLFW_KEY_V 86
307#define GLFW_KEY_W 87
308#define GLFW_KEY_X 88
309#define GLFW_KEY_Y 89
310#define GLFW_KEY_Z 90
Marcus3b008472011-01-03 22:07:01 +0100311#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
Marcusc0cb4c22011-01-02 11:18:14 +0100312#define GLFW_KEY_BACKSLASH 92 /* \ */
Marcus3b008472011-01-03 22:07:01 +0100313#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
Marcusc0cb4c22011-01-02 11:18:14 +0100314#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
315#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
316#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
317
318/* Function keys */
319#define GLFW_KEY_ESCAPE 256
320#define GLFW_KEY_ENTER 257
321#define GLFW_KEY_TAB 258
322#define GLFW_KEY_BACKSPACE 259
323#define GLFW_KEY_INSERT 260
324#define GLFW_KEY_DELETE 261
325#define GLFW_KEY_RIGHT 262
326#define GLFW_KEY_LEFT 263
327#define GLFW_KEY_DOWN 264
328#define GLFW_KEY_UP 265
329#define GLFW_KEY_PAGE_UP 266
330#define GLFW_KEY_PAGE_DOWN 267
331#define GLFW_KEY_HOME 268
332#define GLFW_KEY_END 269
333#define GLFW_KEY_CAPS_LOCK 280
334#define GLFW_KEY_SCROLL_LOCK 281
335#define GLFW_KEY_NUM_LOCK 282
336#define GLFW_KEY_PRINT_SCREEN 283
337#define GLFW_KEY_PAUSE 284
338#define GLFW_KEY_F1 290
339#define GLFW_KEY_F2 291
340#define GLFW_KEY_F3 292
341#define GLFW_KEY_F4 293
342#define GLFW_KEY_F5 294
343#define GLFW_KEY_F6 295
344#define GLFW_KEY_F7 296
345#define GLFW_KEY_F8 297
346#define GLFW_KEY_F9 298
347#define GLFW_KEY_F10 299
348#define GLFW_KEY_F11 300
349#define GLFW_KEY_F12 301
350#define GLFW_KEY_F13 302
351#define GLFW_KEY_F14 303
352#define GLFW_KEY_F15 304
353#define GLFW_KEY_F16 305
354#define GLFW_KEY_F17 306
355#define GLFW_KEY_F18 307
356#define GLFW_KEY_F19 308
357#define GLFW_KEY_F20 309
358#define GLFW_KEY_F21 310
359#define GLFW_KEY_F22 311
360#define GLFW_KEY_F23 312
361#define GLFW_KEY_F24 313
362#define GLFW_KEY_F25 314
363#define GLFW_KEY_KP_0 320
364#define GLFW_KEY_KP_1 321
365#define GLFW_KEY_KP_2 322
366#define GLFW_KEY_KP_3 323
367#define GLFW_KEY_KP_4 324
368#define GLFW_KEY_KP_5 325
369#define GLFW_KEY_KP_6 326
370#define GLFW_KEY_KP_7 327
371#define GLFW_KEY_KP_8 328
372#define GLFW_KEY_KP_9 329
373#define GLFW_KEY_KP_DECIMAL 330
374#define GLFW_KEY_KP_DIVIDE 331
375#define GLFW_KEY_KP_MULTIPLY 332
376#define GLFW_KEY_KP_SUBTRACT 333
377#define GLFW_KEY_KP_ADD 334
378#define GLFW_KEY_KP_ENTER 335
379#define GLFW_KEY_KP_EQUAL 336
380#define GLFW_KEY_LEFT_SHIFT 340
381#define GLFW_KEY_LEFT_CONTROL 341
382#define GLFW_KEY_LEFT_ALT 342
383#define GLFW_KEY_LEFT_SUPER 343
384#define GLFW_KEY_RIGHT_SHIFT 344
385#define GLFW_KEY_RIGHT_CONTROL 345
386#define GLFW_KEY_RIGHT_ALT 346
387#define GLFW_KEY_RIGHT_SUPER 347
388#define GLFW_KEY_MENU 348
389#define GLFW_KEY_LAST GLFW_KEY_MENU
390
391/* GLFW 2.x key name aliases (deprecated) */
392#define GLFW_KEY_ESC GLFW_KEY_ESCAPE
393#define GLFW_KEY_DEL GLFW_KEY_DELETE
394#define GLFW_KEY_PAGEUP GLFW_KEY_PAGE_UP
395#define GLFW_KEY_PAGEDOWN GLFW_KEY_PAGE_DOWN
396#define GLFW_KEY_KP_NUM_LOCK GLFW_KEY_NUM_LOCK
397#define GLFW_KEY_LCTRL GLFW_KEY_LEFT_CONTROL
398#define GLFW_KEY_LSHIFT GLFW_KEY_LEFT_SHIFT
399#define GLFW_KEY_LALT GLFW_KEY_LEFT_ALT
400#define GLFW_KEY_LSUPER GLFW_KEY_LEFT_SUPER
401#define GLFW_KEY_RCTRL GLFW_KEY_RIGHT_CONTROL
402#define GLFW_KEY_RSHIFT GLFW_KEY_RIGHT_SHIFT
403#define GLFW_KEY_RALT GLFW_KEY_RIGHT_ALT
404#define GLFW_KEY_RSUPER GLFW_KEY_RIGHT_SUPER
Camilla Berglund3249f812010-09-07 17:34:51 +0200405
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100406/*! @} */
407
408/*! @defgroup buttons Mouse buttons
409 * @ingroup input
410 * @{ */
Camilla Berglund3249f812010-09-07 17:34:51 +0200411#define GLFW_MOUSE_BUTTON_1 0
412#define GLFW_MOUSE_BUTTON_2 1
413#define GLFW_MOUSE_BUTTON_3 2
414#define GLFW_MOUSE_BUTTON_4 3
415#define GLFW_MOUSE_BUTTON_5 4
416#define GLFW_MOUSE_BUTTON_6 5
417#define GLFW_MOUSE_BUTTON_7 6
418#define GLFW_MOUSE_BUTTON_8 7
419#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
Camilla Berglund3249f812010-09-07 17:34:51 +0200420#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
421#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
422#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100423/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200424
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100425/*! @defgroup joysticks Joysticks
426 * @ingroup input
427 * @{ */
Camilla Berglund3249f812010-09-07 17:34:51 +0200428#define GLFW_JOYSTICK_1 0
429#define GLFW_JOYSTICK_2 1
430#define GLFW_JOYSTICK_3 2
431#define GLFW_JOYSTICK_4 3
432#define GLFW_JOYSTICK_5 4
433#define GLFW_JOYSTICK_6 5
434#define GLFW_JOYSTICK_7 6
435#define GLFW_JOYSTICK_8 7
436#define GLFW_JOYSTICK_9 8
437#define GLFW_JOYSTICK_10 9
438#define GLFW_JOYSTICK_11 10
439#define GLFW_JOYSTICK_12 11
440#define GLFW_JOYSTICK_13 12
441#define GLFW_JOYSTICK_14 13
442#define GLFW_JOYSTICK_15 14
443#define GLFW_JOYSTICK_16 15
444#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100445/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200446
447
448/*************************************************************************
449 * Other definitions
450 *************************************************************************/
451
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100452/*! @brief A regular, overlapped window.
453 * @ingroup window
454 */
Camilla Berglund484a2712010-09-10 13:24:19 +0200455#define GLFW_WINDOWED 0x00010001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100456/*! @brief A fullscreen window that may changed the monitor's resolution.
457 * @ingroup window
458 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200459#define GLFW_FULLSCREEN 0x00010002
460
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100461/*! @defgroup paramhints Window parameters and hints
462 * @ingroup window
463 * @{ */
464
Camilla Berglund14355d62012-11-22 17:04:44 +0100465/*! @brief @c GL_TRUE if the window has focus, or @c GL_FALSE otherwise.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100466 */
Camilla Berglund14355d62012-11-22 17:04:44 +0100467#define GLFW_FOCUSED 0x00020001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100468/*! @brief @c GL_TRUE if the window is iconified, or @c GL_FALSE otherwise.
469 */
Camilla Berglund39dfa7d2010-11-15 21:39:46 +0100470#define GLFW_ICONIFIED 0x00020002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100471/*! @brief @c GL_TRUE if the window has been requested to close, or @c GL_FALSE
472 * otherwise.
473 */
Camilla Berglund2410e2a2012-08-10 13:31:15 +0200474#define GLFW_CLOSE_REQUESTED 0x00020003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100475/*! @brief The OpenGL API version revision.
476 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200477#define GLFW_OPENGL_REVISION 0x00020004
Camilla Berglund950a3be2010-09-09 19:58:51 +0200478
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100479/*! @brief The bit depth of the red component of the color buffer.
480 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200481#define GLFW_RED_BITS 0x00021000
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100482/*! @brief The bit depth of the green component of the color buffer.
483 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200484#define GLFW_GREEN_BITS 0x00021001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100485/*! @brief The bit depth of the blue component of the color buffer.
486 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200487#define GLFW_BLUE_BITS 0x00021002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100488/*! @brief The bit depth of the alpha component of the color buffer.
489 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200490#define GLFW_ALPHA_BITS 0x00021003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100491/*! @brief The bit depth of the depth buffer of the default framebuffer.
492 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200493#define GLFW_DEPTH_BITS 0x00021004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100494/*! @brief The bit depth of the stencil buffer of the default framebuffer.
495 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200496#define GLFW_STENCIL_BITS 0x00021005
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100497/*! @brief The monitor refresh rate.
498 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200499#define GLFW_REFRESH_RATE 0x00021006
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100500/*! @brief The bit depth of the red component of the accumulation buffer.
501 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200502#define GLFW_ACCUM_RED_BITS 0x00021007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100503/*! @brief The bit depth of the red component of the accumulation buffer.
504 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200505#define GLFW_ACCUM_GREEN_BITS 0x00021008
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100506/*! @brief The bit depth of the red component of the accumulation buffer.
507 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200508#define GLFW_ACCUM_BLUE_BITS 0x00021009
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100509/*! @brief The bit depth of the red component of the accumulation buffer.
510 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200511#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100512/*! @brief The number of auxiliary buffers.
513 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200514#define GLFW_AUX_BUFFERS 0x0002100B
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100515/*! @brief @c GL_TRUE for stereo rendering, or @c GL_FALSE otherwise.
516 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200517#define GLFW_STEREO 0x0002100C
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100518/*! @brief The number of samples used for default framebuffer multisampling.
519 */
Camilla Berglund4fb55782011-08-15 01:40:10 +0200520#define GLFW_FSAA_SAMPLES 0x0002100E
Camilla Berglundddcf5d42012-08-10 13:03:11 +0200521
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100522/*! @brief The @link clients client API @endlink to create a context for.
Camilla Berglundddcf5d42012-08-10 13:03:11 +0200523 */
Camilla Berglund38cad9a2012-09-30 15:32:50 +0200524#define GLFW_CLIENT_API 0x00022000
525#define GLFW_OPENGL_VERSION_MAJOR 0x00022001
526#define GLFW_OPENGL_VERSION_MINOR 0x00022002
527#define GLFW_OPENGL_FORWARD_COMPAT 0x00022003
528#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022004
529#define GLFW_OPENGL_PROFILE 0x00022005
530#define GLFW_OPENGL_ROBUSTNESS 0x00022006
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100531/*! @brief @c GL_TRUE if the window is resizable, or @c GL_FALSE otherwise.
532 */
Camilla Berglund38cad9a2012-09-30 15:32:50 +0200533#define GLFW_RESIZABLE 0x00022007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100534/*! @brief @c GL_TRUE if the window is visible, or @c GL_FALSE otherwise.
535 */
Camilla Berglund38cad9a2012-09-30 15:32:50 +0200536#define GLFW_VISIBLE 0x00022008
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100537/*! @brief The x-coordinate, in pixels, of the upper-left corner of the
538 * client area of the window.
539 */
m@bitsnbites.euc9f4ded2012-10-28 00:23:28 +0200540#define GLFW_POSITION_X 0x00022009
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100541/*! @brief The y-coordinate, in pixels, of the upper-left corner of the
542 * client area of the window.
543 */
m@bitsnbites.euc9f4ded2012-10-28 00:23:28 +0200544#define GLFW_POSITION_Y 0x0002200A
Camilla Berglund38cad9a2012-09-30 15:32:50 +0200545
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100546/*! @} */
547
548/*! @name Client APIs
549 * @{ */
550/*! @brief The OpenGL API.
551 * @ingroup opengl
552 */
Camilla Berglund38cad9a2012-09-30 15:32:50 +0200553#define GLFW_OPENGL_API 0x00000001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100554/*! @brief The OpenGL ES API.
555 * @ingroup opengl
556 */
Camilla Berglund38cad9a2012-09-30 15:32:50 +0200557#define GLFW_OPENGL_ES_API 0x00000002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100558/*! @} */
Camilla Berglundd43e0b52011-03-07 20:51:34 +0100559
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100560/*! @name OpenGL robustness strategies
561 * @{ */
562/*! @brief No robustness strategy is used.
563 *
564 * This is the default.
565 * @ingroup opengl
566 */
Camilla Berglundd43e0b52011-03-07 20:51:34 +0100567#define GLFW_OPENGL_NO_ROBUSTNESS 0x00000000
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100568/*! @brief
569 * @ingroup opengl
570 */
Camilla Berglundd43e0b52011-03-07 20:51:34 +0100571#define GLFW_OPENGL_NO_RESET_NOTIFICATION 0x00000001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100572/*! @brief
573 * @ingroup opengl
574 */
Camilla Berglundd43e0b52011-03-07 20:51:34 +0100575#define GLFW_OPENGL_LOSE_CONTEXT_ON_RESET 0x00000002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100576/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200577
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100578/*! @name OpenGL profiles
579 * @{ */
580/*! @brief No OpenGL profile.
581 * @ingroup opengl
582 */
Camilla Berglunde2c58b02011-09-19 21:00:29 +0200583#define GLFW_OPENGL_NO_PROFILE 0x00000000
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100584/*! @brief The OpenGL core profile.
585 * @ingroup opengl
586 */
Camilla Berglund20662dd2010-11-15 21:40:43 +0100587#define GLFW_OPENGL_CORE_PROFILE 0x00000001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100588/*! @brief The OpenGL compatibility profile.
589 * @ingroup opengl
590 */
Camilla Berglund20662dd2010-11-15 21:40:43 +0100591#define GLFW_OPENGL_COMPAT_PROFILE 0x00000002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100592/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200593
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100594/*! @name Input modes
595 * @{ */
596/*! @brief The behaviour of the cursor.
597 * @ingroup input
598 */
Camilla Berglundce288a82012-02-04 00:51:35 +0100599#define GLFW_CURSOR_MODE 0x00030001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100600/*! @brief Whether the @ref glfwGetKey function uses sticky state.
601 * @ingroup input
602 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200603#define GLFW_STICKY_KEYS 0x00030002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100604/*! @brief Whether the @ref glfwGetMouseButton function uses sticky state.
605 * @ingroup input
606 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200607#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100608/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200609
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100610/*! @name Cursor modes
611 * @{ */
612/*! @brief The cursor is visible and behaves normally.
613 * @ingroup input
614 */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200615#define GLFW_CURSOR_NORMAL 0x00040001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100616/*! @brief The cursor is hidden when over the client area of the window.
617 * @ingroup input
618 */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200619#define GLFW_CURSOR_HIDDEN 0x00040002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100620/*! @brief The cursor is disabled and cursor movement is unbounded.
621 * @ingroup input
622 */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200623#define GLFW_CURSOR_CAPTURED 0x00040003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100624/*! @} */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200625
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100626/*! @name Joystick parameters
627 * @{ */
628/*! @brief @c GL_TRUE if the joystick is present, or @c GL_FALSE otherwise.
629 * @ingroup input
630 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200631#define GLFW_PRESENT 0x00050001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100632/*! @brief The number of axes on the specified joystick, or zero if the joystick
633 * is not present.
634 * @ingroup input
635 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200636#define GLFW_AXES 0x00050002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100637/*! @brief The number of buttons on the specified joystick, or zero if the
638 * joystick is not present.
639 * @ingroup input
640 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200641#define GLFW_BUTTONS 0x00050003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100642/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200643
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100644/*! @defgroup errors Error codes
645 * @ingroup error
646 * @{ */
647/*! @brief No error has occurred.
648 */
Camilla Berglunde28543c2010-09-09 21:08:50 +0200649#define GLFW_NO_ERROR 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100650/*! @brief GLFW has not been initialized.
651 */
Camilla Berglunde28543c2010-09-09 21:08:50 +0200652#define GLFW_NOT_INITIALIZED 0x00070001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100653/*! @brief No context is current for this thread.
654 */
Camilla Berglund957ecdc2012-08-02 15:36:15 +0200655#define GLFW_NO_CURRENT_CONTEXT 0x00070002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100656/*! @brief One of the enum parameters for the function was given an invalid
657 * enum.
658 */
Camilla Berglund52546172010-10-05 00:08:19 +0200659#define GLFW_INVALID_ENUM 0x00070003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100660/*! @brief One of the parameters for the function was given an invalid value.
661 */
Camilla Berglund52546172010-10-05 00:08:19 +0200662#define GLFW_INVALID_VALUE 0x00070004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100663/*! @brief A memory allocation failed.
664 */
Camilla Berglund52546172010-10-05 00:08:19 +0200665#define GLFW_OUT_OF_MEMORY 0x00070005
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100666/*! @brief GLFW could not find support for the requested client API on the
667 * system.
668 */
Camilla Berglund52546172010-10-05 00:08:19 +0200669#define GLFW_OPENGL_UNAVAILABLE 0x00070006
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100670/*! @brief The requested OpenGL or GLES version is not available.
671 */
Camilla Berglund52546172010-10-05 00:08:19 +0200672#define GLFW_VERSION_UNAVAILABLE 0x00070007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100673/*! @brief A platform-specific error occurred that does not match any of the
674 * more specific categories.
675 */
Camilla Berglund52546172010-10-05 00:08:19 +0200676#define GLFW_PLATFORM_ERROR 0x00070008
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100677/*! @brief The clipboard did not contain data in the requested format.
678 */
Camilla Berglund998cb512012-11-22 17:20:16 +0100679#define GLFW_FORMAT_UNAVAILABLE 0x00070009
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100680/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200681
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100682/*! @brief The number of entries in the gamma ramp.
683 * @ingroup gamma
684 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200685#define GLFW_GAMMA_RAMP_SIZE 256
Camilla Berglund2c091572010-09-09 21:09:11 +0200686
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100687
Camilla Berglund3249f812010-09-07 17:34:51 +0200688/*************************************************************************
689 * Typedefs
690 *************************************************************************/
691
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100692/*! @brief OpenGL function pointer type.
693 * @ingroup opengl
694 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +0200695typedef void (*GLFWglproc)(void);
696
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100697/*! @brief Window handle type.
698 * @ingroup window
699 */
Camilla Berglunda66a4cd2011-02-09 12:37:42 +0100700typedef void* GLFWwindow;
Camilla Berglund135194a2010-09-09 18:15:32 +0200701
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100702/*! @brief The function signature for error callbacks.
703 * @param[in] error An @link errors error code @endlink.
704 * @param[in] description A UTF-8 encoded string describing the error.
705 * @ingroup error
706 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100707typedef void (* GLFWerrorfun)(int,const char*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100708
709/*! @brief The function signature for window resize callbacks.
710 * @param[in] window The window that the user resized.
711 * @param[in] width The new width, in pixels, of the window.
712 * @param[in] height The new height, in pixels, of the window.
713 * @ingroup window
714 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100715typedef void (* GLFWwindowsizefun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100716
717/*! @brief The function signature for window close callbacks.
718 * @param[in] window The window that the user attempted to close.
719 * @return @c GL_TRUE to allow the window to be closed, or @c GL_FALSE to
720 * ignore the attempt.
721 * @ingroup window
722 */
723typedef int (* GLFWwindowclosefun)(GLFWwindow);
724
725/*! @brief The function signature for window content refresh callbacks.
726 * @param[in] window The window whose content needs to be refreshed.
727 * @ingroup window
728 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100729typedef void (* GLFWwindowrefreshfun)(GLFWwindow);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100730
731/*! @brief The function signature for window focus/defocus callbacks.
732 * @param[in] window The window that was focused or defocused.
733 * @param[in] focused @c GL_TRUE if the window was focused, or @c GL_FALSE if
734 * it was defocused.
735 * @ingroup window
736 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100737typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100738
Camilla Berglund06e7a962012-11-22 19:14:27 +0100739/*! @brief The function signature for window iconify/restore callbacks.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100740 * @param[in] window The window that was iconified or restored.
741 * @param[in] iconified @c GL_TRUE if the window was iconified, or @c GL_FALSE
742 * if it was restored.
743 * @ingroup window
744 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100745typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100746
747/*! @brief The function signature for mouse button callbacks.
748 * @param[in] window The window that received the event.
749 * @param[in] button The @link buttons mouse button @endlink that was pressed
750 * or released.
751 * @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE.
752 * @ingroup input
753 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100754typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100755
756/*! @brief The function signature for cursor position callbacks.
757 * @param[in] window The window that received the event.
758 * @param[in] x The new x-coordinate of the cursor.
759 * @param[in] y The new y-coordinate of the cursor.
760 * @ingroup input
761 */
Camilla Berglundcef9dea2012-06-22 13:53:02 +0200762typedef void (* GLFWcursorposfun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100763
764/*! @brief The function signature for cursor enter/exit callbacks.
765 * @param[in] window The window that received the event.
766 * @param[in] entered @c GL_TRUE if the cursor entered the window's client
767 * area, or @c GL_FALSE if it left it.
768 * @ingroup input
769 */
Camilla Berglundc4806b92012-01-30 22:59:38 +0100770typedef void (* GLFWcursorenterfun)(GLFWwindow,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100771
772/*! @brief The function signature for scroll callbacks.
773 * @param[in] window The window that received the event.
774 * @param[in] x The scroll offset along the x-axis.
775 * @param[in] y The scroll offset along the y-axis.
776 * @ingroup input
777 */
Camilla Berglund4ef9aec2012-03-28 21:54:09 +0200778typedef void (* GLFWscrollfun)(GLFWwindow,double,double);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100779
780/*! @brief The function signature for keyboard key callbacks.
781 * @param[in] window The window that received the event.
782 * @param[in] key The @link keys keyboard key @endlink that was pressed or
783 * released.
784 * @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE.
785 * @ingroup input
786 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100787typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100788
789/*! @brief The function signature for Unicode character callbacks.
790 * @param[in] window The window that received the event.
791 * @param[in] character The Unicode code point of the character.
792 * @ingroup input
793 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100794typedef void (* GLFWcharfun)(GLFWwindow,int);
795
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100796/* @brief Video mode type.
797 * @ingroup monitor
798 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200799typedef struct
800{
801 int width;
802 int height;
803 int redBits;
804 int blueBits;
805 int greenBits;
Camilla Berglund3249f812010-09-07 17:34:51 +0200806} GLFWvidmode;
807
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100808/*! @brief Gamma ramp.
809 * @ingroup gamma
810 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200811typedef struct
812{
813 unsigned short red[GLFW_GAMMA_RAMP_SIZE];
814 unsigned short green[GLFW_GAMMA_RAMP_SIZE];
815 unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
816} GLFWgammaramp;
817
Camilla Berglund3249f812010-09-07 17:34:51 +0200818
819/*************************************************************************
820 * Prototypes
821 *************************************************************************/
822
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100823/*! @brief Initializes the GLFW library.
824 *
825 * Before most GLFW functions can be used, GLFW must be initialized, and before
826 * a program terminates GLFW should be terminated in order to free allocated
827 * resources, memory, etc.
828 *
829 * @return @c GL_TRUE if successful, or @c GL_FALSE if an error occurred.
830 * @ingroup init
831 *
832 * @remarks Additional calls to this function after successful initialization
833 * but before termination will succeed but will do nothing.
834 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +0100835 * @note This function may only be called from the main thread.
836 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100837 * @note This function may take several seconds to complete on some systems,
838 * while on other systems it may take only a fraction of a second to complete.
839 *
840 * @note On Mac OS X, this function will change the current directory of the
841 * application to the @c Contents/Resources subdirectory of the application's
842 * bundle, if present.
843 *
844 * @sa glfwTerminate
845 */
846GLFWAPI int glfwInit(void);
847
848/*! @brief Terminates the GLFW library.
849 * @ingroup init
850 *
851 * @remarks This function may be called before @ref glfwInit.
852 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +0100853 * @note This function may only be called from the main thread.
854 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100855 * @note This function closes all GLFW windows.
856 *
857 * @note This function should be called before the program exits.
858 *
859 * @warning No window's context may be current on another thread when this
860 * function is called.
861 *
862 * @sa glfwInit
863 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200864GLFWAPI void glfwTerminate(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100865
866/*! @brief Retrieves the version of the GLFW library.
867 * @param[out] major Where to store the major version number, or @c NULL.
868 * @param[out] minor Where to store the minor version number, or @c NULL.
869 * @param[out] rev Where to store the revision number, or @c NULL.
870 * @ingroup init
871 *
872 * @remarks This function may be called before @ref glfwInit.
873 *
874 * @remarks This function may be called from secondary threads.
875 *
876 * @sa glfwGetVersionString
877 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200878GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100879
880/*! @brief Returns the version string of the GLFW library.
881 *
882 * The version string contains information about what compile-time options were
883 * enabled when the library was built.
884 *
885 * @return The GLFW version string.
886 * @ingroup init
887 *
888 * @remarks This function may be called before @ref glfwInit.
889 *
890 * @remarks This function may be called from secondary threads.
891 *
892 * @sa glfwGetVersion
893 */
Camilla Berglundd6fe4472010-09-13 18:05:59 +0200894GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +0200895
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100896/*! @brief Retrieves the latest error.
897 * @return The latest @link errors error code @endlink.
898 * @ingroup error
899 *
900 * @remarks This function may be called before @ref glfwInit.
901 */
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200902GLFWAPI int glfwGetError(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100903
904/*! @brief Retrieves a generic, human readable description of the specified error.
905 * @param[in] error The @link errors error code @endlink to be described.
906 * @return A UTF-8 encoded string describing the error.
907 * @ingroup error
908 *
909 * @remarks This function may be called before @ref glfwInit.
910 *
911 * @remarks This function may be called from secondary threads.
912 */
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200913GLFWAPI const char* glfwErrorString(int error);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100914
915/*! @brief Sets the error callback.
916 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
917 * callback.
918 * @ingroup error
919 *
920 * @remarks This function may be called before @ref glfwInit.
921 *
922 * @remarks The error callback is the preferred error retrieval mechanism, as
923 * it may be provided with a more specific error description than the generic
924 * one returned by @ref glfwErrorString.
925 *
926 * @note Because the description string provided to the callback may have been
927 * generated specifically for that error, it is not guaranteed to be valid
928 * after the callback has returned. If you wish to use it after that, you need
929 * to make your own copy of it before returning.
930 */
Camilla Berglundf1e7d7c2010-11-23 17:45:23 +0100931GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun);
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200932
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100933/*! @ingroup monitor
934 */
Camilla Berglund871e1a72012-08-02 18:03:43 +0200935GLFWAPI GLFWvidmode* glfwGetVideoModes(int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100936
937/*! @ingroup monitor
938 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200939GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
Camilla Berglund3249f812010-09-07 17:34:51 +0200940
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100941/*! @brief Sets the system gamma ramp to one generated from the specified
942 * exponent.
943 * @param[in] The desired exponent.
944 * @ingroup gamma
945 */
Camilla Berglundca0dbdb2011-09-06 15:43:31 +0200946GLFWAPI void glfwSetGamma(float gamma);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100947
948/*! @brief Retrieves the current system gamma ramp.
949 * @param[out] ramp Where to store the gamma ramp.
950 * @ingroup gamma
951 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200952GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100953
954/*! @brief Sets the system gamma ramp to the one specified.
955 * @param[in] ramp The gamma ramp to use.
956 * @ingroup gamma
957 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200958GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
959
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100960/*! @brief Resets all window hints to their default values
961 *
962 * The @ref GLFW_RED_BITS, @ref GLFW_GREEN_BITS, @ref GLFW_BLUE_BITS, @ref
963 * GLFW_ALPHA_BITS and @ref GLFW_STENCIL_BITS hints are set to 8.
964 *
965 * The @ref GLFW_DEPTH_BITS hint is set to 24.
966 *
967 * The @ref GLFW_VISIBLE and @ref GLFW_RESIZABLE hints are set to 1.
968 *
969 * The @ref GLFW_CLIENT_API hint is set to @ref GLFW_OPENGL_API.
970 *
971 * The @ref GLFW_OPENGL_VERSION_MAJOR and @ref GLFW_OPENGL_VERSION_MINOR hints
972 * are set to 1 and 0, respectively.
973 *
974 * All other hints are set to 0.
975 *
976 * @ingroup window
977 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +0100978 * @note This function may only be called from the main thread.
979 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100980 * @sa glfwWindowHint
981 */
Camilla Berglund5df4df62012-10-22 02:59:05 +0200982GLFWAPI void glfwDefaultWindowHints(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100983
984/*! @brief Sets the specified window hint to the desired value.
985 * @param[in] target The window hint to set.
986 * @param[in] target The new value of the window hint.
987 * @ingroup window
988 *
989 * The @ref GLFW_RED_BITS, @ref GLFW_GREEN_BITS, @ref GLFW_BLUE_BITS, @ref
990 * GLFW_ALPHA_BITS, @ref GLFW_DEPTH_BITS and @ref GLFW_STENCIL_BITS hints
991 * specify the desired bit depths of the various components of the default
992 * framebuffer.
993 *
994 * The @ref GLFW_REFRESH_RATE hint specifies the desired monitor refresh rate
995 * for fullscreen windows.
996 *
997 * The @ref GLFW_ACCUM_RED_BITS, @ref GLFW_ACCUM_GREEN_BITS, @ref
998 * GLFW_ACCUM_BLUE_BITS and @ref GLFW_ACCUM_ALPHA_BITS hints specify the
999 * desired bit depths of the various components of the accumulation buffer.
1000 *
1001 * The @ref GLFW_AUX_BUFFERS hint specifies the desired number of auxiliary
1002 * buffers.
1003 *
1004 * The @ref GLFW_STEREO hint specifies whether to use stereoscopic rendering.
1005 * This is a hard constraint.
1006 *
1007 * The @ref GLFW_FSAA_SAMPLES hint specifies the desired number of samples to
1008 * use for multisampling.
1009 *
1010 * The @ref GLFW_CLIENT_API hint specifies which client API to create the
1011 * context for. Possible values are @ref GLFW_OPENGL_API and @ref
1012 * GLFW_OPENGL_ES_API. This is a hard constraint.
1013 *
1014 * The @ref GLFW_OPENGL_VERSION_MAJOR and @ref GLFW_OPENGL_VERSION_MINOR hints
1015 * specify the OpenGL version that the created context must be compatible with.
1016 *
1017 * These hints are @em not hard constraints, as they don't have to match
1018 * exactly, but @ref glfwCreateWindow will still fail if the resulting OpenGL
1019 * version is less than the one requested with hints. It is therefore
1020 * perfectly safe to use the default of version 1.0 for legacy code and you
1021 * will still get backwards-compatible contexts of version 3.0 and above when
1022 * available.
1023 *
1024 * The @ref GLFW_OPENGL_FORWARD_COMPAT hint specifies whether the OpenGL
1025 * context should be forward-compatible. This is a hard constraint.
1026 *
1027 * The @ref GLFW_OPENGL_DEBUG_CONTEXT hint specifies whether to create a debug
1028 * OpenGL context.
1029 *
1030 * The @ref GLFW_OPENGL_PROFILE hint specifies which OpenGL profile to create
1031 * the context for. Possible values are @ref GLFW_OPENGL_NO_PROFILE, @ref
1032 * GLFW_OPENGL_CORE_PROFILE and @ref GLFW_OPENGL_COMPAT_PROFILE. This is
1033 * a hard constraint.
1034 *
1035 * The @ref GLFW_OPENGL_ROBUSTNESS hint specifies the robustness strategy to be
1036 * used by the OpenGL context.
1037 *
1038 * The @ref GLFW_RESIZABLE hint specifies whether the window will be resizable
1039 * by the user. This hint is ignored for fullscreen windows.
1040 *
1041 * The @ref GLFW_VISIBLE hint specifies whether the window will be initially
1042 * visible. This hint is ignored for fullscreen windows.
1043 *
1044 * The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y hints specify the initial
1045 * position of the window. These hints are ignored for fullscreen windows.
1046 *
1047 * Some window hints are hard constraints. These must match the available
1048 * capabilities @em exactly for window and context creation to succeed. Hints
1049 * that are not hard constraints are matched as closely as possible, but the
1050 * resulting window and context may differ from what these hints requested.
1051 *
1052 * The following window hints are hard constraints:
1053 * @arg @ref GLFW_STEREO
1054 * @arg @ref GLFW_CLIENT_API
1055 * @arg @ref GLFW_OPENGL_FORWARD_COMPAT
1056 * @arg @ref GLFW_OPENGL_PROFILE
1057 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001058 * @note This function may only be called from the main thread.
1059 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001060 * @sa glfwDefaultWindowHints
1061 */
Camilla Berglundaff30d02012-08-06 17:56:41 +02001062GLFWAPI void glfwWindowHint(int target, int hint);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001063
1064/*! @brief Creates a window and its associated context.
1065 *
Camilla Berglundb8c16e42012-11-22 17:04:54 +01001066 * @param[in] width The desired width, in pixels, of the window. This must be
1067 * greater than zero.
1068 * @param[in] height The desired height, in pixels, of the window. This must
1069 * be greater than zero.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001070 * @param[in] mode One of @ref GLFW_WINDOWED or @ref GLFW_FULLSCREEN.
1071 * @param[in] title The initial, UTF-8 encoded window title.
1072 * @param[in] share The window whose context to share resources with, or @c
1073 * NULL to not share resources.
1074 * @return The handle of the created window, or @c NULL if an error occurred.
1075 * @ingroup window
1076 *
1077 * @remarks Most of the options for how the window and its context should be
1078 * created are specified via the @ref glfwWindowHint function.
1079 *
1080 * @remarks This function does not change which context is current. Before you
1081 * can use the newly created context, you need to make it current using @ref
1082 * glfwMakeContextCurrent.
1083 *
1084 * @remarks For fullscreen windows the initial cursor mode is @ref
1085 * GLFW_CURSOR_CAPTURED and the screensaver is prohibited from starting. For
1086 * regular windows the initial cursor mode is @ref GLFW_CURSOR_NORMAL and the
1087 * screensaver is allowed to start.
1088 *
1089 * @remarks In order to determine the actual properties of an opened window,
1090 * use @ref glfwGetWindowParam and @ref glfwGetWindowSize.
1091 *
1092 * @remarks On Microsoft Windows, if the executable has an icon resource named
1093 * @c GLFW_ICON, it will be set as the icon for the window. If no such icon is
1094 * present, the @c IDI_WINLOGO icon will be used instead.
1095 *
1096 * @remarks On Mac OS X the GLFW window has no icon, but programs using GLFW
1097 * will use the application bundle's icon. Also, the first time a window is
1098 * opened the menu bar is populated with common commands like Hide, Quit and
1099 * About. The (minimal) about dialog uses information from the application's
1100 * bundle. For more information on bundles, see the Bundle Programming Guide
1101 * provided by Apple.
1102 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001103 * @note This function may only be called from the main thread.
1104 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001105 * @sa glfwDestroyWindow
1106 */
Camilla Berglund2212cd92012-08-10 13:29:45 +02001107GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, int mode, const char* title, GLFWwindow share);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001108
1109/*! @brief Destroys the specified window and its context.
1110 * @param[in] window The window to destroy.
1111 * @ingroup window
1112 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001113 * @note This function may only be called from the main thread.
1114 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001115 * @note If the window's context is current on the main thread, it is
1116 * detached before being destroyed.
1117 *
1118 * @warning The window's context must not be current on any other thread.
1119 *
1120 * @sa glfwCreateWindow
1121 */
Camilla Berglundaff30d02012-08-06 17:56:41 +02001122GLFWAPI void glfwDestroyWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001123
1124/*! @brief Sets the title of the specified window.
1125 * @param[in] window The window whose title to change.
1126 * @param[in] title The UTF-8 encoded window title.
1127 * @ingroup window
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001128 *
1129 * @note This function may only be called from the main thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001130 */
Camilla Berglunda3390982012-09-02 15:22:56 +02001131GLFWAPI void glfwSetWindowTitle(GLFWwindow window, const char* title);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001132
1133/*! @brief Retrieves the size of the client area of the specified window.
1134 * @param[in] window The window whose size to retrieve.
1135 * @param[out] width The width of the client area.
1136 * @param[out] height The height of the client area.
1137 * @ingroup window
1138 *
1139 * @sa glfwSetWindowSize
1140 */
Camilla Berglunda3390982012-09-02 15:22:56 +02001141GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001142
1143/*! @brief Sets the size of the client area of the specified window.
1144 * @param[in] window The window to resize.
1145 * @param[in] width The desired width of the specified window.
1146 * @param[in] height The desired height of the specified window.
1147 * @ingroup window
1148 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001149 * @note This function may only be called from the main thread.
1150 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001151 * @note The window manager may put limits on what window sizes are allowed.
1152 *
1153 * @note For fullscreen windows, this function selects and switches to the
1154 * resolution closest to the specified size, without destroying the window's
1155 * context.
1156 *
1157 * @sa glfwGetWindowSize
1158 */
Camilla Berglunda3390982012-09-02 15:22:56 +02001159GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001160
1161/*! @brief Iconifies the specified window.
1162 * @param[in] window The window to iconify.
1163 * @ingroup window
1164 *
1165 * @remarks If the window is already iconified, this function does nothing.
1166 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001167 * @note This function may only be called from the main thread.
1168 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001169 * @sa glfwRestoreWindow
1170 */
Camilla Berglund135194a2010-09-09 18:15:32 +02001171GLFWAPI void glfwIconifyWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001172
1173/*! @brief Restores the specified window.
1174 * @param[in] window The window to restore.
1175 * @ingroup window
1176 *
1177 * @remarks If the window is already restored, this function does nothing.
1178 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001179 * @note This function may only be called from the main thread.
1180 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001181 * @sa glfwIconifyWindow
1182 */
Camilla Berglund135194a2010-09-09 18:15:32 +02001183GLFWAPI void glfwRestoreWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001184
1185/*! @brief Makes the specified window visible.
1186 * @param[in] window The window to make visible.
1187 * @ingroup window
1188 *
1189 * @remarks If the window is already visible, this function does nothing.
1190 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001191 * @note This function may only be called from the main thread.
1192 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001193 * @sa glfwHideWindow
1194 */
Riku Salminen596132c2012-08-21 21:01:57 +03001195GLFWAPI void glfwShowWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001196
1197/*! @brief Hides the specified window.
1198 * @param[in] window The window to hide.
1199 * @ingroup window
1200 *
1201 * @remarks If the window is already hidden, this function does nothing.
1202 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001203 * @note This function may only be called from the main thread.
1204 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001205 * @sa glfwShowWindow
1206 */
Riku Salminen596132c2012-08-21 21:01:57 +03001207GLFWAPI void glfwHideWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001208
1209/*! @brief Returns a property of the specified window.
1210 * @ingroup window
1211 */
1212GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param);
1213
1214/*! @brief Sets the user pointer of the specified window.
1215 * @param[in] window The window whose pointer to set.
1216 * @param[in] pointer The new value.
1217 * @ingroup window
1218 *
1219 * @sa glfwGetWindowUserPointer
1220 */
Camilla Berglund48f5a7e2010-09-09 22:44:38 +02001221GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001222
1223/*! @brief Returns the user pointer of the specified window.
1224 * @param[in] window The window whose pointer to return.
1225 * @ingroup window
1226 *
1227 * @sa glfwSetWindowUserPointer
1228 */
Camilla Berglund48f5a7e2010-09-09 22:44:38 +02001229GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001230
1231/*! @brief Sets the size callback for the specified window.
1232 * @param[in] window The window whose callback to set.
1233 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
1234 * callback.
1235 * @ingroup window
1236 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001237GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001238
1239/*! @brief Sets the close callback for the specified window.
1240 * @param[in] window The window whose callback to set.
1241 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
1242 * callback.
1243 * @ingroup window
1244 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001245GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001246
1247/*! @brief Sets the refresh callback for the specified window.
1248 * @param[in] window The window whose callback to set.
1249 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
1250 * callback.
1251 * @ingroup window
1252 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001253GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001254
1255/*! @brief Sets the focus callback for the specified window.
1256 * @param[in] window The window whose callback to set.
1257 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
1258 * callback.
1259 * @ingroup window
1260 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001261GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001262
1263/*! @brief Sets the iconify callback for the specified window.
1264 * @param[in] window The window whose callback to set.
1265 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
1266 * callback.
1267 * @ingroup window
1268 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001269GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun);
Camilla Berglund135194a2010-09-09 18:15:32 +02001270
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001271/*! @brief Processes all pending events.
1272 * @ingroup window
1273 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001274 * @note This function may only be called from the main thread.
1275 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001276 * @sa glfwWaitEvents
1277 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001278GLFWAPI void glfwPollEvents(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001279
1280/*! @brief Waits until events are pending and processes them.
1281 * @ingroup window
1282 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001283 * @note This function may only be called from the main thread.
1284 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001285 * @sa glfwPollEvents
1286 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001287GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +02001288
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001289/*! @brief Returns the value of an input option for the specified window.
1290 * @param[in] window The window to query.
1291 * @param[in] mode One of the following:
1292 * @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
1293 * @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
1294 * @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001295 * @ingroup input
1296 *
1297 * @sa glfwSetInputMode
1298 */
1299GLFWAPI int glfwGetInputMode(GLFWwindow window, int mode);
1300
1301/*! @brief Sets an input option for the specified window.
1302 * @param[in] mode One of the following:
1303 * @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
1304 * @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
1305 * @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001306 * @ingroup input
1307 *
1308 * @sa glfwGetInputMode
1309 */
Camilla Berglund609c0082012-02-04 01:34:12 +01001310GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001311
1312/*! @brief Returns the last reported state of a keyboard key for the specified
1313 * window.
1314 * @param[in] window The desired window.
1315 * @param[in] key The desired @link keys keyboard key @endlink.
1316 * @return @ref GLFW_PRESS or @ref GLFW_RELEASE.
1317 * @ingroup input
1318 */
1319GLFWAPI int glfwGetKey(GLFWwindow window, int key);
1320
1321/*! @brief Returns the last reported state of a mouse button for the specified
1322 * window.
1323 * @param[in] window The desired window.
1324 * @param[in] key The desired @link buttons mouse buttons @endlink.
1325 * @return @ref GLFW_PRESS or @ref GLFW_RELEASE.
1326 * @ingroup input
1327 */
1328GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button);
1329
1330/*! @brief Retrieves the last reported cursor position, relative to the client
1331 * area of the window.
1332 * @param[in] window The desired window.
1333 * @param[out] xpos The cursor x-coordinate, relative to the left edge of the
1334 * client area, or @c NULL.
1335 * @param[out] ypos The cursor y-coordinate, relative to the to top edge of the
1336 * client area, or @c NULL.
1337 * @ingroup input
1338 *
1339 * @sa glfwSetCursorPos
1340 */
Camilla Berglundcef9dea2012-06-22 13:53:02 +02001341GLFWAPI void glfwGetCursorPos(GLFWwindow window, int* xpos, int* ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001342
1343/*! @brief Sets the position of the cursor, relative to the client area of the window.
1344 * @param[in] window The desired window.
1345 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
1346 * client area, or @c NULL.
1347 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
1348 * client area, or @c NULL.
1349 * @ingroup input
1350 *
Camilla Berglund14355d62012-11-22 17:04:44 +01001351 * @note The specified window must be focused.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001352 *
1353 * @sa glfwGetCursorPos
1354 */
Camilla Berglundcef9dea2012-06-22 13:53:02 +02001355GLFWAPI void glfwSetCursorPos(GLFWwindow window, int xpos, int ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001356
1357/*! @ingroup input
1358 */
Camilla Berglund4ef9aec2012-03-28 21:54:09 +02001359GLFWAPI void glfwGetScrollOffset(GLFWwindow window, double* xoffset, double* yoffset);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001360
1361/*! @brief Sets the key callback.
1362 * @param[in] cbfun The new key callback, or @c NULL to remove the currently
1363 * set callback.
1364 * @ingroup input
1365 *
1366 * @note The key callback deals with physical keys, with @link keys tokens
1367 * @endlink named after their use on the standard US keyboard layout. If you
1368 * want to input text, use the Unicode character callback instead.
1369 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001370GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001371
1372/*! @brief Sets the Unicode character callback.
1373 * @param[in] cbfun The new Unicode character callback, or @c NULL to remove
1374 * the currently set callback.
1375 * @ingroup input
1376 *
1377 * @note The Unicode character callback is for text input. If you want to know
1378 * whether a specific key was pressed or released, use the key callback.
1379 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001380GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001381
1382/*! @brief Sets the mouse button callback.
1383 * @param[in] cbfun The new mouse button callback, or @c NULL to remove the
1384 * currently set callback.
1385 * @ingroup input
1386 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001387GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001388
1389/*! @brief Sets the cursor position callback.
1390 * @param[in] cbfun The new cursor position callback, or @c NULL to remove the
1391 * currently set callback.
1392 * @ingroup input
1393 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001394GLFWAPI void glfwSetCursorPosCallback(GLFWwindow window, GLFWcursorposfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001395
1396/*! @brief Sets the cursor enter/exit callback.
1397 * @param[in] cbfun The new cursor enter/exit callback, or @c NULL to remove
1398 * the currently set callback.
1399 * @ingroup input
1400 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001401GLFWAPI void glfwSetCursorEnterCallback(GLFWwindow window, GLFWcursorenterfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001402
1403/*! @brief Sets the scroll callback.
1404 * @param[in] cbfun The new scroll callback, or @c NULL to remove the currently
1405 * set callback.
1406 * @ingroup input
1407 *
1408 * @note This receives all scrolling input, like that from a mouse wheel or
1409 * a touchpad scrolling area.
1410 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001411GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun);
Camilla Berglund3249f812010-09-07 17:34:51 +02001412
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001413/*! @brief Returns a property of the specified joystick.
1414 * @param[in] joy The joystick to query.
1415 * @param[in] param The property whose value to return.
1416 * @return The specified joystick's current value, or zero if the joystick is
1417 * not present.
1418 * @ingroup input
1419 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001420GLFWAPI int glfwGetJoystickParam(int joy, int param);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001421
1422/*! @brief Returns the values of axes of the specified joystick.
1423 * @param[in] joy The joystick to query.
1424 * @param[out] axes The array to hold the values.
1425 * @param[in] numaxes The size of the provided array.
1426 * @return The number of values written to @p axes.
1427 * @ingroup input
1428 */
Camilla Berglund2502e4d2012-08-29 18:31:12 +02001429GLFWAPI int glfwGetJoystickAxes(int joy, float* axes, int numaxes);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001430
1431/*! @brief Returns the values of buttons of the specified joystick.
1432 * @param[in] joy The joystick to query.
1433 * @param[out] buttons The array to hold the values.
1434 * @param[in] numbuttons The size of the provided array.
1435 * @return The number of values written to @p buttons.
1436 * @ingroup input
1437 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001438GLFWAPI int glfwGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons);
Camilla Berglund3249f812010-09-07 17:34:51 +02001439
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001440/*! @brief Sets the clipboard to the specified string.
1441 * @param[in] window The window that will own the clipboard contents.
1442 * @param[in] string A UTF-8 encoded string.
1443 * @ingroup clipboard
1444 *
1445 * @sa glfwGetClipboardString
1446 */
Camilla Berglund1214fa12012-04-09 16:03:14 +02001447GLFWAPI void glfwSetClipboardString(GLFWwindow window, const char* string);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001448
1449/*! @brief Retrieves the contents of the clipboard as a string.
1450 * @param[in] window The window that will request the clipboard contents.
1451 * @return The contents of the clipboard as a UTF-8 encoded string, or @c NULL
1452 * if that format was unavailable.
1453 * @ingroup clipboard
1454 *
1455 * @note The returned string is valid only until the next call to @ref
1456 * glfwGetClipboardString or @ref glfwSetClipboardString.
1457 *
1458 * @sa glfwSetClipboardString
1459 */
Camilla Berglundf8687122012-04-12 00:51:58 +02001460GLFWAPI const char* glfwGetClipboardString(GLFWwindow window);
Ralph Eastwood31c91542011-09-21 10:09:47 +01001461
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001462/*! @brief Retrieves the current value of the GLFW timer.
1463 * @return The current value, in seconds.
1464 * @ingroup time
1465 *
1466 * @remarks This function may be called from secondary threads.
1467 *
1468 * @remarks Unless the timer has been set using @ref glfwSetTime, the timer
1469 * measures time elapsed since GLFW was initialized.
1470 *
1471 * @note The resolution of the timer is system dependent.
1472 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001473GLFWAPI double glfwGetTime(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02001474
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001475/*! @brief Sets the GLFW timer.
1476 * @param[in] time The new value, in seconds.
1477 * @ingroup time
1478 *
1479 * @note The resolution of the timer is system dependent.
1480 */
1481GLFWAPI void glfwSetTime(double time);
1482
1483/*! @brief Makes the context of the specified window current for this thread.
1484 * @param[in] window The window whose context to make current, or @c NULL to
1485 * detach the current context.
1486 * @ingroup opengl
1487 *
1488 * @remarks This function may be called from secondary threads.
1489 *
1490 * @note A context may only be current for a single thread at a time.
1491 *
1492 * @sa glfwGetCurrentContext
1493 */
Camilla Berglundc1ab73b2011-07-27 16:01:27 +02001494GLFWAPI void glfwMakeContextCurrent(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001495
1496/*! @brief Returns the window whose context is current on this thread.
1497 * @return The window whose context is current, or @c NULL if no window's
1498 * context is current.
1499 * @ingroup opengl
1500 *
1501 * @remarks This function may be called from secondary threads.
1502 *
1503 * @sa glfwMakeContextCurrent
1504 */
Camilla Berglundc1ab73b2011-07-27 16:01:27 +02001505GLFWAPI GLFWwindow glfwGetCurrentContext(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001506
1507/*! @brief Swaps the front and back buffers of the specified window.
1508 * @param[in] The window whose buffers to swap.
1509 * @ingroup opengl
1510 *
1511 * @remarks This function may be called from secondary threads.
1512 *
1513 * @sa glfwSwapInterval
1514 */
1515GLFWAPI void glfwSwapBuffers(GLFWwindow window);
1516
1517/*! @brief Sets the swap interval for the current context.
1518 * @param[in] interval The minimum number of video frame periods to wait for
1519 * until the buffers are swapped by @ref glfwSwapBuffers.
1520 * @ingroup opengl
1521 *
1522 * @remarks This function may be called from secondary threads.
1523 *
1524 * @sa glfwSwapBuffers
1525 */
1526GLFWAPI void glfwSwapInterval(int interval);
1527
1528/*! @brief Checks whether the specified extension is available.
1529 * @param[in] extension The ASCII encoded name of the extension.
1530 * @return @c GL_TRUE if the extension is available, or @c FALSE otherwise.
1531 * @ingroup opengl
1532 *
1533 * @remarks This function may be called from secondary threads.
1534 *
1535 * @note This function checks not only the client API extension string, but
1536 * also any platform-specific context creation API extension strings.
1537 */
1538GLFWAPI int glfwExtensionSupported(const char* extension);
1539
1540/*! @brief Returns the address of the specified client API function for the
1541 * current context.
1542 * @param[in] procname The ASCII encoded name of the function.
1543 * @return The address of the function, or @c NULL if the function is
1544 * unavailable.
1545 * @ingroup opengl
1546 *
1547 * @remarks This function may be called from secondary threads.
1548 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02001549GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001550
1551/*! @brief Copies the desired parts of the state of one window's context to another.
1552 * @ingroup opengl
1553 *
1554 * @remarks This function may be called from secondary threads.
1555 */
1556GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
Camilla Berglund3249f812010-09-07 17:34:51 +02001557
Camilla Berglund3249f812010-09-07 17:34:51 +02001558
Camilla Berglund4afc67c2011-07-27 17:09:17 +02001559/*************************************************************************
1560 * Global definition cleanup
1561 *************************************************************************/
1562
1563/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
1564
Camilla Berglund4afc67c2011-07-27 17:09:17 +02001565#ifdef GLFW_WINGDIAPI_DEFINED
1566 #undef WINGDIAPI
1567 #undef GLFW_WINGDIAPI_DEFINED
1568#endif
1569
1570#ifdef GLFW_CALLBACK_DEFINED
1571 #undef CALLBACK
1572 #undef GLFW_CALLBACK_DEFINED
1573#endif
1574
1575/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
1576
1577
Camilla Berglund3249f812010-09-07 17:34:51 +02001578#ifdef __cplusplus
1579}
1580#endif
1581
Camilla Berglund36e54092010-11-09 02:58:35 +01001582#endif /* __glfw3_h__ */
Camilla Berglund3249f812010-09-07 17:34:51 +02001583