blob: b8a6cb86f544542b2d064c56880f809d6c410a62 [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 Berglundf8df91d2013-01-15 01:59:56 +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
Camilla Berglundbce2cd62012-11-22 16:38:24 +010042/*! @defgroup clipboard Clipboard support
43 */
Camilla Berglund3f5843f2012-12-13 02:22:39 +010044/*! @defgroup context Context handling
45 */
Camilla Berglundbce2cd62012-11-22 16:38:24 +010046/*! @defgroup error Error handling
47 */
48/*! @defgroup gamma Gamma ramp support
49 */
50/*! @defgroup init Initialization and version information
51 */
52/*! @defgroup input Input handling
53 */
Camilla Berglund5f68e122012-11-27 17:07:28 +010054/*! @defgroup monitor Monitor handling
55 */
Camilla Berglundbce2cd62012-11-22 16:38:24 +010056/*! @defgroup time Time input
57 */
58/*! @defgroup window Window handling
59 *
Camilla Berglund948cc042013-04-16 02:02:22 +020060 * This is the reference documentation for the window handling API, including
61 * creation, deletion and event polling. For more information, see the
62 * [article on window handling](@ref window).
Camilla Berglundbce2cd62012-11-22 16:38:24 +010063 */
Camilla Berglundbce2cd62012-11-22 16:38:24 +010064
65
66/*************************************************************************
Camilla Berglund3249f812010-09-07 17:34:51 +020067 * Global definitions
68 *************************************************************************/
69
Camilla Berglund3249f812010-09-07 17:34:51 +020070/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
71
Camilla Berglund06e7a962012-11-22 19:14:27 +010072/* Please report any problems that you find with your compiler, which may
Camilla Berglund3249f812010-09-07 17:34:51 +020073 * be solved in this section! There are several compilers that I have not
74 * been able to test this file with yet.
75 *
76 * First: If we are we on Windows, we want a single define for it (_WIN32)
77 * (Note: For Cygwin the compiler flag -mwin32 should be used, but to
78 * make sure that things run smoothly for Cygwin users, we add __CYGWIN__
79 * to the list of "valid Win32 identifiers", which removes the need for
80 * -mwin32)
81 */
82#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
83 #define _WIN32
84#endif /* _WIN32 */
85
86/* In order for extension support to be portable, we need to define an
87 * OpenGL function call method. We use the keyword APIENTRY, which is
88 * defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
89 */
90#ifndef APIENTRY
91 #ifdef _WIN32
92 #define APIENTRY __stdcall
93 #else
94 #define APIENTRY
95 #endif
Camilla Berglund3249f812010-09-07 17:34:51 +020096#endif /* APIENTRY */
97
Camilla Berglund3249f812010-09-07 17:34:51 +020098/* The following three defines are here solely to make some Windows-based
99 * <GL/gl.h> files happy. Theoretically we could include <windows.h>, but
100 * it has the major drawback of severely polluting our namespace.
101 */
102
103/* Under Windows, we need WINGDIAPI defined */
104#if !defined(WINGDIAPI) && defined(_WIN32)
105 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
106 /* Microsoft Visual C++, Borland C++ Builder and Pelles C */
107 #define WINGDIAPI __declspec(dllimport)
108 #elif defined(__LCC__)
109 /* LCC-Win32 */
110 #define WINGDIAPI __stdcall
111 #else
112 /* Others (e.g. MinGW, Cygwin) */
113 #define WINGDIAPI extern
114 #endif
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200115 #define GLFW_WINGDIAPI_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200116#endif /* WINGDIAPI */
117
118/* Some <GL/glu.h> files also need CALLBACK defined */
119#if !defined(CALLBACK) && defined(_WIN32)
120 #if defined(_MSC_VER)
121 /* Microsoft Visual C++ */
122 #if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
123 #define CALLBACK __stdcall
124 #else
125 #define CALLBACK
126 #endif
127 #else
128 /* Other Windows compilers */
129 #define CALLBACK __stdcall
130 #endif
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200131 #define GLFW_CALLBACK_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200132#endif /* CALLBACK */
133
Camilla Berglund3c912cb2012-08-02 21:25:00 +0200134/* Most <GL/glu.h> variants on Windows need wchar_t */
135#if defined(_WIN32)
136 #include <stddef.h>
137#endif
Camilla Berglund3249f812010-09-07 17:34:51 +0200138
139
140/* ---------------- GLFW related system specific defines ----------------- */
141
Camilla Berglundcc5d7cd2012-03-25 17:43:02 +0200142#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
143 #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
144#endif
145
Camilla Berglund2588c9b2012-03-25 17:40:30 +0200146#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
Camilla Berglund3249f812010-09-07 17:34:51 +0200147
148 /* We are building a Win32 DLL */
Camilla Berglund2955cd32010-11-17 15:42:55 +0100149 #define GLFWAPI __declspec(dllexport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200150
151#elif defined(_WIN32) && defined(GLFW_DLL)
152
153 /* We are calling a Win32 DLL */
154 #if defined(__LCC__)
Camilla Berglund2955cd32010-11-17 15:42:55 +0100155 #define GLFWAPI extern
Camilla Berglund3249f812010-09-07 17:34:51 +0200156 #else
Camilla Berglund2955cd32010-11-17 15:42:55 +0100157 #define GLFWAPI __declspec(dllimport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200158 #endif
159
John Bartholomew93f4eff2013-05-01 13:08:09 +0100160#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
161
162 #define GLFWAPI __attribute__((visibility("default")))
163
Camilla Berglund3249f812010-09-07 17:34:51 +0200164#else
165
166 /* We are either building/calling a static lib or we are non-win32 */
167 #define GLFWAPI
168
169#endif
170
171/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
172
Camilla Berglund3f5843f2012-12-13 02:22:39 +0100173/* Include the chosen client API headers.
Camilla Berglund3249f812010-09-07 17:34:51 +0200174 */
175#if defined(__APPLE_CC__)
Camilla Berglund410a4e22012-09-27 22:28:04 +0200176 #if defined(GLFW_INCLUDE_GLCOREARB)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200177 #include <OpenGL/gl3.h>
Camilla Berglund378c75d2013-03-13 20:44:00 +0100178 #elif !defined(GLFW_INCLUDE_NONE)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200179 #define GL_GLEXT_LEGACY
180 #include <OpenGL/gl.h>
181 #endif
Camilla Berglund22134502012-06-05 23:55:10 +0200182 #if defined(GLFW_INCLUDE_GLU)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200183 #include <OpenGL/glu.h>
184 #endif
Camilla Berglund3249f812010-09-07 17:34:51 +0200185#else
Camilla Berglund410a4e22012-09-27 22:28:04 +0200186 #if defined(GLFW_INCLUDE_GLCOREARB)
187 #include <GL/glcorearb.h>
Jari Vetoniemi38c4a8e2012-11-10 00:08:44 +0200188 #elif defined(GLFW_INCLUDE_ES1)
189 #include <GLES/gl.h>
Camilla Berglund3fd17742012-07-19 23:20:47 +0200190 #elif defined(GLFW_INCLUDE_ES2)
191 #include <GLES2/gl2.h>
Camilla Berglunda933d8c2013-02-14 19:28:59 +0100192 #elif defined(GLFW_INCLUDE_ES3)
193 #include <GLES3/gl3.h>
Camilla Berglund378c75d2013-03-13 20:44:00 +0100194 #elif !defined(GLFW_INCLUDE_NONE)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200195 #include <GL/gl.h>
196 #endif
Camilla Berglund22134502012-06-05 23:55:10 +0200197 #if defined(GLFW_INCLUDE_GLU)
Camilla Berglundd88789e2011-09-16 04:44:40 +0200198 #include <GL/glu.h>
199 #endif
Camilla Berglund3249f812010-09-07 17:34:51 +0200200#endif
201
202
203/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100204 * GLFW API tokens
Camilla Berglund3249f812010-09-07 17:34:51 +0200205 *************************************************************************/
206
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100207/*! @name GLFW version macros
208 * @{ */
209/*! @brief The major version number of the GLFW library.
210 *
211 * This is incremented when the API is changed in non-compatible ways.
212 * @ingroup init
213 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100214#define GLFW_VERSION_MAJOR 3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100215/*! @brief The minor version number of the GLFW library.
216 *
217 * This is incremented when features are added to the API but it remains
218 * backward-compatible.
219 * @ingroup init
220 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100221#define GLFW_VERSION_MINOR 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100222/*! @brief The revision number of the GLFW library.
223 *
224 * This is incremented when a bug fix release is made that does not contain any
225 * API changes.
226 * @ingroup init
227 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100228#define GLFW_VERSION_REVISION 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100229/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200230
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100231/*! @name Key and button actions
232 * @{ */
233/*! @brief The key or button was released.
234 * @ingroup input
235 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100236#define GLFW_RELEASE 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100237/*! @brief The key or button was pressed.
238 * @ingroup input
239 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100240#define GLFW_PRESS 1
Camilla Berglund253e0d62013-01-12 17:06:35 +0100241/*! @brief The key was held down until it repeated.
242 * @ingroup input
243 */
244#define GLFW_REPEAT 2
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100245/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200246
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200247/*! @defgroup keys Keyboard keys
248 *
249 * These key codes are inspired by the *USB HID Usage Tables v1.12* (p. 53-60),
Marcusc0cb4c22011-01-02 11:18:14 +0100250 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
251 * put in the 256+ range).
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200252 *
Marcusc0cb4c22011-01-02 11:18:14 +0100253 * The naming of the key codes follow these rules:
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200254 * - The US keyboard layout is used
Marcusc0cb4c22011-01-02 11:18:14 +0100255 * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200256 * "3", etc.)
Marcusc0cb4c22011-01-02 11:18:14 +0100257 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200258 * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
259 * correspond to the Unicode standard (usually for brevity)
260 * - Keys that lack a clear US mapping are named "WORLD_x"
Marcusc0cb4c22011-01-02 11:18:14 +0100261 * - For non-printable keys, custom names are used (e.g. "F4",
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200262 * "BACKSPACE", etc.)
263 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100264 * @ingroup input
265 * @{
266 */
267
Marcusc0cb4c22011-01-02 11:18:14 +0100268/* Printable keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100269#define GLFW_KEY_SPACE 32
270#define GLFW_KEY_APOSTROPHE 39 /* ' */
271#define GLFW_KEY_COMMA 44 /* , */
272#define GLFW_KEY_MINUS 45 /* - */
273#define GLFW_KEY_PERIOD 46 /* . */
274#define GLFW_KEY_SLASH 47 /* / */
275#define GLFW_KEY_0 48
276#define GLFW_KEY_1 49
277#define GLFW_KEY_2 50
278#define GLFW_KEY_3 51
279#define GLFW_KEY_4 52
280#define GLFW_KEY_5 53
281#define GLFW_KEY_6 54
282#define GLFW_KEY_7 55
283#define GLFW_KEY_8 56
284#define GLFW_KEY_9 57
285#define GLFW_KEY_SEMICOLON 59 /* ; */
286#define GLFW_KEY_EQUAL 61 /* = */
287#define GLFW_KEY_A 65
288#define GLFW_KEY_B 66
289#define GLFW_KEY_C 67
290#define GLFW_KEY_D 68
291#define GLFW_KEY_E 69
292#define GLFW_KEY_F 70
293#define GLFW_KEY_G 71
294#define GLFW_KEY_H 72
295#define GLFW_KEY_I 73
296#define GLFW_KEY_J 74
297#define GLFW_KEY_K 75
298#define GLFW_KEY_L 76
299#define GLFW_KEY_M 77
300#define GLFW_KEY_N 78
301#define GLFW_KEY_O 79
302#define GLFW_KEY_P 80
303#define GLFW_KEY_Q 81
304#define GLFW_KEY_R 82
305#define GLFW_KEY_S 83
306#define GLFW_KEY_T 84
307#define GLFW_KEY_U 85
308#define GLFW_KEY_V 86
309#define GLFW_KEY_W 87
310#define GLFW_KEY_X 88
311#define GLFW_KEY_Y 89
312#define GLFW_KEY_Z 90
313#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
314#define GLFW_KEY_BACKSLASH 92 /* \ */
315#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
316#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
317#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
318#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
Marcusc0cb4c22011-01-02 11:18:14 +0100319
320/* Function keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100321#define GLFW_KEY_ESCAPE 256
322#define GLFW_KEY_ENTER 257
323#define GLFW_KEY_TAB 258
324#define GLFW_KEY_BACKSPACE 259
325#define GLFW_KEY_INSERT 260
326#define GLFW_KEY_DELETE 261
327#define GLFW_KEY_RIGHT 262
328#define GLFW_KEY_LEFT 263
329#define GLFW_KEY_DOWN 264
330#define GLFW_KEY_UP 265
331#define GLFW_KEY_PAGE_UP 266
332#define GLFW_KEY_PAGE_DOWN 267
333#define GLFW_KEY_HOME 268
334#define GLFW_KEY_END 269
335#define GLFW_KEY_CAPS_LOCK 280
336#define GLFW_KEY_SCROLL_LOCK 281
337#define GLFW_KEY_NUM_LOCK 282
338#define GLFW_KEY_PRINT_SCREEN 283
339#define GLFW_KEY_PAUSE 284
340#define GLFW_KEY_F1 290
341#define GLFW_KEY_F2 291
342#define GLFW_KEY_F3 292
343#define GLFW_KEY_F4 293
344#define GLFW_KEY_F5 294
345#define GLFW_KEY_F6 295
346#define GLFW_KEY_F7 296
347#define GLFW_KEY_F8 297
348#define GLFW_KEY_F9 298
349#define GLFW_KEY_F10 299
350#define GLFW_KEY_F11 300
351#define GLFW_KEY_F12 301
352#define GLFW_KEY_F13 302
353#define GLFW_KEY_F14 303
354#define GLFW_KEY_F15 304
355#define GLFW_KEY_F16 305
356#define GLFW_KEY_F17 306
357#define GLFW_KEY_F18 307
358#define GLFW_KEY_F19 308
359#define GLFW_KEY_F20 309
360#define GLFW_KEY_F21 310
361#define GLFW_KEY_F22 311
362#define GLFW_KEY_F23 312
363#define GLFW_KEY_F24 313
364#define GLFW_KEY_F25 314
365#define GLFW_KEY_KP_0 320
366#define GLFW_KEY_KP_1 321
367#define GLFW_KEY_KP_2 322
368#define GLFW_KEY_KP_3 323
369#define GLFW_KEY_KP_4 324
370#define GLFW_KEY_KP_5 325
371#define GLFW_KEY_KP_6 326
372#define GLFW_KEY_KP_7 327
373#define GLFW_KEY_KP_8 328
374#define GLFW_KEY_KP_9 329
375#define GLFW_KEY_KP_DECIMAL 330
376#define GLFW_KEY_KP_DIVIDE 331
377#define GLFW_KEY_KP_MULTIPLY 332
378#define GLFW_KEY_KP_SUBTRACT 333
379#define GLFW_KEY_KP_ADD 334
380#define GLFW_KEY_KP_ENTER 335
381#define GLFW_KEY_KP_EQUAL 336
382#define GLFW_KEY_LEFT_SHIFT 340
383#define GLFW_KEY_LEFT_CONTROL 341
384#define GLFW_KEY_LEFT_ALT 342
385#define GLFW_KEY_LEFT_SUPER 343
386#define GLFW_KEY_RIGHT_SHIFT 344
387#define GLFW_KEY_RIGHT_CONTROL 345
388#define GLFW_KEY_RIGHT_ALT 346
389#define GLFW_KEY_RIGHT_SUPER 347
390#define GLFW_KEY_MENU 348
391#define GLFW_KEY_LAST GLFW_KEY_MENU
Marcusc0cb4c22011-01-02 11:18:14 +0100392
393/* GLFW 2.x key name aliases (deprecated) */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100394#define GLFW_KEY_ESC GLFW_KEY_ESCAPE
395#define GLFW_KEY_DEL GLFW_KEY_DELETE
396#define GLFW_KEY_PAGEUP GLFW_KEY_PAGE_UP
397#define GLFW_KEY_PAGEDOWN GLFW_KEY_PAGE_DOWN
398#define GLFW_KEY_KP_NUM_LOCK GLFW_KEY_NUM_LOCK
399#define GLFW_KEY_LCTRL GLFW_KEY_LEFT_CONTROL
400#define GLFW_KEY_LSHIFT GLFW_KEY_LEFT_SHIFT
401#define GLFW_KEY_LALT GLFW_KEY_LEFT_ALT
402#define GLFW_KEY_LSUPER GLFW_KEY_LEFT_SUPER
403#define GLFW_KEY_RCTRL GLFW_KEY_RIGHT_CONTROL
404#define GLFW_KEY_RSHIFT GLFW_KEY_RIGHT_SHIFT
405#define GLFW_KEY_RALT GLFW_KEY_RIGHT_ALT
406#define GLFW_KEY_RSUPER GLFW_KEY_RIGHT_SUPER
Camilla Berglund3249f812010-09-07 17:34:51 +0200407
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100408/*! @} */
409
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200410/*! @defgroup mods Modifier key flags
411 * @ingroup input
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100412 * @{ */
413
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200414/*! @brief If this bit is set one or more Shift keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100415 */
416#define GLFW_MOD_SHIFT 0x0001
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200417/*! @brief If this bit is set one or more Control keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100418 */
Camilla Berglund3bcffba2013-05-23 14:11:05 +0200419#define GLFW_MOD_CONTROL 0x0002
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200420/*! @brief If this bit is set one or more Alt keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100421 */
422#define GLFW_MOD_ALT 0x0004
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200423/*! @brief If this bit is set one or more Super keys were held down.
Noel Cowereff85f92013-05-23 13:22:27 +0200424 */
425#define GLFW_MOD_SUPER 0x0008
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100426
427/*! @} */
428
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100429/*! @defgroup buttons Mouse buttons
430 * @ingroup input
431 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100432#define GLFW_MOUSE_BUTTON_1 0
433#define GLFW_MOUSE_BUTTON_2 1
434#define GLFW_MOUSE_BUTTON_3 2
435#define GLFW_MOUSE_BUTTON_4 3
436#define GLFW_MOUSE_BUTTON_5 4
437#define GLFW_MOUSE_BUTTON_6 5
438#define GLFW_MOUSE_BUTTON_7 6
439#define GLFW_MOUSE_BUTTON_8 7
440#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
441#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
442#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
443#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100444/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200445
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100446/*! @defgroup joysticks Joysticks
447 * @ingroup input
448 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100449#define GLFW_JOYSTICK_1 0
450#define GLFW_JOYSTICK_2 1
451#define GLFW_JOYSTICK_3 2
452#define GLFW_JOYSTICK_4 3
453#define GLFW_JOYSTICK_5 4
454#define GLFW_JOYSTICK_6 5
455#define GLFW_JOYSTICK_7 6
456#define GLFW_JOYSTICK_8 7
457#define GLFW_JOYSTICK_9 8
458#define GLFW_JOYSTICK_10 9
459#define GLFW_JOYSTICK_11 10
460#define GLFW_JOYSTICK_12 11
461#define GLFW_JOYSTICK_13 12
462#define GLFW_JOYSTICK_14 13
463#define GLFW_JOYSTICK_15 14
464#define GLFW_JOYSTICK_16 15
465#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100466/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200467
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100468/*! @defgroup errors Error codes
469 * @ingroup error
470 * @{ */
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100471/*! @brief GLFW has not been initialized.
472 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200473#define GLFW_NOT_INITIALIZED 0x00010001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100474/*! @brief No context is current for this thread.
475 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200476#define GLFW_NO_CURRENT_CONTEXT 0x00010002
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100477/*! @brief One of the enum parameters for the function was given an invalid
478 * enum.
479 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200480#define GLFW_INVALID_ENUM 0x00010003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100481/*! @brief One of the parameters for the function was given an invalid value.
482 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200483#define GLFW_INVALID_VALUE 0x00010004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100484/*! @brief A memory allocation failed.
485 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200486#define GLFW_OUT_OF_MEMORY 0x00010005
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100487/*! @brief GLFW could not find support for the requested client API on the
488 * system.
489 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200490#define GLFW_API_UNAVAILABLE 0x00010006
Camilla Berglund3f5843f2012-12-13 02:22:39 +0100491/*! @brief The requested client API version is not available.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100492 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200493#define GLFW_VERSION_UNAVAILABLE 0x00010007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100494/*! @brief A platform-specific error occurred that does not match any of the
495 * more specific categories.
496 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200497#define GLFW_PLATFORM_ERROR 0x00010008
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100498/*! @brief The clipboard did not contain data in the requested format.
499 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200500#define GLFW_FORMAT_UNAVAILABLE 0x00010009
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100501/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200502
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100503#define GLFW_FOCUSED 0x00020001
504#define GLFW_ICONIFIED 0x00020002
Camilla Berglund393e4392013-05-27 22:16:59 +0200505#define GLFW_RESIZABLE 0x00020003
506#define GLFW_VISIBLE 0x00020004
507#define GLFW_DECORATED 0x00020005
Camilla Berglund2c091572010-09-09 21:09:11 +0200508
Camilla Berglund393e4392013-05-27 22:16:59 +0200509#define GLFW_CONTEXT_REVISION 0x00021001
510#define GLFW_RED_BITS 0x00021002
511#define GLFW_GREEN_BITS 0x00021003
512#define GLFW_BLUE_BITS 0x00021004
513#define GLFW_ALPHA_BITS 0x00021005
514#define GLFW_DEPTH_BITS 0x00021006
515#define GLFW_STENCIL_BITS 0x00021007
516#define GLFW_ACCUM_RED_BITS 0x00021008
517#define GLFW_ACCUM_GREEN_BITS 0x00021009
518#define GLFW_ACCUM_BLUE_BITS 0x0002100A
519#define GLFW_ACCUM_ALPHA_BITS 0x0002100B
520#define GLFW_AUX_BUFFERS 0x0002100C
521#define GLFW_STEREO 0x0002100D
522#define GLFW_SAMPLES 0x0002100E
523#define GLFW_SRGB_CAPABLE 0x0002100F
Camilla Berglunddeb0b3d2012-12-02 21:00:15 +0100524
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100525#define GLFW_CLIENT_API 0x00022000
526#define GLFW_CONTEXT_VERSION_MAJOR 0x00022001
527#define GLFW_CONTEXT_VERSION_MINOR 0x00022002
528#define GLFW_CONTEXT_ROBUSTNESS 0x00022003
529#define GLFW_OPENGL_FORWARD_COMPAT 0x00022004
530#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022005
531#define GLFW_OPENGL_PROFILE 0x00022006
532
Camilla Berglund393e4392013-05-27 22:16:59 +0200533#define GLFW_OPENGL_API 0x00030001
534#define GLFW_OPENGL_ES_API 0x00030002
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100535
Camilla Berglund393e4392013-05-27 22:16:59 +0200536#define GLFW_NO_ROBUSTNESS 0
537#define GLFW_NO_RESET_NOTIFICATION 0x00031001
538#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100539
Camilla Berglund393e4392013-05-27 22:16:59 +0200540#define GLFW_OPENGL_NO_PROFILE 0
541#define GLFW_OPENGL_CORE_PROFILE 0x00032001
542#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100543
Camilla Berglund393e4392013-05-27 22:16:59 +0200544#define GLFW_CURSOR 0x00033001
545#define GLFW_STICKY_KEYS 0x00033002
546#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100547
Camilla Berglund393e4392013-05-27 22:16:59 +0200548#define GLFW_CURSOR_NORMAL 0x00034001
549#define GLFW_CURSOR_HIDDEN 0x00034002
550#define GLFW_CURSOR_DISABLED 0x00034003
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100551
Camilla Berglund393e4392013-05-27 22:16:59 +0200552#define GLFW_CONNECTED 0x00040001
553#define GLFW_DISCONNECTED 0x00040002
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100554
Camilla Berglund97387282011-10-06 23:28:56 +0200555
Camilla Berglund3249f812010-09-07 17:34:51 +0200556/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100557 * GLFW API types
Camilla Berglund3249f812010-09-07 17:34:51 +0200558 *************************************************************************/
559
Camilla Berglund3f5843f2012-12-13 02:22:39 +0100560/*! @brief Client API function pointer type.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200561 *
562 * Generic function pointer used for returning client API function pointers
563 * without forcing a cast from a regular pointer.
564 *
Camilla Berglund3f5843f2012-12-13 02:22:39 +0100565 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100566 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +0200567typedef void (*GLFWglproc)(void);
568
Camilla Berglunddba2d802013-01-17 23:06:56 +0100569/*! @brief Opaque monitor object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200570 *
571 * Opaque monitor object.
572 *
Camilla Berglund41bc0d12012-11-27 16:55:04 +0100573 * @ingroup monitor
574 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100575typedef struct GLFWmonitor GLFWmonitor;
Camilla Berglunde0ce9202012-08-29 20:39:05 +0200576
Camilla Berglunddba2d802013-01-17 23:06:56 +0100577/*! @brief Opaque window object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200578 *
579 * Opaque window object.
580 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100581 * @ingroup window
582 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100583typedef struct GLFWwindow GLFWwindow;
Camilla Berglund135194a2010-09-09 18:15:32 +0200584
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100585/*! @brief The function signature for error callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200586 *
587 * This is the function signature for error callback functions.
588 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100589 * @param[in] error An [error code](@ref errors).
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100590 * @param[in] description A UTF-8 encoded string describing the error.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100591 *
592 * @sa glfwSetErrorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100593 *
594 * @ingroup error
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100595 */
Camilla Berglund897558f2011-03-07 13:34:58 +0100596typedef void (* GLFWerrorfun)(int,const char*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100597
Camilla Berglund1a3d47d2012-11-30 13:56:42 +0100598/*! @brief The function signature for window position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200599 *
600 * This is the function signature for window position callback functions.
601 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +0100602 * @param[in] window The window that the user moved.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200603 * @param[in] xpos The new x-coordinate, in screen coordinates, of the
604 * upper-left corner of the client area of the window.
605 * @param[in] ypos The new y-coordinate, in screen coordinates, of the
606 * upper-left corner of the client area of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100607 *
608 * @sa glfwSetWindowPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100609 *
610 * @ingroup window
Camilla Berglund1a3d47d2012-11-30 13:56:42 +0100611 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100612typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +0100613
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100614/*! @brief The function signature for window resize callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200615 *
616 * This is the function signature for window size callback functions.
617 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100618 * @param[in] window The window that the user resized.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200619 * @param[in] width The new width, in screen coordinates, of the window.
620 * @param[in] height The new height, in screen coordinates, of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100621 *
622 * @sa glfwSetWindowSizeCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100623 *
624 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100625 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100626typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100627
628/*! @brief The function signature for window close callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200629 *
630 * This is the function signature for window close callback functions.
631 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100632 * @param[in] window The window that the user attempted to close.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100633 *
634 * @sa glfwSetWindowCloseCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100635 *
636 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100637 */
Camilla Berglund64afb192013-03-06 23:29:37 +0100638typedef void (* GLFWwindowclosefun)(GLFWwindow*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100639
640/*! @brief The function signature for window content refresh callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200641 *
642 * This is the function signature for window refresh callback functions.
643 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100644 * @param[in] window The window whose content needs to be refreshed.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100645 *
646 * @sa glfwSetWindowRefreshCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100647 *
648 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100649 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100650typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100651
652/*! @brief The function signature for window focus/defocus callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200653 *
654 * This is the function signature for window focus callback functions.
655 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100656 * @param[in] window The window that was focused or defocused.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100657 * @param[in] focused `GL_TRUE` if the window was focused, or `GL_FALSE` if
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100658 * it was defocused.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100659 *
660 * @sa glfwSetWindowFocusCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100661 *
662 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100663 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100664typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100665
Camilla Berglund06e7a962012-11-22 19:14:27 +0100666/*! @brief The function signature for window iconify/restore callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200667 *
668 * This is the function signature for window iconify/restore callback
669 * functions.
670 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100671 * @param[in] window The window that was iconified or restored.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100672 * @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100673 * if it was restored.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100674 *
675 * @sa glfwSetWindowIconifyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100676 *
677 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100678 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100679typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100680
681/*! @brief The function signature for mouse button callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200682 *
683 * This is the function signature for mouse button callback functions.
684 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100685 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100686 * @param[in] button The [mouse button](@ref buttons) that was pressed or
687 * released.
688 * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200689 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
690 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100691 *
692 * @sa glfwSetMouseButtonCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100693 *
694 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100695 */
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100696typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100697
698/*! @brief The function signature for cursor position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200699 *
700 * This is the function signature for cursor position callback functions.
701 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100702 * @param[in] window The window that received the event.
Camilla Berglund52f718d2013-02-12 12:01:12 +0100703 * @param[in] xpos The new x-coordinate of the cursor.
704 * @param[in] ypos The new y-coordinate of the cursor.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100705 *
706 * @sa glfwSetCursorPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100707 *
708 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100709 */
Camilla Berglund129e94d2013-04-04 16:16:21 +0200710typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100711
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200712/*! @brief The function signature for cursor enter/leave callbacks.
713 *
714 * This is the function signature for cursor enter/leave callback functions.
715 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100716 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100717 * @param[in] entered `GL_TRUE` if the cursor entered the window's client
718 * area, or `GL_FALSE` if it left it.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100719 *
720 * @sa glfwSetCursorEnterCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100721 *
722 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100723 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100724typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100725
726/*! @brief The function signature for scroll callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200727 *
728 * This is the function signature for scroll callback functions.
729 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100730 * @param[in] window The window that received the event.
Camilla Berglund52f718d2013-02-12 12:01:12 +0100731 * @param[in] xpos The scroll offset along the x-axis.
732 * @param[in] ypos The scroll offset along the y-axis.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100733 *
734 * @sa glfwSetScrollCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100735 *
736 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100737 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100738typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100739
740/*! @brief The function signature for keyboard key callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200741 *
742 * This is the function signature for keyboard key callback functions.
743 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100744 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100745 * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
Camilla Berglund253e0d62013-01-12 17:06:35 +0100746 * @param[in] action @ref GLFW_PRESS, @ref GLFW_RELEASE or @ref GLFW_REPEAT.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200747 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
748 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100749 *
750 * @sa glfwSetKeyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100751 *
752 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100753 */
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100754typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100755
756/*! @brief The function signature for Unicode character callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200757 *
758 * This is the function signature for Unicode character callback functions.
759 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100760 * @param[in] window The window that received the event.
761 * @param[in] character The Unicode code point of the character.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100762 *
763 * @sa glfwSetCharCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100764 *
765 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100766 */
Camilla Berglund182e0af2013-02-25 17:02:28 +0100767typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
Camilla Berglund5f68e122012-11-27 17:07:28 +0100768
769/*! @brief The function signature for monitor configuration callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200770 *
771 * This is the function signature for monitor configuration callback functions.
772 *
Camilla Berglund5f68e122012-11-27 17:07:28 +0100773 * @param[in] monitor The monitor that was connected or disconnected.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100774 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100775 *
776 * @sa glfwSetMonitorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +0100777 *
778 * @ingroup monitor
Camilla Berglund5f68e122012-11-27 17:07:28 +0100779 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100780typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
Camilla Berglund897558f2011-03-07 13:34:58 +0100781
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200782/*! @brief Video mode type.
783 *
784 * This describes a single video mode.
785 *
786 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100787 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200788typedef struct
789{
Camilla Berglundc1594112013-05-27 22:29:06 +0200790 /*! The width, in pixels, of the video mode.
791 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200792 int width;
Camilla Berglundc1594112013-05-27 22:29:06 +0200793 /*! The height, in pixels, of the video mode.
794 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200795 int height;
Camilla Berglundc1594112013-05-27 22:29:06 +0200796 /*! The bit depth of the red channel of the video mode.
797 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200798 int redBits;
Camilla Berglundc1594112013-05-27 22:29:06 +0200799 /*! The bit depth of the green channel of the video mode.
800 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200801 int greenBits;
Camilla Berglundc1594112013-05-27 22:29:06 +0200802 /*! The bit depth of the blue channel of the video mode.
803 */
Camilla Berglund2e8446f2013-04-11 01:31:00 +0200804 int blueBits;
Camilla Berglund3249f812010-09-07 17:34:51 +0200805} GLFWvidmode;
806
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100807/*! @brief Gamma ramp.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200808 *
809 * This describes the gamma ramp for a monitor.
810 *
811 * @sa glfwGetGammaRamp glfwSetGammaRamp
812 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100813 * @ingroup gamma
814 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200815typedef struct
816{
Camilla Berglundc1594112013-05-27 22:29:06 +0200817 /*! An array of value describing the response of the red channel.
818 */
Camilla Berglund5d308db2013-05-19 15:46:44 +0200819 unsigned short* red;
Camilla Berglundc1594112013-05-27 22:29:06 +0200820 /*! An array of value describing the response of the green channel.
821 */
Camilla Berglund5d308db2013-05-19 15:46:44 +0200822 unsigned short* green;
Camilla Berglundc1594112013-05-27 22:29:06 +0200823 /*! An array of value describing the response of the blue channel.
824 */
Camilla Berglund5d308db2013-05-19 15:46:44 +0200825 unsigned short* blue;
Camilla Berglundc1594112013-05-27 22:29:06 +0200826 /*! The number of elements in each array.
827 */
Camilla Berglund5d308db2013-05-19 15:46:44 +0200828 unsigned int size;
Camilla Berglund2630d492010-10-13 04:04:43 +0200829} GLFWgammaramp;
830
Camilla Berglund3249f812010-09-07 17:34:51 +0200831
832/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100833 * GLFW API functions
Camilla Berglund3249f812010-09-07 17:34:51 +0200834 *************************************************************************/
835
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100836/*! @brief Initializes the GLFW library.
837 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100838 * This function initializes the GLFW library. Before most GLFW functions can
839 * be used, GLFW must be initialized, and before a program terminates GLFW
840 * should be terminated in order to free any resources allocated during or
841 * after initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100842 *
Camilla Berglund23f61762013-03-12 19:53:29 +0100843 * If this function fails, it calls @ref glfwTerminate before returning. If it
844 * succeeds, you should call @ref glfwTerminate before the program exits.
845 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100846 * Additional calls to this function after successful initialization but before
847 * termination will succeed but will do nothing.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100848 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100849 * @return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100850 *
Camilla Berglund401033c2013-03-12 19:17:07 +0100851 * @par New in GLFW 3
852 * This function no longer registers @ref glfwTerminate with `atexit`.
853 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +0100854 * @note This function may only be called from the main thread.
855 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100856 * @note This function may take several seconds to complete on some systems,
857 * while on other systems it may take only a fraction of a second to complete.
858 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100859 * @note **Mac OS X:** This function will change the current directory of the
860 * application to the `Contents/Resources` subdirectory of the application's
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100861 * bundle, if present.
862 *
863 * @sa glfwTerminate
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100864 *
865 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100866 */
867GLFWAPI int glfwInit(void);
868
869/*! @brief Terminates the GLFW library.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100870 *
Camilla Berglund23f61762013-03-12 19:53:29 +0100871 * This function destroys all remaining windows, frees any allocated resources
872 * and sets the library to an uninitialized state. Once this is called, you
873 * must again call @ref glfwInit successfully before you will be able to use
874 * most GLFW functions.
875 *
876 * If GLFW has been successfully initialized, this function should be called
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100877 * before the program exits. If initialization fails, there is no need to call
878 * this function, as it is called by @ref glfwInit before it returns failure.
Camilla Berglund23f61762013-03-12 19:53:29 +0100879 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100880 * @remarks This function may be called before @ref glfwInit.
881 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +0100882 * @note This function may only be called from the main thread.
883 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100884 * @warning No window's context may be current on another thread when this
885 * function is called.
886 *
887 * @sa glfwInit
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100888 *
889 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100890 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200891GLFWAPI void glfwTerminate(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100892
893/*! @brief Retrieves the version of the GLFW library.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100894 *
895 * This function retrieves the major, minor and revision numbers of the GLFW
896 * library. It is intended for when you are using GLFW as a shared library and
897 * want to ensure that you are using the minimum required version.
898 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100899 * @param[out] major Where to store the major version number, or `NULL`.
900 * @param[out] minor Where to store the minor version number, or `NULL`.
901 * @param[out] rev Where to store the revision number, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100902 *
903 * @remarks This function may be called before @ref glfwInit.
904 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100905 * @remarks This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100906 *
907 * @sa glfwGetVersionString
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100908 *
909 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100910 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200911GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100912
Camilla Berglund6f8084f2013-02-14 13:14:17 +0100913/*! @brief Returns a string describing the compile-time configuration.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100914 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100915 * This function returns a static string generated at compile-time according to
916 * which configuration macros were defined. This is intended for use when
917 * submitting bug reports, to allow developers to see which code paths are
918 * enabled in a binary.
919 *
Camilla Berglund6f8084f2013-02-14 13:14:17 +0100920 * The format of the string is as follows:
Camilla Berglund13ccf7d2013-04-07 13:46:38 +0200921 * - The version of GLFW
922 * - The name of the window system API
923 * - The name of the context creation API
924 * - Any additional options or APIs
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100925 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100926 * For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200927 * back ends, the version string may look something like this:
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100928 *
929 * 3.0.0 Win32 WGL MinGW
930 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100931 * @return The GLFW version string.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100932 *
933 * @remarks This function may be called before @ref glfwInit.
934 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100935 * @remarks This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100936 *
937 * @sa glfwGetVersion
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100938 *
939 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100940 */
Camilla Berglundd6fe4472010-09-13 18:05:59 +0200941GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +0200942
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100943/*! @brief Sets the error callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100944 *
945 * This function sets the error callback, which is called with an error code
946 * and a human-readable description each time a GLFW error occurs.
947 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100948 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100949 * callback.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100950 *
Camilla Berglund11a27de2013-04-08 21:21:21 +0200951 * @return The previously set callback, or `NULL` if an error occurred.
952 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100953 * @remarks This function may be called before @ref glfwInit.
954 *
Camilla Berglund9bfb9252013-01-07 17:22:02 +0100955 * @note The error callback is called by the thread where the error was
956 * generated. If you are using GLFW from multiple threads, your error callback
957 * needs to be written accordingly.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100958 *
959 * @note Because the description string provided to the callback may have been
960 * generated specifically for that error, it is not guaranteed to be valid
961 * after the callback has returned. If you wish to use it after that, you need
962 * to make your own copy of it before returning.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100963 *
964 * @ingroup error
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100965 */
Camilla Berglund11a27de2013-04-08 21:21:21 +0200966GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200967
Camilla Berglund5f68e122012-11-27 17:07:28 +0100968/*! @brief Returns the currently connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100969 *
970 * This function returns an array of handles for all currently connected
971 * monitors.
972 *
Camilla Berglundc00d0572013-05-15 15:01:42 +0200973 * @param[out] count The size of the returned array, or zero if an error
974 * occurred.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100975 * @return An array of monitor handles, or `NULL` if an error occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100976 *
977 * @note The returned array is valid only until the monitor configuration
978 * changes. See @ref glfwSetMonitorCallback to receive notifications of
979 * configuration changes.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100980 *
981 * @sa glfwGetPrimaryMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100982 *
983 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100984 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100985GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100986
Camilla Berglund5f68e122012-11-27 17:07:28 +0100987/*! @brief Returns the primary monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100988 *
989 * This function returns the primary monitor. This is usually the monitor
990 * where elements like the Windows task bar or the OS X menu bar is located.
991 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100992 * @return The primary monitor, or `NULL` if an error occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100993 *
994 * @sa glfwGetMonitors
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100995 *
996 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +0100997 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100998GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
Camilla Berglund41bc0d12012-11-27 16:55:04 +0100999
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001000/*! @brief Returns the position of the monitor's viewport on the virtual screen.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001001 *
1002 * This function returns the position, in screen coordinates, of the upper-left
1003 * corner of the specified monitor.
1004 *
Camilla Berglunddba2d802013-01-17 23:06:56 +01001005 * @param[in] monitor The monitor to query.
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001006 * @param[out] xpos The monitor x-coordinate.
1007 * @param[out] ypos The monitor y-coordinate.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001008 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001009 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001010 */
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001011GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
1012
1013/*! @brief Returns the physical size of the monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001014 *
1015 * This function returns the size, in millimetres, of the display area of the
1016 * specified monitor.
1017 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001018 * @param[in] monitor The monitor to query.
1019 * @param[out] width The width, in mm, of the monitor's display
1020 * @param[out] height The height, in mm, of the monitor's display.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001021 *
1022 * @note Some operating systems do not provide accurate information, either
1023 * because the monitor's EDID data is incorrect, or because the driver does not
1024 * report it accurately.
1025 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001026 * @ingroup monitor
1027 */
1028GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001029
Camilla Berglund5f68e122012-11-27 17:07:28 +01001030/*! @brief Returns the name of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001031 *
1032 * This function returns a human-readable name, encoded as UTF-8, of the
1033 * specified monitor.
1034 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001035 * @param[in] monitor The monitor to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001036 * @return The UTF-8 encoded name of the monitor, or `NULL` if an error
Camilla Berglund5d6256c2013-02-25 17:53:02 +01001037 * occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001038 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001039 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001040 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001041GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001042
Camilla Berglund5f68e122012-11-27 17:07:28 +01001043/*! @brief Sets the monitor configuration callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001044 *
1045 * This function sets the monitor configuration callback, or removes the
1046 * currently set callback. This is called when a monitor is connected to or
1047 * disconnected from the system.
1048 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001049 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001050 * callback.
Camilla Berglund11a27de2013-04-08 21:21:21 +02001051 * @return The previously set callback, or `NULL` if an error occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001052 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001053 * @bug This callback is not yet called on monitor configuration changes.
1054 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001055 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001056 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001057GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
Marcel Metzbeacbb32011-05-07 10:53:50 +02001058
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001059/*! @brief Returns the available video modes for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001060 *
1061 * This function returns an array of all video modes supported by the specified
Camilla Berglund948cc042013-04-16 02:02:22 +02001062 * monitor. The returned array is sorted in ascending order, first by color
1063 * bit depth (the sum of all channel depths) and then by resolution area (the
1064 * product of width and height).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001065 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001066 * @param[in] monitor The monitor to query.
Camilla Berglundc00d0572013-05-15 15:01:42 +02001067 * @param[out] count The number of video modes in the returned array, or zero
1068 * if an error occurred.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001069 * @return An array of video modes, or `NULL` if an error occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001070 *
1071 * @note The returned array is valid only until this function is called again
Camilla Berglund948cc042013-04-16 02:02:22 +02001072 * for the specified monitor.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001073 *
1074 * @sa glfwGetVideoMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001075 *
1076 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001077 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001078GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001079
Camilla Berglund5f68e122012-11-27 17:07:28 +01001080/*! @brief Returns the current mode of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001081 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001082 * This function returns the current video mode of the specified monitor. If
1083 * you are using a full screen window, the return value will therefore depend
1084 * on whether it is focused.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001085 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001086 * @param[in] monitor The monitor to query.
Camilla Berglundce1e84d2013-05-22 22:16:43 +02001087 * @return The current mode of the monitor, or `NULL` if an error occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001088 *
1089 * @sa glfwGetVideoModes
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001090 *
1091 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001092 */
Camilla Berglundce1e84d2013-05-22 22:16:43 +02001093GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
Camilla Berglund3249f812010-09-07 17:34:51 +02001094
Camilla Berglund92a71e02013-02-12 13:50:41 +01001095/*! @brief Generates a gamma ramp and sets it for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001096 *
Camilla Berglund5d308db2013-05-19 15:46:44 +02001097 * This function generates a 256-element gamma ramp from the specified exponent
1098 * and then calls @ref glfwSetGamma with it.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001099 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01001100 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001101 * @param[in] gamma The desired exponent.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001102 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001103 * @ingroup gamma
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001104 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01001105GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001106
Camilla Berglund92a71e02013-02-12 13:50:41 +01001107/*! @brief Retrieves the current gamma ramp for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001108 *
1109 * This function retrieves the current gamma ramp of the specified monitor.
1110 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01001111 * @param[in] monitor The monitor to query.
Camilla Berglund5d308db2013-05-19 15:46:44 +02001112 * @return The current gamma ramp.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001113 *
1114 * @ingroup gamma
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001115 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02001116GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001117
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001118/*! @brief Sets the current gamma ramp for the specified monitor.
1119 *
1120 * This function sets the current gamma ramp for the specified monitor.
1121 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01001122 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001123 * @param[in] ramp The gamma ramp to use.
Camilla Berglund8954af62013-02-20 19:44:52 +01001124 *
Camilla Berglund5d308db2013-05-19 15:46:44 +02001125 * @note Gamma ramp sizes other than 256 are not supported by all hardware.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001126 *
1127 * @ingroup gamma
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001128 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01001129GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
Camilla Berglund2630d492010-10-13 04:04:43 +02001130
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001131/*! @brief Resets all window hints to their default values.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001132 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001133 * This function resets all window hints to their
Camilla Berglunde248fb62013-03-29 14:06:23 +01001134 * [default values](@ref window_hints_values).
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001135 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001136 * @note This function may only be called from the main thread.
1137 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001138 * @sa glfwWindowHint
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001139 *
1140 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001141 */
Camilla Berglund5df4df62012-10-22 02:59:05 +02001142GLFWAPI void glfwDefaultWindowHints(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001143
1144/*! @brief Sets the specified window hint to the desired value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001145 *
Camilla Berglunded9e4032012-12-23 15:59:09 +01001146 * This function sets hints for the next call to @ref glfwCreateWindow. The
1147 * hints, once set, retain their values until changed by a call to @ref
1148 * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
1149 * terminated with @ref glfwTerminate.
1150 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001151 * @param[in] target The [window hint](@ref window_hints) to set.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001152 * @param[in] hint The new value of the window hint.
1153 *
Camilla Berglund401033c2013-03-12 19:17:07 +01001154 * @par New in GLFW 3
1155 * Hints are no longer reset to their default values on window creation. To
1156 * set default hint values, use @ref glfwDefaultWindowHints.
1157 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001158 * @note This function may only be called from the main thread.
1159 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001160 * @sa glfwDefaultWindowHints
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001161 *
1162 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001163 */
Camilla Berglundaff30d02012-08-06 17:56:41 +02001164GLFWAPI void glfwWindowHint(int target, int hint);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001165
1166/*! @brief Creates a window and its associated context.
1167 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001168 * This function creates a window and its associated context. Most of the
1169 * options controlling how the window and its context should be created are
Camilla Berglundfa0cbd92013-04-11 01:07:07 +02001170 * specified through @ref glfwWindowHint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001171 *
1172 * Successful creation does not change which context is current. Before you
1173 * can use the newly created context, you need to make it current using @ref
1174 * glfwMakeContextCurrent.
1175 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001176 * Note that the created window and context may differ from what you requested,
Camilla Berglundfa0cbd92013-04-11 01:07:07 +02001177 * as not all parameters and hints are
1178 * [hard constraints](@ref window_hints_hard). This includes the size of the
1179 * window, especially for full screen windows. To retrieve the actual
Camilla Berglundad1f6f02013-05-27 15:30:32 +02001180 * attributes of the created window and context, use queries like @ref
1181 * glfwGetWindowAttrib and @ref glfwGetWindowSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001182 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001183 * @param[in] width The desired width, in screen coordinates, of the window.
1184 * This must be greater than zero.
1185 * @param[in] height The desired height, in screen coordinates, of the window.
1186 * This must be greater than zero.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001187 * @param[in] title The initial, UTF-8 encoded window title.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001188 * @param[in] monitor The monitor to use for full screen mode, or `NULL` to use
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001189 * windowed mode.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001190 * @param[in] share The window whose context to share resources with, or `NULL`
1191 * to not share resources.
1192 * @return The handle of the created window, or `NULL` if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001193 *
Camilla Berglund6f8084f2013-02-14 13:14:17 +01001194 * @remarks To create the window at a specific position, make it initially
Camilla Berglund71d2b572013-03-12 15:33:05 +01001195 * invisible using the `GLFW_VISIBLE` window hint, set its position and then
Camilla Berglund6f8084f2013-02-14 13:14:17 +01001196 * show it.
1197 *
Camilla Berglund159f9b92013-04-10 01:57:43 +02001198 * @remarks If a fullscreen window is active, the screensaver is prohibited
1199 * from starting.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001200 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001201 * @remarks **Windows:** If the executable has an icon resource named
1202 * `GLFW_ICON,` it will be set as the icon for the window. If no such icon is
1203 * present, the `IDI_WINLOGO` icon will be used instead.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001204 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001205 * @remarks **Mac OS X:** The GLFW window has no icon, as it is not a document
1206 * window, but the dock icon will be the same as the application bundle's icon.
1207 * Also, the first time a window is opened the menu bar is populated with
1208 * common commands like Hide, Quit and About. The (minimal) about dialog uses
1209 * information from the application's bundle. For more information on bundles,
1210 * see the Bundle Programming Guide provided by Apple.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001211 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001212 * @note This function may only be called from the main thread.
1213 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001214 * @sa glfwDestroyWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001215 *
1216 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001217 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001218GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001219
1220/*! @brief Destroys the specified window and its context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001221 *
1222 * This function destroys the specified window and its context. On calling
1223 * this function, no further callbacks will be called for that window.
1224 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001225 * @param[in] window The window to destroy.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001226 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001227 * @note This function may only be called from the main thread.
1228 *
Camilla Berglundb48128f2013-02-14 18:49:03 +01001229 * @note This function may not be called from a callback.
1230 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001231 * @note If the window's context is current on the main thread, it is
1232 * detached before being destroyed.
1233 *
1234 * @warning The window's context must not be current on any other thread.
1235 *
1236 * @sa glfwCreateWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001237 *
1238 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001239 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001240GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001241
Camilla Berglund64afb192013-03-06 23:29:37 +01001242/*! @brief Checks the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001243 *
1244 * This function returns the value of the close flag of the specified window.
1245 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01001246 * @param[in] window The window to query.
Camilla Berglund64afb192013-03-06 23:29:37 +01001247 * @return The value of the close flag.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001248 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01001249 * @ingroup window
1250 */
1251GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
1252
Camilla Berglund64afb192013-03-06 23:29:37 +01001253/*! @brief Sets the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001254 *
1255 * This function sets the value of the close flag of the specified window.
1256 * This can be used to override the user's attempt to close the window, or
1257 * to signal that it should be closed.
1258 *
Camilla Berglund64afb192013-03-06 23:29:37 +01001259 * @param[in] window The window whose flag to change.
Camilla Berglund6fadf372013-03-01 13:45:12 +01001260 * @param[in] value The new value.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001261 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01001262 * @ingroup window
Camilla Berglund6fadf372013-03-01 13:45:12 +01001263 */
1264GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
1265
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001266/*! @brief Sets the title of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001267 *
1268 * This function sets the window title, encoded as UTF-8, of the specified
1269 * window.
1270 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001271 * @param[in] window The window whose title to change.
1272 * @param[in] title The UTF-8 encoded window title.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001273 *
1274 * @note This function may only be called from the main thread.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001275 *
1276 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001277 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001278GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001279
Camilla Berglund7c193232013-01-24 19:30:31 +01001280/*! @brief Retrieves the position of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001281 *
1282 * This function retrieves the position, in screen coordinates, of the
1283 * upper-left corner of the client area of the specified window.
1284 *
Camilla Berglund7c193232013-01-24 19:30:31 +01001285 * @param[in] window The window to query.
1286 * @param[out] xpos The x-coordinate of the upper-left corner of the client area.
1287 * @param[out] ypos The y-coordinate of the upper-left corner of the client area.
Camilla Berglund7c193232013-01-24 19:30:31 +01001288 *
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02001289 * @remarks Either or both coordinate arguments may be `NULL`.
Camilla Berglund7c193232013-01-24 19:30:31 +01001290 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001291 * @bug **Mac OS X:** The screen coordinate system is inverted.
1292 *
Camilla Berglund7c193232013-01-24 19:30:31 +01001293 * @sa glfwSetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001294 *
1295 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01001296 */
1297GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
1298
1299/*! @brief Sets the position of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001300 *
1301 * This function sets the position, in screen coordinates, of the upper-left
1302 * corner of the client area of the window.
1303 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001304 * If it is a full screen window, this function does nothing.
1305 *
Camilla Berglund7c193232013-01-24 19:30:31 +01001306 * @param[in] window The window to query.
1307 * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
1308 * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
Camilla Berglund7c193232013-01-24 19:30:31 +01001309 *
1310 * @remarks If you wish to set an initial window position you should create
Camilla Berglund71d2b572013-03-12 15:33:05 +01001311 * a hidden window (using @ref glfwWindowHint and `GLFW_VISIBLE`), set its
Camilla Berglund7c193232013-01-24 19:30:31 +01001312 * position and then show it.
1313 *
1314 * @note It is very rarely a good idea to move an already visible window, as it
1315 * will confuse and annoy the user.
1316 *
1317 * @note This function may only be called from the main thread.
1318 *
1319 * @note The window manager may put limits on what positions are allowed.
1320 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001321 * @bug **X11:** Some window managers ignore the set position of hidden (i.e.
1322 * unmapped) windows, instead placing them where it thinks is appropriate once
1323 * they are shown.
Camilla Berglund7c193232013-01-24 19:30:31 +01001324 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001325 * @bug **Mac OS X:** The screen coordinate system is inverted.
Camilla Berglund7c193232013-01-24 19:30:31 +01001326 *
1327 * @sa glfwGetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001328 *
1329 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01001330 */
Camilla Berglund52f718d2013-02-12 12:01:12 +01001331GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
Camilla Berglund7c193232013-01-24 19:30:31 +01001332
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001333/*! @brief Retrieves the size of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001334 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001335 * This function retrieves the size, in screen coordinates, of the client area
1336 * of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001337 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001338 * @param[in] window The window whose size to retrieve.
1339 * @param[out] width The width of the client area.
1340 * @param[out] height The height of the client area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001341 *
1342 * @sa glfwSetWindowSize
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001343 *
1344 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001345 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001346GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001347
1348/*! @brief Sets the size of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001349 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001350 * This function sets the size, in screen coordinates, of the client area of
1351 * the specified window.
1352 *
1353 * For full screen windows, this function selects and switches to the resolution
1354 * closest to the specified size, without affecting the window's context. As
1355 * the context is unaffected, the bit depths of the framebuffer remain
1356 * unchanged.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001357 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001358 * @param[in] window The window to resize.
1359 * @param[in] width The desired width of the specified window.
1360 * @param[in] height The desired height of the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001361 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001362 * @note This function may only be called from the main thread.
1363 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001364 * @note The window manager may put limits on what window sizes are allowed.
1365 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001366 * @sa glfwGetWindowSize
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001367 *
1368 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001369 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001370GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001371
1372/*! @brief Iconifies the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001373 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001374 * This function iconifies/minimizes the specified window, if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001375 * restored. If it is a full screen window, the original monitor resolution is
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001376 * restored until the window is restored. If the window is already iconified,
1377 * this function does nothing.
1378 *
1379 * @param[in] window The window to iconify.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001380 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001381 * @note This function may only be called from the main thread.
1382 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001383 * @bug **Mac OS X:** This function is not yet implemented for
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001384 * full screen windows.
Camilla Berglund8954af62013-02-20 19:44:52 +01001385 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001386 * @sa glfwRestoreWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001387 *
1388 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001389 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001390GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001391
1392/*! @brief Restores the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001393 *
1394 * This function restores the specified window, if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001395 * iconified/minimized. If it is a full screen window, the resolution chosen
1396 * for the window is restored on the selected monitor. If the window is
1397 * already restored, this function does nothing.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001398 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001399 * @param[in] window The window to restore.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001400 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001401 * @note This function may only be called from the main thread.
1402 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001403 * @bug **Mac OS X:** This function is not yet implemented for full screen
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001404 * windows.
Camilla Berglund8954af62013-02-20 19:44:52 +01001405 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001406 * @sa glfwIconifyWindow
Camilla Berglunde248fb62013-03-29 14:06:23 +01001407 *
1408 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001409 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001410GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001411
1412/*! @brief Makes the specified window visible.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001413 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001414 * This function makes the specified window visible, if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001415 * hidden. If the window is already visible or is in full screen mode, this
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001416 * function does nothing.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001417 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001418 * @param[in] window The window to make visible.
1419 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001420 * @note This function may only be called from the main thread.
1421 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001422 * @sa glfwHideWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001423 *
1424 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001425 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001426GLFWAPI void glfwShowWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001427
1428/*! @brief Hides the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001429 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001430 * This function hides the specified window, if it was previously visible. If
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001431 * the window is already hidden or is in full screen mode, this function does
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001432 * nothing.
1433 *
1434 * @param[in] window The window to hide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001435 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001436 * @note This function may only be called from the main thread.
1437 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001438 * @sa glfwShowWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001439 *
1440 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001441 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001442GLFWAPI void glfwHideWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001443
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001444/*! @brief Returns the monitor that the window uses for full screen mode.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001445 *
1446 * This function returns the handle of the monitor that the specified window is
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001447 * in full screen on.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001448 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001449 * @param[in] window The window to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001450 * @return The monitor, or `NULL` if the window is in windowed mode.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001451 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001452 * @ingroup window
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001453 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001454GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001455
Camilla Berglundad1f6f02013-05-27 15:30:32 +02001456/*! @brief Returns an attribute of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001457 *
Camilla Berglundad1f6f02013-05-27 15:30:32 +02001458 * This function returns an attribute of the specified window. There are many
1459 * attributes, some related to the window and others to its context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001460 *
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001461 * @param[in] window The window to query.
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02001462 * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
1463 * return.
Camilla Berglundad1f6f02013-05-27 15:30:32 +02001464 * @return The value of the attribute, or zero if an error occurred.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001465 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001466 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001467 */
Camilla Berglundad1f6f02013-05-27 15:30:32 +02001468GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001469
1470/*! @brief Sets the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001471 *
1472 * This function sets the user-defined pointer of the specified window. The
1473 * current value is retained until the window is destroyed. The initial value
1474 * is `NULL`.
1475 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001476 * @param[in] window The window whose pointer to set.
1477 * @param[in] pointer The new value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001478 *
1479 * @sa glfwGetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001480 *
1481 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001482 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001483GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001484
1485/*! @brief Returns the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001486 *
1487 * This function returns the current value of the user-defined pointer of the
1488 * specified window. The initial value is `NULL`.
1489 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001490 * @param[in] window The window whose pointer to return.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001491 *
1492 * @sa glfwSetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001493 *
1494 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001495 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001496GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001497
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001498/*! @brief Sets the position callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001499 *
1500 * This function sets the position callback of the specified window, which is
1501 * called when the window is moved. The callback is provided with the screen
1502 * position of the upper-left corner of the client area of the window.
1503 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001504 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001505 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001506 * callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001507 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001508 * @return The previously set callback, or `NULL` if an error occurred.
1509 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001510 * @ingroup window
1511 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001512GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001513
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001514/*! @brief Sets the size callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001515 *
1516 * This function sets the size callback of the specified window, which is
1517 * called when the window is resized. The callback is provided with the size,
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001518 * in screen coordinates, of the client area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001519 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001520 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001521 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001522 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001523 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001524 * @return The previously set callback, or `NULL` if an error occurred.
1525 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001526 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001527 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001528GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001529
1530/*! @brief Sets the close callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001531 *
1532 * This function sets the close callback of the specified window, which is
1533 * called when the user attempts to close the window, for example by clicking
1534 * the close widget in the title bar.
1535 *
1536 * The close flag is set before this callback is called, but you can modify it
1537 * at any time with @ref glfwSetWindowShouldClose.
1538 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001539 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001540 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001541 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001542 *
Camilla Berglund64afb192013-03-06 23:29:37 +01001543 * @remarks Calling @ref glfwDestroyWindow does not cause this callback to be
1544 * called.
Camilla Berglund1bd59842013-01-13 21:28:18 +01001545 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001546 * @return The previously set callback, or `NULL` if an error occurred.
1547 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001548 * @remarks **Mac OS X:** Selecting Quit from the application menu will
Camilla Berglund1bd59842013-01-13 21:28:18 +01001549 * trigger the close callback for all windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001550 *
1551 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001552 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001553GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001554
1555/*! @brief Sets the refresh callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001556 *
1557 * This function sets the refresh callback of the specified window, which is
1558 * called when the client area of the window needs to be redrawn, for example
1559 * if the window has been exposed after having been covered by another window.
1560 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001561 * On compositing window systems such as Aero, Compiz or Aqua, where the window
1562 * contents are saved off-screen, this callback may be called only very
1563 * infrequently or never at all.
1564 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001565 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001566 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001567 * callback.
Camilla Berglund11a27de2013-04-08 21:21:21 +02001568 * @return The previously set callback, or `NULL` if an error occurred.
1569 *
1570 * @note On compositing window systems such as Aero, Compiz or Aqua, where the
1571 * window contents are saved off-screen, this callback may be called only very
1572 * infrequently or never at all.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001573 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001574 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001575 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001576GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001577
1578/*! @brief Sets the focus callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001579 *
1580 * This function sets the focus callback of the specified window, which is
1581 * called when the window gains or loses focus.
1582 *
Camilla Berglund4538a522013-04-24 19:49:46 +02001583 * After the focus callback is called for a window that lost focus, synthetic
1584 * key and mouse button release events will be generated for all such that had
1585 * been pressed. For more information, see @ref glfwSetKeyCallback and @ref
1586 * glfwSetMouseButtonCallback.
1587 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001588 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001589 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001590 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001591 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001592 * @return The previously set callback, or `NULL` if an error occurred.
1593 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001594 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001595 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001596GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001597
1598/*! @brief Sets the iconify callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001599 *
1600 * This function sets the iconification callback of the specified window, which
1601 * is called when the window is iconified or restored.
1602 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001603 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001604 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001605 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001606 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001607 * @return The previously set callback, or `NULL` if an error occurred.
1608 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001609 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001610 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001611GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
Camilla Berglund135194a2010-09-09 18:15:32 +02001612
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001613/*! @brief Processes all pending events.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001614 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001615 * This function processes only those events that have already been received
Camilla Berglund948cc042013-04-16 02:02:22 +02001616 * and then returns immediately. Processing events will cause the window and
1617 * input callbacks associated with those events to be called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001618 *
Camilla Berglund401033c2013-03-12 19:17:07 +01001619 * @par New in GLFW 3
1620 * This function is no longer called by @ref glfwSwapBuffers. You need to call
1621 * it or @ref glfwWaitEvents yourself.
1622 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001623 * @remarks This function is not required for joystick input to work.
1624 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001625 * @note This function may only be called from the main thread.
1626 *
Camilla Berglundb48128f2013-02-14 18:49:03 +01001627 * @note This function may not be called from a callback.
1628 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001629 * @note On some platforms, certain callbacks may be called outside of a call
1630 * to one of the event processing functions.
1631 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001632 * @sa glfwWaitEvents
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001633 *
1634 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001635 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001636GLFWAPI void glfwPollEvents(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001637
1638/*! @brief Waits until events are pending and processes them.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001639 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001640 * This function puts the calling thread to sleep until at least one event has
1641 * been received. Once one or more events have been recevied, it behaves as if
1642 * @ref glfwPollEvents was called, i.e. the events are processed and the
1643 * function then returns immediately. Processing events will cause the window
1644 * and input callbacks associated with those events to be called.
1645 *
1646 * Since not all events are associated with callbacks, this function may return
1647 * without a callback having been called even if you are monitoring all
1648 * callbacks.
1649 *
1650 * @remarks This function is not required for joystick input to work.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001651 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001652 * @note This function may only be called from the main thread.
1653 *
Camilla Berglundb48128f2013-02-14 18:49:03 +01001654 * @note This function may not be called from a callback.
1655 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001656 * @note On some platforms, certain callbacks may be called outside of a call
1657 * to one of the event processing functions.
1658 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001659 * @sa glfwPollEvents
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001660 *
1661 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001662 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001663GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +02001664
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001665/*! @brief Returns the value of an input option for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001666 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001667 * @param[in] window The window to query.
Camilla Berglund9264b5d2013-04-26 14:29:55 +02001668 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001669 * `GLFW_STICKY_MOUSE_BUTTONS`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001670 *
1671 * @sa glfwSetInputMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001672 *
1673 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001674 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001675GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001676
1677/*! @brief Sets an input option for the specified window.
Camilla Berglund9492fc52013-01-17 17:51:12 +01001678 * @param[in] window The window whose input mode to set.
Camilla Berglund9264b5d2013-04-26 14:29:55 +02001679 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
Camilla Berglund71d2b572013-03-12 15:33:05 +01001680 * `GLFW_STICKY_MOUSE_BUTTONS`.
Camilla Berglund9492fc52013-01-17 17:51:12 +01001681 * @param[in] value The new value of the specified input mode.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001682 *
Camilla Berglund9264b5d2013-04-26 14:29:55 +02001683 * If `mode` is `GLFW_CURSOR`, the value must be one of the supported input
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001684 * modes:
Camilla Berglund13ccf7d2013-04-07 13:46:38 +02001685 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
1686 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001687 * area of the window.
Camilla Berglund6df692b2013-04-26 17:20:31 +02001688 * - `GLFW_CURSOR_DISABLED` disables the cursor and removes any limitations on
1689 * cursor movement.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001690 *
1691 * If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
1692 * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are
1693 * enabled, a key press will ensure that @ref glfwGetKey returns @ref
1694 * GLFW_PRESS the next time it is called even if the key had been released
1695 * before the call.
1696 *
1697 * If `mode` is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either `GL_TRUE`
1698 * to enable sticky mouse buttons, or `GL_FALSE` to disable it. If sticky
1699 * mouse buttons are enabled, a mouse button press will ensure that @ref
1700 * glfwGetMouseButton returns @ref GLFW_PRESS the next time it is called even
1701 * if the mouse button had been released before the call.
1702 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001703 * @sa glfwGetInputMode
Camilla Berglunde248fb62013-03-29 14:06:23 +01001704 *
1705 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001706 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001707GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001708
1709/*! @brief Returns the last reported state of a keyboard key for the specified
1710 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001711 *
1712 * This function returns the last state reported for the specified key to the
1713 * specified window. The returned state is one of `GLFW_PRESS` or
1714 * `GLFW_RELEASE`. The higher-level state `GLFW_REPEAT` is only reported to
1715 * the key callback.
1716 *
1717 * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
1718 * `GLFW_PRESS` the first time you call this function after a key has been
1719 * pressed, even if the key has already been released.
1720 *
1721 * The key functions deal with physical keys, with [key tokens](@ref keys)
1722 * named after their use on the standard US keyboard layout. If you want to
1723 * input text, use the Unicode character callback instead.
1724 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001725 * @param[in] window The desired window.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001726 * @param[in] key The desired [keyboard key](@ref keys).
1727 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001728 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001729 * @ingroup input
1730 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001731GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001732
1733/*! @brief Returns the last reported state of a mouse button for the specified
1734 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001735 *
1736 * This function returns the last state reported for the specified mouse button
1737 * to the specified window.
1738 *
1739 * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
1740 * returns `GLFW_PRESS` the first time you call this function after a mouse
1741 * button has been pressed, even if the mouse button has already been released.
1742 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001743 * @param[in] window The desired window.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001744 * @param[in] button The desired [mouse button](@ref buttons).
1745 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001746 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001747 * @ingroup input
1748 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001749GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001750
1751/*! @brief Retrieves the last reported cursor position, relative to the client
1752 * area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001753 *
1754 * This function returns the last reported position of the cursor to the
1755 * specified window.
1756 *
Camilla Berglund6df692b2013-04-26 17:20:31 +02001757 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
1758 * position is unbounded and limited only by the minimum and maximum values of
1759 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02001760 *
Camilla Berglund3ec29252013-04-25 18:03:15 +02001761 * The coordinate can be converted to their integer equivalents with the
1762 * `floor` function. Casting directly to an integer type works for positive
1763 * coordinates, but fails for negative ones.
1764 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001765 * @param[in] window The desired window.
1766 * @param[out] xpos The cursor x-coordinate, relative to the left edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001767 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001768 * @param[out] ypos The cursor y-coordinate, relative to the to top edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001769 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001770 *
1771 * @sa glfwSetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001772 *
1773 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001774 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02001775GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001776
1777/*! @brief Sets the position of the cursor, relative to the client area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001778 *
1779 * This function sets the position of the cursor. The specified window must be
1780 * focused. If the window does not have focus when this function is called, it
1781 * fails silently.
1782 *
Camilla Berglund6df692b2013-04-26 17:20:31 +02001783 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
1784 * position is unbounded and limited only by the minimum and maximum values of
1785 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02001786 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001787 * @param[in] window The desired window.
1788 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001789 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001790 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001791 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001792 *
1793 * @sa glfwGetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001794 *
1795 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001796 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02001797GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001798
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001799/*! @brief Sets the key callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001800 *
1801 * This function sets the key callback of the specific window, which is called
1802 * when a key is pressed, repeated or released.
1803 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001804 * The key functions deal with physical keys, with layout independent
1805 * [key tokens](@ref keys) named after their values in the standard US keyboard
1806 * layout. If you want to input text, use the [character callback](@ref
1807 * glfwSetCharCallback) instead.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001808 *
Camilla Berglund4538a522013-04-24 19:49:46 +02001809 * When a window loses focus, it will generate synthetic key release events
1810 * for all pressed keys. You can tell these events from user-generated events
1811 * by the fact that the synthetic ones are generated after the window has lost
1812 * focus, i.e. `GLFW_FOCUSED` will be false and the focus callback will have
1813 * already been called.
1814 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001815 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001816 * @param[in] cbfun The new key callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001817 * set callback.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001818 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001819 * @return The previously set callback, or `NULL` if an error occurred.
1820 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001821 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001822 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001823GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001824
1825/*! @brief Sets the Unicode character callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001826 *
1827 * This function sets the character callback of the specific window, which is
1828 * called when a Unicode character is input.
1829 *
1830 * The character callback is intended for text input. If you want to know
1831 * whether a specific key was pressed or released, use the
1832 * [key callback](@ref glfwSetKeyCallback) instead.
1833 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001834 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001835 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001836 * callback.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001837 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001838 * @return The previously set callback, or `NULL` if an error occurred.
1839 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001840 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001841 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001842GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001843
1844/*! @brief Sets the mouse button callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001845 *
1846 * This function sets the mouse button callback of the specified window, which
1847 * is called when a mouse button is pressed or released.
1848 *
Camilla Berglund4538a522013-04-24 19:49:46 +02001849 * When a window loses focus, it will generate synthetic mouse button release
1850 * events for all pressed mouse buttons. You can tell these events from
1851 * user-generated events by the fact that the synthetic ones are generated
1852 * after the window has lost focus, i.e. `GLFW_FOCUSED` will be false and the
1853 * focus callback will have already been called.
1854 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001855 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001856 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001857 * callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001858 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001859 * @return The previously set callback, or `NULL` if an error occurred.
1860 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001861 * @ingroup input
1862 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001863GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001864
1865/*! @brief Sets the cursor position callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001866 *
1867 * This function sets the cursor position callback of the specified window,
1868 * which is called when the cursor is moved. The callback is provided with the
1869 * position relative to the upper-left corner of the client area of the window.
1870 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001871 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001872 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001873 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001874 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001875 * @return The previously set callback, or `NULL` if an error occurred.
1876 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001877 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001878 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001879GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001880
1881/*! @brief Sets the cursor enter/exit callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001882 *
1883 * This function sets the cursor boundary crossing callback of the specified
1884 * window, which is called when the cursor enters or leaves the client area of
1885 * the window.
1886 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001887 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001888 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001889 * callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001890 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001891 * @return The previously set callback, or `NULL` if an error occurred.
1892 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001893 * @ingroup input
1894 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001895GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001896
1897/*! @brief Sets the scroll callback.
Camilla Berglunde248fb62013-03-29 14:06:23 +01001898 *
1899 * This function sets the scroll callback of the specified window, which is
1900 * called when a scrolling device is used, such as a mouse wheel or scrolling
1901 * area of a touchpad.
1902 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001903 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001904 * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001905 * set callback.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001906 *
Camilla Berglunda59c82c2013-03-01 15:20:29 +01001907 * @remarks This receives all scrolling input, like that from a mouse wheel or
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001908 * a touchpad scrolling area.
Camilla Berglunde248fb62013-03-29 14:06:23 +01001909 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001910 * @return The previously set callback, or `NULL` if an error occurred.
1911 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001912 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001913 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001914GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
Camilla Berglund3249f812010-09-07 17:34:51 +02001915
Camilla Berglundfdd45182013-05-27 15:13:09 +02001916/*! @brief Returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001917 *
Camilla Berglundfdd45182013-05-27 15:13:09 +02001918 * This function returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001919 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001920 * @param[in] joy The joystick to query.
Camilla Berglundfdd45182013-05-27 15:13:09 +02001921 * @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001922 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001923 * @ingroup input
1924 */
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001925GLFWAPI int glfwJoystickPresent(int joy);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001926
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001927/*! @brief Returns the values of all axes of the specified joystick.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001928 * @param[in] joy The joystick to query.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001929 * @param[out] count The size of the returned array.
1930 * @return An array of axis values, or @c NULL if the joystick is not present.
1931 *
1932 * @note The returned array is valid only until the next call to @ref
1933 * glfwGetJoystickAxes for that joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001934 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001935 * @ingroup input
1936 */
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001937GLFWAPI float* glfwGetJoystickAxes(int joy, int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001938
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001939/*! @brief Returns the values of all buttons of the specified joystick.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001940 * @param[in] joy The joystick to query.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001941 * @param[out] count The size of the returned array.
1942 * @return An array of axis values, or @c NULL if the joystick is not present.
1943 *
1944 * @note The returned array is valid only until the next call to @ref
1945 * glfwGetJoystickButtons for that joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001946 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001947 * @ingroup input
1948 */
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001949GLFWAPI unsigned char* glfwGetJoystickButtons(int joy, int* count);
Camilla Berglund3249f812010-09-07 17:34:51 +02001950
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001951/*! @brief Returns the name of the specified joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001952 *
1953 * This function returns the name, encoded as UTF-8, of the specified joystick.
1954 *
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001955 * @param[in] joy The joystick to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001956 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001957 * is not present.
Camilla Berglundd4a08b12012-12-02 17:13:41 +01001958 *
1959 * @note The returned string is valid only until the next call to @ref
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001960 * glfwGetJoystickName for that joystick.
1961 *
1962 * @ingroup input
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001963 */
Camilla Berglund93a1d1c2012-09-07 01:01:34 +02001964GLFWAPI const char* glfwGetJoystickName(int joy);
Camilla Berglund3249f812010-09-07 17:34:51 +02001965
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001966/*! @brief Sets the clipboard to the specified string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001967 *
1968 * This function sets the system clipboard to the specified, UTF-8 encoded
1969 * string. The string is copied before returning, so you don't have to retain
1970 * it afterwards.
1971 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001972 * @param[in] window The window that will own the clipboard contents.
1973 * @param[in] string A UTF-8 encoded string.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001974 *
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001975 * @note This function may only be called from the main thread.
1976 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001977 * @sa glfwGetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001978 *
1979 * @ingroup clipboard
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001980 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001981GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001982
1983/*! @brief Retrieves the contents of the clipboard as a string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001984 *
1985 * This function returns the contents of the system clipboard, if it contains
1986 * or is convertible to a UTF-8 encoded string.
1987 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001988 * @param[in] window The window that will request the clipboard contents.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001989 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
Camilla Berglund5d6256c2013-02-25 17:53:02 +01001990 * if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001991 *
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001992 * @note This function may only be called from the main thread.
1993 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001994 * @note The returned string is valid only until the next call to @ref
1995 * glfwGetClipboardString or @ref glfwSetClipboardString.
1996 *
1997 * @sa glfwSetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001998 *
1999 * @ingroup clipboard
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002000 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002001GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
Ralph Eastwood31c91542011-09-21 10:09:47 +01002002
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002003/*! @brief Returns the value of the GLFW timer.
2004 *
2005 * This function returns the value of the GLFW timer. Unless the timer has
2006 * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
2007 * was initialized.
2008 *
Camilla Berglund5d6256c2013-02-25 17:53:02 +01002009 * @return The current value, in seconds, or zero if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002010 *
2011 * @remarks This function may be called from secondary threads.
2012 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002013 * @note The resolution of the timer is system dependent, but is usually on the
2014 * order of a few micro- or nanoseconds. It uses the highest-resolution
2015 * monotonic time source on each supported platform.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002016 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002017 * @ingroup time
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002018 */
Camilla Berglund9a716692010-09-08 16:40:43 +02002019GLFWAPI double glfwGetTime(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02002020
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002021/*! @brief Sets the GLFW timer.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002022 *
2023 * This function sets the value of the GLFW timer. It then continues to count
2024 * up from that value.
2025 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002026 * @param[in] time The new value, in seconds.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002027 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002028 * @note The resolution of the timer is system dependent, but is usually on the
2029 * order of a few micro- or nanoseconds. It uses the highest-resolution
2030 * monotonic time source on each supported platform.
Camilla Berglunde248fb62013-03-29 14:06:23 +01002031 *
2032 * @ingroup time
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002033 */
2034GLFWAPI void glfwSetTime(double time);
2035
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002036/*! @brief Makes the context of the specified window current for the calling
2037 * thread.
2038 *
2039 * This function makes the context of the specified window current on the
2040 * calling thread. A context can only be made current on a single thread at
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002041 * a time and each thread can have only a single current context at a time.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002042 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01002043 * @param[in] window The window whose context to make current, or `NULL` to
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002044 * detach the current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002045 *
2046 * @remarks This function may be called from secondary threads.
2047 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002048 * @sa glfwGetCurrentContext
Camilla Berglunde248fb62013-03-29 14:06:23 +01002049 *
2050 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002051 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002052GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002053
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002054/*! @brief Returns the window whose context is current on the calling thread.
2055 *
2056 * This function returns the window whose context is current on the calling
2057 * thread.
2058 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01002059 * @return The window whose context is current, or `NULL` if no window's
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002060 * context is current.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002061 *
2062 * @remarks This function may be called from secondary threads.
2063 *
2064 * @sa glfwMakeContextCurrent
Camilla Berglunde248fb62013-03-29 14:06:23 +01002065 *
2066 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002067 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002068GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002069
2070/*! @brief Swaps the front and back buffers of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002071 *
2072 * This function swaps the front and back buffers of the specified window. If
2073 * the swap interval is greater than zero, the GPU driver waits the specified
2074 * number of screen updates before swapping the buffers.
2075 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01002076 * @param[in] window The window whose buffers to swap.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002077 *
2078 * @remarks This function may be called from secondary threads.
2079 *
Camilla Berglund401033c2013-03-12 19:17:07 +01002080 * @par New in GLFW 3
2081 * This function no longer calls @ref glfwPollEvents. You need to call it or
2082 * @ref glfwWaitEvents yourself.
2083 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002084 * @sa glfwSwapInterval
Camilla Berglunde248fb62013-03-29 14:06:23 +01002085 *
2086 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002087 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002088GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002089
2090/*! @brief Sets the swap interval for the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002091 *
2092 * This function sets the swap interval for the current context, i.e. the
2093 * number of screen updates to wait before swapping the buffers of a window and
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002094 * returning from @ref glfwSwapBuffers. This is sometimes called 'vertical
2095 * synchronization', 'vertical retrace synchronization' or 'vsync'.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002096 *
2097 * @param[in] interval The minimum number of screen updates to wait for
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002098 * until the buffers are swapped by @ref glfwSwapBuffers.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002099 *
2100 * @remarks This function may be called from secondary threads.
2101 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002102 * @remarks Contexts that support either of the `WGL_EXT_swap_control_tear` and
2103 * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,
2104 * which allow the driver to swap even if a frame arrives a little bit late.
2105 * You can check for the presence of these extensions using @ref
2106 * glfwExtensionSupported. For more information about swap tearing, see the
2107 * extension specifications.
2108 *
2109 * @note Some GPU drivers do not honor the requested swap interval, either
2110 * because of user settings that override the request or due to bugs in the
2111 * driver.
2112 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002113 * @sa glfwSwapBuffers
Camilla Berglunde248fb62013-03-29 14:06:23 +01002114 *
2115 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002116 */
2117GLFWAPI void glfwSwapInterval(int interval);
2118
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002119/*! @brief Returns whether the specified extension is available.
2120 *
Camilla Berglund608109c2013-04-11 20:18:46 +02002121 * This function returns whether the specified
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02002122 * [OpenGL or context creation API extension](@ref context_glext) is supported
2123 * by the current context. For example, on Windows both the OpenGL and WGL
2124 * extension strings are checked.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002125 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002126 * @param[in] extension The ASCII encoded name of the extension.
Camilla Berglund71d2b572013-03-12 15:33:05 +01002127 * @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002128 *
2129 * @remarks This function may be called from secondary threads.
2130 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002131 * @note As this functions searches one or more extension strings on each call,
2132 * it is recommended that you cache its results if it's going to be used
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002133 * frequently. The extension strings will not change during the lifetime of
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002134 * a context, so there is no danger in doing this.
Camilla Berglunde248fb62013-03-29 14:06:23 +01002135 *
2136 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002137 */
2138GLFWAPI int glfwExtensionSupported(const char* extension);
2139
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002140/*! @brief Returns the address of the specified function for the current
2141 * context.
2142 *
Camilla Berglund608109c2013-04-11 20:18:46 +02002143 * This function returns the address of the specified
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02002144 * [client API or extension function](@ref context_glext), if it is supported
2145 * by the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002146 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002147 * @param[in] procname The ASCII encoded name of the function.
Camilla Berglund71d2b572013-03-12 15:33:05 +01002148 * @return The address of the function, or `NULL` if the function is
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002149 * unavailable.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002150 *
2151 * @remarks This function may be called from secondary threads.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002152 *
2153 * @note The addresses of these functions are not guaranteed to be the same for
2154 * all contexts, especially if they use different client APIs or even different
2155 * context creation hints.
2156 *
2157 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002158 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02002159GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
Camilla Berglund3249f812010-09-07 17:34:51 +02002160
Camilla Berglund3249f812010-09-07 17:34:51 +02002161
Camilla Berglund4afc67c2011-07-27 17:09:17 +02002162/*************************************************************************
2163 * Global definition cleanup
2164 *************************************************************************/
2165
2166/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
2167
Camilla Berglund4afc67c2011-07-27 17:09:17 +02002168#ifdef GLFW_WINGDIAPI_DEFINED
2169 #undef WINGDIAPI
2170 #undef GLFW_WINGDIAPI_DEFINED
2171#endif
2172
2173#ifdef GLFW_CALLBACK_DEFINED
2174 #undef CALLBACK
2175 #undef GLFW_CALLBACK_DEFINED
2176#endif
2177
2178/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
2179
2180
Camilla Berglund3249f812010-09-07 17:34:51 +02002181#ifdef __cplusplus
2182}
2183#endif
2184
Camilla Berglundf8df91d2013-01-15 01:59:56 +01002185#endif /* _glfw3_h_ */
Camilla Berglund3249f812010-09-07 17:34:51 +02002186