blob: ba2184da4a170f3646a98bb7e161d86543edd579 [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
79/* Please report any probles that you find with your compiler, which may
80 * 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/*! @brief Whether to allow key repeat for the @link GLFWkeyfun key callback
609 * @endlink.
610 * @ingroup input
611 */
m@bitsnbites.eu1c21fc12012-10-28 00:50:38 +0200612#define GLFW_KEY_REPEAT 0x00030004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100613/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200614
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100615/*! @name Cursor modes
616 * @{ */
617/*! @brief The cursor is visible and behaves normally.
618 * @ingroup input
619 */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200620#define GLFW_CURSOR_NORMAL 0x00040001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100621/*! @brief The cursor is hidden when over the client area of the window.
622 * @ingroup input
623 */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200624#define GLFW_CURSOR_HIDDEN 0x00040002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100625/*! @brief The cursor is disabled and cursor movement is unbounded.
626 * @ingroup input
627 */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200628#define GLFW_CURSOR_CAPTURED 0x00040003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100629/*! @} */
Camilla Berglundb1656d72011-09-06 13:55:29 +0200630
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100631/*! @name Joystick parameters
632 * @{ */
633/*! @brief @c GL_TRUE if the joystick is present, or @c GL_FALSE otherwise.
634 * @ingroup input
635 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200636#define GLFW_PRESENT 0x00050001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100637/*! @brief The number of axes on the specified joystick, or zero if the joystick
638 * is not present.
639 * @ingroup input
640 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200641#define GLFW_AXES 0x00050002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100642/*! @brief The number of buttons on the specified joystick, or zero if the
643 * joystick is not present.
644 * @ingroup input
645 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200646#define GLFW_BUTTONS 0x00050003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100647/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200648
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100649/*! @defgroup errors Error codes
650 * @ingroup error
651 * @{ */
652/*! @brief No error has occurred.
653 */
Camilla Berglunde28543c2010-09-09 21:08:50 +0200654#define GLFW_NO_ERROR 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100655/*! @brief GLFW has not been initialized.
656 */
Camilla Berglunde28543c2010-09-09 21:08:50 +0200657#define GLFW_NOT_INITIALIZED 0x00070001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100658/*! @brief No context is current for this thread.
659 */
Camilla Berglund957ecdc2012-08-02 15:36:15 +0200660#define GLFW_NO_CURRENT_CONTEXT 0x00070002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100661/*! @brief One of the enum parameters for the function was given an invalid
662 * enum.
663 */
Camilla Berglund52546172010-10-05 00:08:19 +0200664#define GLFW_INVALID_ENUM 0x00070003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100665/*! @brief One of the parameters for the function was given an invalid value.
666 */
Camilla Berglund52546172010-10-05 00:08:19 +0200667#define GLFW_INVALID_VALUE 0x00070004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100668/*! @brief A memory allocation failed.
669 */
Camilla Berglund52546172010-10-05 00:08:19 +0200670#define GLFW_OUT_OF_MEMORY 0x00070005
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100671/*! @brief GLFW could not find support for the requested client API on the
672 * system.
673 */
Camilla Berglund52546172010-10-05 00:08:19 +0200674#define GLFW_OPENGL_UNAVAILABLE 0x00070006
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100675/*! @brief The requested OpenGL or GLES version is not available.
676 */
Camilla Berglund52546172010-10-05 00:08:19 +0200677#define GLFW_VERSION_UNAVAILABLE 0x00070007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100678/*! @brief A platform-specific error occurred that does not match any of the
679 * more specific categories.
680 */
Camilla Berglund52546172010-10-05 00:08:19 +0200681#define GLFW_PLATFORM_ERROR 0x00070008
Camilla Berglund14355d62012-11-22 17:04:44 +0100682/*! @brief The specified window needed to be focused for the call to succeed.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100683 */
Camilla Berglund14355d62012-11-22 17:04:44 +0100684#define GLFW_WINDOW_NOT_FOCUSED 0x00070009
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100685/*! @brief The clipboard did not contain data in the requested format.
686 */
Camilla Berglund7044ed62012-04-09 15:54:36 +0200687#define GLFW_FORMAT_UNAVAILABLE 0x0007000A
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100688/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200689
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100690/*! @brief The number of entries in the gamma ramp.
691 * @ingroup gamma
692 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200693#define GLFW_GAMMA_RAMP_SIZE 256
Camilla Berglund2c091572010-09-09 21:09:11 +0200694
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100695
Camilla Berglund3249f812010-09-07 17:34:51 +0200696/*************************************************************************
697 * Typedefs
698 *************************************************************************/
699
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100700/*! @brief OpenGL function pointer type.
701 * @ingroup opengl
702 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +0200703typedef void (*GLFWglproc)(void);
704
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100705/*! @brief Window handle type.
706 * @ingroup window
707 */
Camilla Berglunda66a4cd2011-02-09 12:37:42 +0100708typedef void* GLFWwindow;
Camilla Berglund135194a2010-09-09 18:15:32 +0200709
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100710/*! @brief The function signature for error callbacks.
711 * @param[in] error An @link errors error code @endlink.
712 * @param[in] description A UTF-8 encoded string describing the error.
713 * @ingroup error
714 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100715typedef void (* GLFWerrorfun)(int,const char*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100716
717/*! @brief The function signature for window resize callbacks.
718 * @param[in] window The window that the user resized.
719 * @param[in] width The new width, in pixels, of the window.
720 * @param[in] height The new height, in pixels, of the window.
721 * @ingroup window
722 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100723typedef void (* GLFWwindowsizefun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100724
725/*! @brief The function signature for window close callbacks.
726 * @param[in] window The window that the user attempted to close.
727 * @return @c GL_TRUE to allow the window to be closed, or @c GL_FALSE to
728 * ignore the attempt.
729 * @ingroup window
730 */
731typedef int (* GLFWwindowclosefun)(GLFWwindow);
732
733/*! @brief The function signature for window content refresh callbacks.
734 * @param[in] window The window whose content needs to be refreshed.
735 * @ingroup window
736 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100737typedef void (* GLFWwindowrefreshfun)(GLFWwindow);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100738
739/*! @brief The function signature for window focus/defocus callbacks.
740 * @param[in] window The window that was focused or defocused.
741 * @param[in] focused @c GL_TRUE if the window was focused, or @c GL_FALSE if
742 * it was defocused.
743 * @ingroup window
744 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100745typedef void (* GLFWwindowfocusfun)(GLFWwindow,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100746
747/*! @brief The function signature for window iconfiy/restore callbacks.
748 * @param[in] window The window that was iconified or restored.
749 * @param[in] iconified @c GL_TRUE if the window was iconified, or @c GL_FALSE
750 * if it was restored.
751 * @ingroup window
752 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100753typedef void (* GLFWwindowiconifyfun)(GLFWwindow,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100754
755/*! @brief The function signature for mouse button callbacks.
756 * @param[in] window The window that received the event.
757 * @param[in] button The @link buttons mouse button @endlink that was pressed
758 * or released.
759 * @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE.
760 * @ingroup input
761 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100762typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100763
764/*! @brief The function signature for cursor position callbacks.
765 * @param[in] window The window that received the event.
766 * @param[in] x The new x-coordinate of the cursor.
767 * @param[in] y The new y-coordinate of the cursor.
768 * @ingroup input
769 */
Camilla Berglundcef9dea2012-06-22 13:53:02 +0200770typedef void (* GLFWcursorposfun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100771
772/*! @brief The function signature for cursor enter/exit callbacks.
773 * @param[in] window The window that received the event.
774 * @param[in] entered @c GL_TRUE if the cursor entered the window's client
775 * area, or @c GL_FALSE if it left it.
776 * @ingroup input
777 */
Camilla Berglundc4806b92012-01-30 22:59:38 +0100778typedef void (* GLFWcursorenterfun)(GLFWwindow,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100779
780/*! @brief The function signature for scroll callbacks.
781 * @param[in] window The window that received the event.
782 * @param[in] x The scroll offset along the x-axis.
783 * @param[in] y The scroll offset along the y-axis.
784 * @ingroup input
785 */
Camilla Berglund4ef9aec2012-03-28 21:54:09 +0200786typedef void (* GLFWscrollfun)(GLFWwindow,double,double);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100787
788/*! @brief The function signature for keyboard key callbacks.
789 * @param[in] window The window that received the event.
790 * @param[in] key The @link keys keyboard key @endlink that was pressed or
791 * released.
792 * @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE.
793 * @ingroup input
794 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100795typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100796
797/*! @brief The function signature for Unicode character callbacks.
798 * @param[in] window The window that received the event.
799 * @param[in] character The Unicode code point of the character.
800 * @ingroup input
801 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100802typedef void (* GLFWcharfun)(GLFWwindow,int);
803
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100804/* @brief Video mode type.
805 * @ingroup monitor
806 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200807typedef struct
808{
809 int width;
810 int height;
811 int redBits;
812 int blueBits;
813 int greenBits;
Camilla Berglund3249f812010-09-07 17:34:51 +0200814} GLFWvidmode;
815
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100816/*! @brief Gamma ramp.
817 * @ingroup gamma
818 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200819typedef struct
820{
821 unsigned short red[GLFW_GAMMA_RAMP_SIZE];
822 unsigned short green[GLFW_GAMMA_RAMP_SIZE];
823 unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
824} GLFWgammaramp;
825
Camilla Berglund3249f812010-09-07 17:34:51 +0200826
827/*************************************************************************
828 * Prototypes
829 *************************************************************************/
830
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100831/*! @brief Initializes the GLFW library.
832 *
833 * Before most GLFW functions can be used, GLFW must be initialized, and before
834 * a program terminates GLFW should be terminated in order to free allocated
835 * resources, memory, etc.
836 *
837 * @return @c GL_TRUE if successful, or @c GL_FALSE if an error occurred.
838 * @ingroup init
839 *
840 * @remarks Additional calls to this function after successful initialization
841 * but before termination will succeed but will do nothing.
842 *
843 * @note This function may take several seconds to complete on some systems,
844 * while on other systems it may take only a fraction of a second to complete.
845 *
846 * @note On Mac OS X, this function will change the current directory of the
847 * application to the @c Contents/Resources subdirectory of the application's
848 * bundle, if present.
849 *
850 * @sa glfwTerminate
851 */
852GLFWAPI int glfwInit(void);
853
854/*! @brief Terminates the GLFW library.
855 * @ingroup init
856 *
857 * @remarks This function may be called before @ref glfwInit.
858 *
859 * @note This function closes all GLFW windows.
860 *
861 * @note This function should be called before the program exits.
862 *
863 * @warning No window's context may be current on another thread when this
864 * function is called.
865 *
866 * @sa glfwInit
867 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200868GLFWAPI void glfwTerminate(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100869
870/*! @brief Retrieves the version of the GLFW library.
871 * @param[out] major Where to store the major version number, or @c NULL.
872 * @param[out] minor Where to store the minor version number, or @c NULL.
873 * @param[out] rev Where to store the revision number, or @c NULL.
874 * @ingroup init
875 *
876 * @remarks This function may be called before @ref glfwInit.
877 *
878 * @remarks This function may be called from secondary threads.
879 *
880 * @sa glfwGetVersionString
881 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200882GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100883
884/*! @brief Returns the version string of the GLFW library.
885 *
886 * The version string contains information about what compile-time options were
887 * enabled when the library was built.
888 *
889 * @return The GLFW version string.
890 * @ingroup init
891 *
892 * @remarks This function may be called before @ref glfwInit.
893 *
894 * @remarks This function may be called from secondary threads.
895 *
896 * @sa glfwGetVersion
897 */
Camilla Berglundd6fe4472010-09-13 18:05:59 +0200898GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +0200899
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100900/*! @brief Retrieves the latest error.
901 * @return The latest @link errors error code @endlink.
902 * @ingroup error
903 *
904 * @remarks This function may be called before @ref glfwInit.
905 */
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200906GLFWAPI int glfwGetError(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100907
908/*! @brief Retrieves a generic, human readable description of the specified error.
909 * @param[in] error The @link errors error code @endlink to be described.
910 * @return A UTF-8 encoded string describing the error.
911 * @ingroup error
912 *
913 * @remarks This function may be called before @ref glfwInit.
914 *
915 * @remarks This function may be called from secondary threads.
916 */
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200917GLFWAPI const char* glfwErrorString(int error);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100918
919/*! @brief Sets the error callback.
920 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
921 * callback.
922 * @ingroup error
923 *
924 * @remarks This function may be called before @ref glfwInit.
925 *
926 * @remarks The error callback is the preferred error retrieval mechanism, as
927 * it may be provided with a more specific error description than the generic
928 * one returned by @ref glfwErrorString.
929 *
930 * @note Because the description string provided to the callback may have been
931 * generated specifically for that error, it is not guaranteed to be valid
932 * after the callback has returned. If you wish to use it after that, you need
933 * to make your own copy of it before returning.
934 */
Camilla Berglundf1e7d7c2010-11-23 17:45:23 +0100935GLFWAPI void glfwSetErrorCallback(GLFWerrorfun cbfun);
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200936
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100937/*! @ingroup monitor
938 */
Camilla Berglund871e1a72012-08-02 18:03:43 +0200939GLFWAPI GLFWvidmode* glfwGetVideoModes(int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100940
941/*! @ingroup monitor
942 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200943GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode);
Camilla Berglund3249f812010-09-07 17:34:51 +0200944
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100945/*! @brief Sets the system gamma ramp to one generated from the specified
946 * exponent.
947 * @param[in] The desired exponent.
948 * @ingroup gamma
949 */
Camilla Berglundca0dbdb2011-09-06 15:43:31 +0200950GLFWAPI void glfwSetGamma(float gamma);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100951
952/*! @brief Retrieves the current system gamma ramp.
953 * @param[out] ramp Where to store the gamma ramp.
954 * @ingroup gamma
955 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200956GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100957
958/*! @brief Sets the system gamma ramp to the one specified.
959 * @param[in] ramp The gamma ramp to use.
960 * @ingroup gamma
961 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200962GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
963
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100964/*! @brief Resets all window hints to their default values
965 *
966 * The @ref GLFW_RED_BITS, @ref GLFW_GREEN_BITS, @ref GLFW_BLUE_BITS, @ref
967 * GLFW_ALPHA_BITS and @ref GLFW_STENCIL_BITS hints are set to 8.
968 *
969 * The @ref GLFW_DEPTH_BITS hint is set to 24.
970 *
971 * The @ref GLFW_VISIBLE and @ref GLFW_RESIZABLE hints are set to 1.
972 *
973 * The @ref GLFW_CLIENT_API hint is set to @ref GLFW_OPENGL_API.
974 *
975 * The @ref GLFW_OPENGL_VERSION_MAJOR and @ref GLFW_OPENGL_VERSION_MINOR hints
976 * are set to 1 and 0, respectively.
977 *
978 * All other hints are set to 0.
979 *
980 * @ingroup window
981 *
982 * @sa glfwWindowHint
983 */
Camilla Berglund5df4df62012-10-22 02:59:05 +0200984GLFWAPI void glfwDefaultWindowHints(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100985
986/*! @brief Sets the specified window hint to the desired value.
987 * @param[in] target The window hint to set.
988 * @param[in] target The new value of the window hint.
989 * @ingroup window
990 *
991 * The @ref GLFW_RED_BITS, @ref GLFW_GREEN_BITS, @ref GLFW_BLUE_BITS, @ref
992 * GLFW_ALPHA_BITS, @ref GLFW_DEPTH_BITS and @ref GLFW_STENCIL_BITS hints
993 * specify the desired bit depths of the various components of the default
994 * framebuffer.
995 *
996 * The @ref GLFW_REFRESH_RATE hint specifies the desired monitor refresh rate
997 * for fullscreen windows.
998 *
999 * The @ref GLFW_ACCUM_RED_BITS, @ref GLFW_ACCUM_GREEN_BITS, @ref
1000 * GLFW_ACCUM_BLUE_BITS and @ref GLFW_ACCUM_ALPHA_BITS hints specify the
1001 * desired bit depths of the various components of the accumulation buffer.
1002 *
1003 * The @ref GLFW_AUX_BUFFERS hint specifies the desired number of auxiliary
1004 * buffers.
1005 *
1006 * The @ref GLFW_STEREO hint specifies whether to use stereoscopic rendering.
1007 * This is a hard constraint.
1008 *
1009 * The @ref GLFW_FSAA_SAMPLES hint specifies the desired number of samples to
1010 * use for multisampling.
1011 *
1012 * The @ref GLFW_CLIENT_API hint specifies which client API to create the
1013 * context for. Possible values are @ref GLFW_OPENGL_API and @ref
1014 * GLFW_OPENGL_ES_API. This is a hard constraint.
1015 *
1016 * The @ref GLFW_OPENGL_VERSION_MAJOR and @ref GLFW_OPENGL_VERSION_MINOR hints
1017 * specify the OpenGL version that the created context must be compatible with.
1018 *
1019 * These hints are @em not hard constraints, as they don't have to match
1020 * exactly, but @ref glfwCreateWindow will still fail if the resulting OpenGL
1021 * version is less than the one requested with hints. It is therefore
1022 * perfectly safe to use the default of version 1.0 for legacy code and you
1023 * will still get backwards-compatible contexts of version 3.0 and above when
1024 * available.
1025 *
1026 * The @ref GLFW_OPENGL_FORWARD_COMPAT hint specifies whether the OpenGL
1027 * context should be forward-compatible. This is a hard constraint.
1028 *
1029 * The @ref GLFW_OPENGL_DEBUG_CONTEXT hint specifies whether to create a debug
1030 * OpenGL context.
1031 *
1032 * The @ref GLFW_OPENGL_PROFILE hint specifies which OpenGL profile to create
1033 * the context for. Possible values are @ref GLFW_OPENGL_NO_PROFILE, @ref
1034 * GLFW_OPENGL_CORE_PROFILE and @ref GLFW_OPENGL_COMPAT_PROFILE. This is
1035 * a hard constraint.
1036 *
1037 * The @ref GLFW_OPENGL_ROBUSTNESS hint specifies the robustness strategy to be
1038 * used by the OpenGL context.
1039 *
1040 * The @ref GLFW_RESIZABLE hint specifies whether the window will be resizable
1041 * by the user. This hint is ignored for fullscreen windows.
1042 *
1043 * The @ref GLFW_VISIBLE hint specifies whether the window will be initially
1044 * visible. This hint is ignored for fullscreen windows.
1045 *
1046 * The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y hints specify the initial
1047 * position of the window. These hints are ignored for fullscreen windows.
1048 *
1049 * Some window hints are hard constraints. These must match the available
1050 * capabilities @em exactly for window and context creation to succeed. Hints
1051 * that are not hard constraints are matched as closely as possible, but the
1052 * resulting window and context may differ from what these hints requested.
1053 *
1054 * The following window hints are hard constraints:
1055 * @arg @ref GLFW_STEREO
1056 * @arg @ref GLFW_CLIENT_API
1057 * @arg @ref GLFW_OPENGL_FORWARD_COMPAT
1058 * @arg @ref GLFW_OPENGL_PROFILE
1059 *
1060 * @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 *
1103 * @sa glfwDestroyWindow
1104 */
Camilla Berglund2212cd92012-08-10 13:29:45 +02001105GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, int mode, const char* title, GLFWwindow share);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001106
1107/*! @brief Destroys the specified window and its context.
1108 * @param[in] window The window to destroy.
1109 * @ingroup window
1110 *
1111 * @note If the window's context is current on the main thread, it is
1112 * detached before being destroyed.
1113 *
1114 * @warning The window's context must not be current on any other thread.
1115 *
1116 * @sa glfwCreateWindow
1117 */
Camilla Berglundaff30d02012-08-06 17:56:41 +02001118GLFWAPI void glfwDestroyWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001119
1120/*! @brief Sets the title of the specified window.
1121 * @param[in] window The window whose title to change.
1122 * @param[in] title The UTF-8 encoded window title.
1123 * @ingroup window
1124 */
Camilla Berglunda3390982012-09-02 15:22:56 +02001125GLFWAPI void glfwSetWindowTitle(GLFWwindow window, const char* title);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001126
1127/*! @brief Retrieves the size of the client area of the specified window.
1128 * @param[in] window The window whose size to retrieve.
1129 * @param[out] width The width of the client area.
1130 * @param[out] height The height of the client area.
1131 * @ingroup window
1132 *
1133 * @sa glfwSetWindowSize
1134 */
Camilla Berglunda3390982012-09-02 15:22:56 +02001135GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001136
1137/*! @brief Sets the size of the client area of the specified window.
1138 * @param[in] window The window to resize.
1139 * @param[in] width The desired width of the specified window.
1140 * @param[in] height The desired height of the specified window.
1141 * @ingroup window
1142 *
1143 * @note The window manager may put limits on what window sizes are allowed.
1144 *
1145 * @note For fullscreen windows, this function selects and switches to the
1146 * resolution closest to the specified size, without destroying the window's
1147 * context.
1148 *
1149 * @sa glfwGetWindowSize
1150 */
Camilla Berglunda3390982012-09-02 15:22:56 +02001151GLFWAPI void glfwSetWindowSize(GLFWwindow window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001152
1153/*! @brief Iconifies the specified window.
1154 * @param[in] window The window to iconify.
1155 * @ingroup window
1156 *
1157 * @remarks If the window is already iconified, this function does nothing.
1158 *
1159 * @sa glfwRestoreWindow
1160 */
Camilla Berglund135194a2010-09-09 18:15:32 +02001161GLFWAPI void glfwIconifyWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001162
1163/*! @brief Restores the specified window.
1164 * @param[in] window The window to restore.
1165 * @ingroup window
1166 *
1167 * @remarks If the window is already restored, this function does nothing.
1168 *
1169 * @sa glfwIconifyWindow
1170 */
Camilla Berglund135194a2010-09-09 18:15:32 +02001171GLFWAPI void glfwRestoreWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001172
1173/*! @brief Makes the specified window visible.
1174 * @param[in] window The window to make visible.
1175 * @ingroup window
1176 *
1177 * @remarks If the window is already visible, this function does nothing.
1178 *
1179 * @sa glfwHideWindow
1180 */
Riku Salminen596132c2012-08-21 21:01:57 +03001181GLFWAPI void glfwShowWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001182
1183/*! @brief Hides the specified window.
1184 * @param[in] window The window to hide.
1185 * @ingroup window
1186 *
1187 * @remarks If the window is already hidden, this function does nothing.
1188 *
1189 * @sa glfwShowWindow
1190 */
Riku Salminen596132c2012-08-21 21:01:57 +03001191GLFWAPI void glfwHideWindow(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001192
1193/*! @brief Returns a property of the specified window.
1194 * @ingroup window
1195 */
1196GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param);
1197
1198/*! @brief Sets the user pointer of the specified window.
1199 * @param[in] window The window whose pointer to set.
1200 * @param[in] pointer The new value.
1201 * @ingroup window
1202 *
1203 * @sa glfwGetWindowUserPointer
1204 */
Camilla Berglund48f5a7e2010-09-09 22:44:38 +02001205GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001206
1207/*! @brief Returns the user pointer of the specified window.
1208 * @param[in] window The window whose pointer to return.
1209 * @ingroup window
1210 *
1211 * @sa glfwSetWindowUserPointer
1212 */
Camilla Berglund48f5a7e2010-09-09 22:44:38 +02001213GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001214
1215/*! @brief Sets the size callback for the specified window.
1216 * @param[in] window The window whose callback to set.
1217 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
1218 * callback.
1219 * @ingroup window
1220 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001221GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001222
1223/*! @brief Sets the close callback for the specified window.
1224 * @param[in] window The window whose callback to set.
1225 * @param[in] cbfun The new callback, or @c NULL to remove the currently set
1226 * callback.
1227 * @ingroup window
1228 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001229GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001230
1231/*! @brief Sets the refresh 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 glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001238
1239/*! @brief Sets the focus 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 glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001246
1247/*! @brief Sets the iconify 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 glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun);
Camilla Berglund135194a2010-09-09 18:15:32 +02001254
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001255/*! @brief Processes all pending events.
1256 * @ingroup window
1257 *
1258 * @sa glfwWaitEvents
1259 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001260GLFWAPI void glfwPollEvents(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001261
1262/*! @brief Waits until events are pending and processes them.
1263 * @ingroup window
1264 *
1265 * @sa glfwPollEvents
1266 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001267GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +02001268
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001269/*! @brief Returns the value of an input option for the specified window.
1270 * @param[in] window The window to query.
1271 * @param[in] mode One of the following:
1272 * @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
1273 * @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
1274 * @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
1275 * @arg @ref GLFW_KEY_REPEAT Sets whether key repeat is enabled.
1276 * @ingroup input
1277 *
1278 * @sa glfwSetInputMode
1279 */
1280GLFWAPI int glfwGetInputMode(GLFWwindow window, int mode);
1281
1282/*! @brief Sets an input option for the specified window.
1283 * @param[in] mode One of the following:
1284 * @arg @ref GLFW_CURSOR_MODE Sets the cursor mode.
1285 * @arg @ref GLFW_STICKY_KEYS Sets whether sticky keys are enabled.
1286 * @arg @ref GLFW_STICKY_MOUSE_BUTTONS Sets whether sticky mouse buttons are enabled.
1287 * @arg @ref GLFW_KEY_REPEAT Sets whether key repeat is enabled.
1288 * @ingroup input
1289 *
1290 * @sa glfwGetInputMode
1291 */
Camilla Berglund609c0082012-02-04 01:34:12 +01001292GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001293
1294/*! @brief Returns the last reported state of a keyboard key for the specified
1295 * window.
1296 * @param[in] window The desired window.
1297 * @param[in] key The desired @link keys keyboard key @endlink.
1298 * @return @ref GLFW_PRESS or @ref GLFW_RELEASE.
1299 * @ingroup input
1300 */
1301GLFWAPI int glfwGetKey(GLFWwindow window, int key);
1302
1303/*! @brief Returns the last reported state of a mouse button for the specified
1304 * window.
1305 * @param[in] window The desired window.
1306 * @param[in] key The desired @link buttons mouse buttons @endlink.
1307 * @return @ref GLFW_PRESS or @ref GLFW_RELEASE.
1308 * @ingroup input
1309 */
1310GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button);
1311
1312/*! @brief Retrieves the last reported cursor position, relative to the client
1313 * area of the window.
1314 * @param[in] window The desired window.
1315 * @param[out] xpos The cursor x-coordinate, relative to the left edge of the
1316 * client area, or @c NULL.
1317 * @param[out] ypos The cursor y-coordinate, relative to the to top edge of the
1318 * client area, or @c NULL.
1319 * @ingroup input
1320 *
1321 * @sa glfwSetCursorPos
1322 */
Camilla Berglundcef9dea2012-06-22 13:53:02 +02001323GLFWAPI void glfwGetCursorPos(GLFWwindow window, int* xpos, int* ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001324
1325/*! @brief Sets the position of the cursor, relative to the client area of the window.
1326 * @param[in] window The desired window.
1327 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
1328 * client area, or @c NULL.
1329 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
1330 * client area, or @c NULL.
1331 * @ingroup input
1332 *
Camilla Berglund14355d62012-11-22 17:04:44 +01001333 * @note The specified window must be focused.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001334 *
1335 * @sa glfwGetCursorPos
1336 */
Camilla Berglundcef9dea2012-06-22 13:53:02 +02001337GLFWAPI void glfwSetCursorPos(GLFWwindow window, int xpos, int ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001338
1339/*! @ingroup input
1340 */
Camilla Berglund4ef9aec2012-03-28 21:54:09 +02001341GLFWAPI void glfwGetScrollOffset(GLFWwindow window, double* xoffset, double* yoffset);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001342
1343/*! @brief Sets the key callback.
1344 * @param[in] cbfun The new key callback, or @c NULL to remove the currently
1345 * set callback.
1346 * @ingroup input
1347 *
1348 * @note The key callback deals with physical keys, with @link keys tokens
1349 * @endlink named after their use on the standard US keyboard layout. If you
1350 * want to input text, use the Unicode character callback instead.
1351 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001352GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001353
1354/*! @brief Sets the Unicode character callback.
1355 * @param[in] cbfun The new Unicode character callback, or @c NULL to remove
1356 * the currently set callback.
1357 * @ingroup input
1358 *
1359 * @note The Unicode character callback is for text input. If you want to know
1360 * whether a specific key was pressed or released, use the key callback.
1361 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001362GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001363
1364/*! @brief Sets the mouse button callback.
1365 * @param[in] cbfun The new mouse button callback, or @c NULL to remove the
1366 * currently set callback.
1367 * @ingroup input
1368 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001369GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001370
1371/*! @brief Sets the cursor position callback.
1372 * @param[in] cbfun The new cursor position callback, or @c NULL to remove the
1373 * currently set callback.
1374 * @ingroup input
1375 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001376GLFWAPI void glfwSetCursorPosCallback(GLFWwindow window, GLFWcursorposfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001377
1378/*! @brief Sets the cursor enter/exit callback.
1379 * @param[in] cbfun The new cursor enter/exit callback, or @c NULL to remove
1380 * the currently set callback.
1381 * @ingroup input
1382 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001383GLFWAPI void glfwSetCursorEnterCallback(GLFWwindow window, GLFWcursorenterfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001384
1385/*! @brief Sets the scroll callback.
1386 * @param[in] cbfun The new scroll callback, or @c NULL to remove the currently
1387 * set callback.
1388 * @ingroup input
1389 *
1390 * @note This receives all scrolling input, like that from a mouse wheel or
1391 * a touchpad scrolling area.
1392 */
Camilla Berglund18d71c22012-10-28 13:45:11 +01001393GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun);
Camilla Berglund3249f812010-09-07 17:34:51 +02001394
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001395/*! @brief Returns a property of the specified joystick.
1396 * @param[in] joy The joystick to query.
1397 * @param[in] param The property whose value to return.
1398 * @return The specified joystick's current value, or zero if the joystick is
1399 * not present.
1400 * @ingroup input
1401 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001402GLFWAPI int glfwGetJoystickParam(int joy, int param);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001403
1404/*! @brief Returns the values of axes of the specified joystick.
1405 * @param[in] joy The joystick to query.
1406 * @param[out] axes The array to hold the values.
1407 * @param[in] numaxes The size of the provided array.
1408 * @return The number of values written to @p axes.
1409 * @ingroup input
1410 */
Camilla Berglund2502e4d2012-08-29 18:31:12 +02001411GLFWAPI int glfwGetJoystickAxes(int joy, float* axes, int numaxes);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001412
1413/*! @brief Returns the values of buttons of the specified joystick.
1414 * @param[in] joy The joystick to query.
1415 * @param[out] buttons The array to hold the values.
1416 * @param[in] numbuttons The size of the provided array.
1417 * @return The number of values written to @p buttons.
1418 * @ingroup input
1419 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001420GLFWAPI int glfwGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons);
Camilla Berglund3249f812010-09-07 17:34:51 +02001421
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001422/*! @brief Sets the clipboard to the specified string.
1423 * @param[in] window The window that will own the clipboard contents.
1424 * @param[in] string A UTF-8 encoded string.
1425 * @ingroup clipboard
1426 *
1427 * @sa glfwGetClipboardString
1428 */
Camilla Berglund1214fa12012-04-09 16:03:14 +02001429GLFWAPI void glfwSetClipboardString(GLFWwindow window, const char* string);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001430
1431/*! @brief Retrieves the contents of the clipboard as a string.
1432 * @param[in] window The window that will request the clipboard contents.
1433 * @return The contents of the clipboard as a UTF-8 encoded string, or @c NULL
1434 * if that format was unavailable.
1435 * @ingroup clipboard
1436 *
1437 * @note The returned string is valid only until the next call to @ref
1438 * glfwGetClipboardString or @ref glfwSetClipboardString.
1439 *
1440 * @sa glfwSetClipboardString
1441 */
Camilla Berglundf8687122012-04-12 00:51:58 +02001442GLFWAPI const char* glfwGetClipboardString(GLFWwindow window);
Ralph Eastwood31c91542011-09-21 10:09:47 +01001443
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001444/*! @brief Retrieves the current value of the GLFW timer.
1445 * @return The current value, in seconds.
1446 * @ingroup time
1447 *
1448 * @remarks This function may be called from secondary threads.
1449 *
1450 * @remarks Unless the timer has been set using @ref glfwSetTime, the timer
1451 * measures time elapsed since GLFW was initialized.
1452 *
1453 * @note The resolution of the timer is system dependent.
1454 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001455GLFWAPI double glfwGetTime(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02001456
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001457/*! @brief Sets the GLFW timer.
1458 * @param[in] time The new value, in seconds.
1459 * @ingroup time
1460 *
1461 * @note The resolution of the timer is system dependent.
1462 */
1463GLFWAPI void glfwSetTime(double time);
1464
1465/*! @brief Makes the context of the specified window current for this thread.
1466 * @param[in] window The window whose context to make current, or @c NULL to
1467 * detach the current context.
1468 * @ingroup opengl
1469 *
1470 * @remarks This function may be called from secondary threads.
1471 *
1472 * @note A context may only be current for a single thread at a time.
1473 *
1474 * @sa glfwGetCurrentContext
1475 */
Camilla Berglundc1ab73b2011-07-27 16:01:27 +02001476GLFWAPI void glfwMakeContextCurrent(GLFWwindow window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001477
1478/*! @brief Returns the window whose context is current on this thread.
1479 * @return The window whose context is current, or @c NULL if no window's
1480 * context is current.
1481 * @ingroup opengl
1482 *
1483 * @remarks This function may be called from secondary threads.
1484 *
1485 * @sa glfwMakeContextCurrent
1486 */
Camilla Berglundc1ab73b2011-07-27 16:01:27 +02001487GLFWAPI GLFWwindow glfwGetCurrentContext(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001488
1489/*! @brief Swaps the front and back buffers of the specified window.
1490 * @param[in] The window whose buffers to swap.
1491 * @ingroup opengl
1492 *
1493 * @remarks This function may be called from secondary threads.
1494 *
1495 * @sa glfwSwapInterval
1496 */
1497GLFWAPI void glfwSwapBuffers(GLFWwindow window);
1498
1499/*! @brief Sets the swap interval for the current context.
1500 * @param[in] interval The minimum number of video frame periods to wait for
1501 * until the buffers are swapped by @ref glfwSwapBuffers.
1502 * @ingroup opengl
1503 *
1504 * @remarks This function may be called from secondary threads.
1505 *
1506 * @sa glfwSwapBuffers
1507 */
1508GLFWAPI void glfwSwapInterval(int interval);
1509
1510/*! @brief Checks whether the specified extension is available.
1511 * @param[in] extension The ASCII encoded name of the extension.
1512 * @return @c GL_TRUE if the extension is available, or @c FALSE otherwise.
1513 * @ingroup opengl
1514 *
1515 * @remarks This function may be called from secondary threads.
1516 *
1517 * @note This function checks not only the client API extension string, but
1518 * also any platform-specific context creation API extension strings.
1519 */
1520GLFWAPI int glfwExtensionSupported(const char* extension);
1521
1522/*! @brief Returns the address of the specified client API function for the
1523 * current context.
1524 * @param[in] procname The ASCII encoded name of the function.
1525 * @return The address of the function, or @c NULL if the function is
1526 * unavailable.
1527 * @ingroup opengl
1528 *
1529 * @remarks This function may be called from secondary threads.
1530 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02001531GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001532
1533/*! @brief Copies the desired parts of the state of one window's context to another.
1534 * @ingroup opengl
1535 *
1536 * @remarks This function may be called from secondary threads.
1537 */
1538GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
Camilla Berglund3249f812010-09-07 17:34:51 +02001539
Camilla Berglund3249f812010-09-07 17:34:51 +02001540
Camilla Berglund4afc67c2011-07-27 17:09:17 +02001541/*************************************************************************
1542 * Global definition cleanup
1543 *************************************************************************/
1544
1545/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
1546
Camilla Berglund4afc67c2011-07-27 17:09:17 +02001547#ifdef GLFW_WINGDIAPI_DEFINED
1548 #undef WINGDIAPI
1549 #undef GLFW_WINGDIAPI_DEFINED
1550#endif
1551
1552#ifdef GLFW_CALLBACK_DEFINED
1553 #undef CALLBACK
1554 #undef GLFW_CALLBACK_DEFINED
1555#endif
1556
1557/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
1558
1559
Camilla Berglund3249f812010-09-07 17:34:51 +02001560#ifdef __cplusplus
1561}
1562#endif
1563
Camilla Berglund36e54092010-11-09 02:58:35 +01001564#endif /* __glfw3_h__ */
Camilla Berglund3249f812010-09-07 17:34:51 +02001565