blob: 127b263f25ca27db4110553b9d72d0de049a8776 [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 Berglund2fca5c52013-01-17 21:51:39 +0100473#define GLFW_NOT_INITIALIZED 0x00070001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100474/*! @brief No context is current for this thread.
475 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100476#define GLFW_NO_CURRENT_CONTEXT 0x00070002
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 Berglund2fca5c52013-01-17 21:51:39 +0100480#define GLFW_INVALID_ENUM 0x00070003
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100481/*! @brief One of the parameters for the function was given an invalid value.
482 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100483#define GLFW_INVALID_VALUE 0x00070004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100484/*! @brief A memory allocation failed.
485 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100486#define GLFW_OUT_OF_MEMORY 0x00070005
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 Berglund2fca5c52013-01-17 21:51:39 +0100490#define GLFW_API_UNAVAILABLE 0x00070006
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 Berglund2fca5c52013-01-17 21:51:39 +0100493#define GLFW_VERSION_UNAVAILABLE 0x00070007
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 Berglund2fca5c52013-01-17 21:51:39 +0100497#define GLFW_PLATFORM_ERROR 0x00070008
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100498/*! @brief The clipboard did not contain data in the requested format.
499 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100500#define GLFW_FORMAT_UNAVAILABLE 0x00070009
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 Berglund2fca5c52013-01-17 21:51:39 +0100505#define GLFW_RESIZABLE 0x00022007
506#define GLFW_VISIBLE 0x00022008
Camilla Berglund49db3b22013-04-08 15:16:32 +0200507#define GLFW_DECORATED 0x00022009
Camilla Berglund2c091572010-09-09 21:09:11 +0200508
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100509#define GLFW_CONTEXT_REVISION 0x00020004
510#define GLFW_RED_BITS 0x00021000
511#define GLFW_GREEN_BITS 0x00021001
512#define GLFW_BLUE_BITS 0x00021002
513#define GLFW_ALPHA_BITS 0x00021003
514#define GLFW_DEPTH_BITS 0x00021004
515#define GLFW_STENCIL_BITS 0x00021005
516#define GLFW_ACCUM_RED_BITS 0x00021006
517#define GLFW_ACCUM_GREEN_BITS 0x00021007
518#define GLFW_ACCUM_BLUE_BITS 0x00021008
519#define GLFW_ACCUM_ALPHA_BITS 0x00021009
520#define GLFW_AUX_BUFFERS 0x0002100A
521#define GLFW_STEREO 0x0002100B
522#define GLFW_SAMPLES 0x0002100C
523#define GLFW_SRGB_CAPABLE 0x0002100D
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
533#define GLFW_OPENGL_API 0x00000001
534#define GLFW_OPENGL_ES_API 0x00000002
535
536#define GLFW_NO_ROBUSTNESS 0x00000000
537#define GLFW_NO_RESET_NOTIFICATION 0x00000001
538#define GLFW_LOSE_CONTEXT_ON_RESET 0x00000002
539
540#define GLFW_OPENGL_NO_PROFILE 0x00000000
541#define GLFW_OPENGL_CORE_PROFILE 0x00000001
542#define GLFW_OPENGL_COMPAT_PROFILE 0x00000002
543
Camilla Berglund9264b5d2013-04-26 14:29:55 +0200544#define GLFW_CURSOR 0x00030001
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100545#define GLFW_STICKY_KEYS 0x00030002
546#define GLFW_STICKY_MOUSE_BUTTONS 0x00030003
547
548#define GLFW_CURSOR_NORMAL 0x00040001
549#define GLFW_CURSOR_HIDDEN 0x00040002
Camilla Berglund6df692b2013-04-26 17:20:31 +0200550#define GLFW_CURSOR_DISABLED 0x00040003
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100551
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100552#define GLFW_CONNECTED 0x00061000
553#define GLFW_DISCONNECTED 0x00061001
554
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{
790 int width;
791 int height;
792 int redBits;
Camilla Berglund5fd3fc72010-09-09 19:44:43 +0200793 int greenBits;
Camilla Berglund2e8446f2013-04-11 01:31:00 +0200794 int blueBits;
Camilla Berglund3249f812010-09-07 17:34:51 +0200795} GLFWvidmode;
796
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100797/*! @brief Gamma ramp.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200798 *
799 * This describes the gamma ramp for a monitor.
800 *
801 * @sa glfwGetGammaRamp glfwSetGammaRamp
802 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100803 * @ingroup gamma
804 */
Camilla Berglund2630d492010-10-13 04:04:43 +0200805typedef struct
806{
Camilla Berglund5d308db2013-05-19 15:46:44 +0200807 unsigned short* red;
808 unsigned short* green;
809 unsigned short* blue;
810 unsigned int size;
Camilla Berglund2630d492010-10-13 04:04:43 +0200811} GLFWgammaramp;
812
Camilla Berglund3249f812010-09-07 17:34:51 +0200813
814/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100815 * GLFW API functions
Camilla Berglund3249f812010-09-07 17:34:51 +0200816 *************************************************************************/
817
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100818/*! @brief Initializes the GLFW library.
819 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100820 * This function initializes the GLFW library. Before most GLFW functions can
821 * be used, GLFW must be initialized, and before a program terminates GLFW
822 * should be terminated in order to free any resources allocated during or
823 * after initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100824 *
Camilla Berglund23f61762013-03-12 19:53:29 +0100825 * If this function fails, it calls @ref glfwTerminate before returning. If it
826 * succeeds, you should call @ref glfwTerminate before the program exits.
827 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100828 * Additional calls to this function after successful initialization but before
829 * termination will succeed but will do nothing.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100830 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100831 * @return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100832 *
Camilla Berglund401033c2013-03-12 19:17:07 +0100833 * @par New in GLFW 3
834 * This function no longer registers @ref glfwTerminate with `atexit`.
835 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +0100836 * @note This function may only be called from the main thread.
837 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100838 * @note This function may take several seconds to complete on some systems,
839 * while on other systems it may take only a fraction of a second to complete.
840 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100841 * @note **Mac OS X:** This function will change the current directory of the
842 * application to the `Contents/Resources` subdirectory of the application's
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100843 * bundle, if present.
844 *
845 * @sa glfwTerminate
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100846 *
847 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100848 */
849GLFWAPI int glfwInit(void);
850
851/*! @brief Terminates the GLFW library.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100852 *
Camilla Berglund23f61762013-03-12 19:53:29 +0100853 * This function destroys all remaining windows, frees any allocated resources
854 * and sets the library to an uninitialized state. Once this is called, you
855 * must again call @ref glfwInit successfully before you will be able to use
856 * most GLFW functions.
857 *
858 * If GLFW has been successfully initialized, this function should be called
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100859 * before the program exits. If initialization fails, there is no need to call
860 * this function, as it is called by @ref glfwInit before it returns failure.
Camilla Berglund23f61762013-03-12 19:53:29 +0100861 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100862 * @remarks This function may be called before @ref glfwInit.
863 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +0100864 * @note This function may only be called from the main thread.
865 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100866 * @warning No window's context may be current on another thread when this
867 * function is called.
868 *
869 * @sa glfwInit
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100870 *
871 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100872 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200873GLFWAPI void glfwTerminate(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100874
875/*! @brief Retrieves the version of the GLFW library.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100876 *
877 * This function retrieves the major, minor and revision numbers of the GLFW
878 * library. It is intended for when you are using GLFW as a shared library and
879 * want to ensure that you are using the minimum required version.
880 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100881 * @param[out] major Where to store the major version number, or `NULL`.
882 * @param[out] minor Where to store the minor version number, or `NULL`.
883 * @param[out] rev Where to store the revision number, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100884 *
885 * @remarks This function may be called before @ref glfwInit.
886 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100887 * @remarks This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100888 *
889 * @sa glfwGetVersionString
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100890 *
891 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100892 */
Camilla Berglund9a716692010-09-08 16:40:43 +0200893GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100894
Camilla Berglund6f8084f2013-02-14 13:14:17 +0100895/*! @brief Returns a string describing the compile-time configuration.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100896 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100897 * This function returns a static string generated at compile-time according to
898 * which configuration macros were defined. This is intended for use when
899 * submitting bug reports, to allow developers to see which code paths are
900 * enabled in a binary.
901 *
Camilla Berglund6f8084f2013-02-14 13:14:17 +0100902 * The format of the string is as follows:
Camilla Berglund13ccf7d2013-04-07 13:46:38 +0200903 * - The version of GLFW
904 * - The name of the window system API
905 * - The name of the context creation API
906 * - Any additional options or APIs
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100907 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100908 * For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200909 * back ends, the version string may look something like this:
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100910 *
911 * 3.0.0 Win32 WGL MinGW
912 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100913 * @return The GLFW version string.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100914 *
915 * @remarks This function may be called before @ref glfwInit.
916 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100917 * @remarks This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100918 *
919 * @sa glfwGetVersion
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100920 *
921 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100922 */
Camilla Berglundd6fe4472010-09-13 18:05:59 +0200923GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +0200924
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100925/*! @brief Sets the error callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100926 *
927 * This function sets the error callback, which is called with an error code
928 * and a human-readable description each time a GLFW error occurs.
929 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100930 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100931 * callback.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100932 *
Camilla Berglund11a27de2013-04-08 21:21:21 +0200933 * @return The previously set callback, or `NULL` if an error occurred.
934 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100935 * @remarks This function may be called before @ref glfwInit.
936 *
Camilla Berglund9bfb9252013-01-07 17:22:02 +0100937 * @note The error callback is called by the thread where the error was
938 * generated. If you are using GLFW from multiple threads, your error callback
939 * needs to be written accordingly.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100940 *
941 * @note Because the description string provided to the callback may have been
942 * generated specifically for that error, it is not guaranteed to be valid
943 * after the callback has returned. If you wish to use it after that, you need
944 * to make your own copy of it before returning.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100945 *
946 * @ingroup error
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100947 */
Camilla Berglund11a27de2013-04-08 21:21:21 +0200948GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
Camilla Berglundf5d74c42010-09-09 21:06:59 +0200949
Camilla Berglund5f68e122012-11-27 17:07:28 +0100950/*! @brief Returns the currently connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100951 *
952 * This function returns an array of handles for all currently connected
953 * monitors.
954 *
Camilla Berglundc00d0572013-05-15 15:01:42 +0200955 * @param[out] count The size of the returned array, or zero if an error
956 * occurred.
Camilla Berglund71d2b572013-03-12 15:33:05 +0100957 * @return An array of monitor handles, or `NULL` if an error occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100958 *
959 * @note The returned array is valid only until the monitor configuration
960 * changes. See @ref glfwSetMonitorCallback to receive notifications of
961 * configuration changes.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100962 *
963 * @sa glfwGetPrimaryMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100964 *
965 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100966 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100967GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100968
Camilla Berglund5f68e122012-11-27 17:07:28 +0100969/*! @brief Returns the primary monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100970 *
971 * This function returns the primary monitor. This is usually the monitor
972 * where elements like the Windows task bar or the OS X menu bar is located.
973 *
Camilla Berglund71d2b572013-03-12 15:33:05 +0100974 * @return The primary monitor, or `NULL` if an error occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +0100975 *
976 * @sa glfwGetMonitors
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100977 *
978 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +0100979 */
Camilla Berglund9af960e2013-01-05 21:13:28 +0100980GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
Camilla Berglund41bc0d12012-11-27 16:55:04 +0100981
Camilla Berglundee5f30e2013-01-24 19:10:17 +0100982/*! @brief Returns the position of the monitor's viewport on the virtual screen.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100983 *
984 * This function returns the position, in screen coordinates, of the upper-left
985 * corner of the specified monitor.
986 *
Camilla Berglunddba2d802013-01-17 23:06:56 +0100987 * @param[in] monitor The monitor to query.
Camilla Berglundee5f30e2013-01-24 19:10:17 +0100988 * @param[out] xpos The monitor x-coordinate.
989 * @param[out] ypos The monitor y-coordinate.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100990 *
Camilla Berglund5f68e122012-11-27 17:07:28 +0100991 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +0100992 */
Camilla Berglundee5f30e2013-01-24 19:10:17 +0100993GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
994
995/*! @brief Returns the physical size of the monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +0100996 *
997 * This function returns the size, in millimetres, of the display area of the
998 * specified monitor.
999 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001000 * @param[in] monitor The monitor to query.
1001 * @param[out] width The width, in mm, of the monitor's display
1002 * @param[out] height The height, in mm, of the monitor's display.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001003 *
1004 * @note Some operating systems do not provide accurate information, either
1005 * because the monitor's EDID data is incorrect, or because the driver does not
1006 * report it accurately.
1007 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001008 * @ingroup monitor
1009 */
1010GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001011
Camilla Berglund5f68e122012-11-27 17:07:28 +01001012/*! @brief Returns the name of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001013 *
1014 * This function returns a human-readable name, encoded as UTF-8, of the
1015 * specified monitor.
1016 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001017 * @param[in] monitor The monitor to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001018 * @return The UTF-8 encoded name of the monitor, or `NULL` if an error
Camilla Berglund5d6256c2013-02-25 17:53:02 +01001019 * occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001020 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001021 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001022 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001023GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001024
Camilla Berglund5f68e122012-11-27 17:07:28 +01001025/*! @brief Sets the monitor configuration callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001026 *
1027 * This function sets the monitor configuration callback, or removes the
1028 * currently set callback. This is called when a monitor is connected to or
1029 * disconnected from the system.
1030 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001031 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001032 * callback.
Camilla Berglund11a27de2013-04-08 21:21:21 +02001033 * @return The previously set callback, or `NULL` if an error occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001034 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001035 * @bug This callback is not yet called on monitor configuration changes.
1036 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001037 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001038 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001039GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
Marcel Metzbeacbb32011-05-07 10:53:50 +02001040
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001041/*! @brief Returns the available video modes for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001042 *
1043 * This function returns an array of all video modes supported by the specified
Camilla Berglund948cc042013-04-16 02:02:22 +02001044 * monitor. The returned array is sorted in ascending order, first by color
1045 * bit depth (the sum of all channel depths) and then by resolution area (the
1046 * product of width and height).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001047 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001048 * @param[in] monitor The monitor to query.
Camilla Berglundc00d0572013-05-15 15:01:42 +02001049 * @param[out] count The number of video modes in the returned array, or zero
1050 * if an error occurred.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001051 * @return An array of video modes, or `NULL` if an error occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001052 *
1053 * @note The returned array is valid only until this function is called again
Camilla Berglund948cc042013-04-16 02:02:22 +02001054 * for the specified monitor.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001055 *
1056 * @sa glfwGetVideoMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001057 *
1058 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001059 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001060GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001061
Camilla Berglund5f68e122012-11-27 17:07:28 +01001062/*! @brief Returns the current mode of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001063 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001064 * This function returns the current video mode of the specified monitor. If
1065 * you are using a full screen window, the return value will therefore depend
1066 * on whether it is focused.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001067 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001068 * @param[in] monitor The monitor to query.
Camilla Berglundce1e84d2013-05-22 22:16:43 +02001069 * @return The current mode of the monitor, or `NULL` if an error occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001070 *
1071 * @sa glfwGetVideoModes
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001072 *
1073 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001074 */
Camilla Berglundce1e84d2013-05-22 22:16:43 +02001075GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
Camilla Berglund3249f812010-09-07 17:34:51 +02001076
Camilla Berglund92a71e02013-02-12 13:50:41 +01001077/*! @brief Generates a gamma ramp and sets it for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001078 *
Camilla Berglund5d308db2013-05-19 15:46:44 +02001079 * This function generates a 256-element gamma ramp from the specified exponent
1080 * and then calls @ref glfwSetGamma with it.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001081 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01001082 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001083 * @param[in] gamma The desired exponent.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001084 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001085 * @ingroup gamma
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001086 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01001087GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001088
Camilla Berglund92a71e02013-02-12 13:50:41 +01001089/*! @brief Retrieves the current gamma ramp for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001090 *
1091 * This function retrieves the current gamma ramp of the specified monitor.
1092 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01001093 * @param[in] monitor The monitor to query.
Camilla Berglund5d308db2013-05-19 15:46:44 +02001094 * @return The current gamma ramp.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001095 *
1096 * @ingroup gamma
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001097 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02001098GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001099
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001100/*! @brief Sets the current gamma ramp for the specified monitor.
1101 *
1102 * This function sets the current gamma ramp for the specified monitor.
1103 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01001104 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001105 * @param[in] ramp The gamma ramp to use.
Camilla Berglund8954af62013-02-20 19:44:52 +01001106 *
Camilla Berglund5d308db2013-05-19 15:46:44 +02001107 * @note Gamma ramp sizes other than 256 are not supported by all hardware.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001108 *
1109 * @ingroup gamma
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001110 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01001111GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
Camilla Berglund2630d492010-10-13 04:04:43 +02001112
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001113/*! @brief Resets all window hints to their default values.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001114 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001115 * This function resets all window hints to their
Camilla Berglunde248fb62013-03-29 14:06:23 +01001116 * [default values](@ref window_hints_values).
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001117 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001118 * @note This function may only be called from the main thread.
1119 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001120 * @sa glfwWindowHint
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001121 *
1122 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001123 */
Camilla Berglund5df4df62012-10-22 02:59:05 +02001124GLFWAPI void glfwDefaultWindowHints(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001125
1126/*! @brief Sets the specified window hint to the desired value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001127 *
Camilla Berglunded9e4032012-12-23 15:59:09 +01001128 * This function sets hints for the next call to @ref glfwCreateWindow. The
1129 * hints, once set, retain their values until changed by a call to @ref
1130 * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
1131 * terminated with @ref glfwTerminate.
1132 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001133 * @param[in] target The [window hint](@ref window_hints) to set.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001134 * @param[in] hint The new value of the window hint.
1135 *
Camilla Berglund401033c2013-03-12 19:17:07 +01001136 * @par New in GLFW 3
1137 * Hints are no longer reset to their default values on window creation. To
1138 * set default hint values, use @ref glfwDefaultWindowHints.
1139 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001140 * @note This function may only be called from the main thread.
1141 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001142 * @sa glfwDefaultWindowHints
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001143 *
1144 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001145 */
Camilla Berglundaff30d02012-08-06 17:56:41 +02001146GLFWAPI void glfwWindowHint(int target, int hint);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001147
1148/*! @brief Creates a window and its associated context.
1149 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001150 * This function creates a window and its associated context. Most of the
1151 * options controlling how the window and its context should be created are
Camilla Berglundfa0cbd92013-04-11 01:07:07 +02001152 * specified through @ref glfwWindowHint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001153 *
1154 * Successful creation does not change which context is current. Before you
1155 * can use the newly created context, you need to make it current using @ref
1156 * glfwMakeContextCurrent.
1157 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001158 * Note that the created window and context may differ from what you requested,
Camilla Berglundfa0cbd92013-04-11 01:07:07 +02001159 * as not all parameters and hints are
1160 * [hard constraints](@ref window_hints_hard). This includes the size of the
1161 * window, especially for full screen windows. To retrieve the actual
1162 * properties of the window and context, use queries like @ref
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001163 * glfwGetWindowParam and @ref glfwGetWindowSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001164 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001165 * @param[in] width The desired width, in screen coordinates, of the window.
1166 * This must be greater than zero.
1167 * @param[in] height The desired height, in screen coordinates, of the window.
1168 * This must be greater than zero.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001169 * @param[in] title The initial, UTF-8 encoded window title.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001170 * @param[in] monitor The monitor to use for full screen mode, or `NULL` to use
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001171 * windowed mode.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001172 * @param[in] share The window whose context to share resources with, or `NULL`
1173 * to not share resources.
1174 * @return The handle of the created window, or `NULL` if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001175 *
Camilla Berglund6f8084f2013-02-14 13:14:17 +01001176 * @remarks To create the window at a specific position, make it initially
Camilla Berglund71d2b572013-03-12 15:33:05 +01001177 * invisible using the `GLFW_VISIBLE` window hint, set its position and then
Camilla Berglund6f8084f2013-02-14 13:14:17 +01001178 * show it.
1179 *
Camilla Berglund159f9b92013-04-10 01:57:43 +02001180 * @remarks If a fullscreen window is active, the screensaver is prohibited
1181 * from starting.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001182 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001183 * @remarks **Windows:** If the executable has an icon resource named
1184 * `GLFW_ICON,` it will be set as the icon for the window. If no such icon is
1185 * present, the `IDI_WINLOGO` icon will be used instead.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001186 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001187 * @remarks **Mac OS X:** The GLFW window has no icon, as it is not a document
1188 * window, but the dock icon will be the same as the application bundle's icon.
1189 * Also, the first time a window is opened the menu bar is populated with
1190 * common commands like Hide, Quit and About. The (minimal) about dialog uses
1191 * information from the application's bundle. For more information on bundles,
1192 * see the Bundle Programming Guide provided by Apple.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001193 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001194 * @note This function may only be called from the main thread.
1195 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001196 * @sa glfwDestroyWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001197 *
1198 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001199 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001200GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001201
1202/*! @brief Destroys the specified window and its context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001203 *
1204 * This function destroys the specified window and its context. On calling
1205 * this function, no further callbacks will be called for that window.
1206 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001207 * @param[in] window The window to destroy.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001208 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001209 * @note This function may only be called from the main thread.
1210 *
Camilla Berglundb48128f2013-02-14 18:49:03 +01001211 * @note This function may not be called from a callback.
1212 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001213 * @note If the window's context is current on the main thread, it is
1214 * detached before being destroyed.
1215 *
1216 * @warning The window's context must not be current on any other thread.
1217 *
1218 * @sa glfwCreateWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001219 *
1220 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001221 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001222GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001223
Camilla Berglund64afb192013-03-06 23:29:37 +01001224/*! @brief Checks the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001225 *
1226 * This function returns the value of the close flag of the specified window.
1227 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01001228 * @param[in] window The window to query.
Camilla Berglund64afb192013-03-06 23:29:37 +01001229 * @return The value of the close flag.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001230 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01001231 * @ingroup window
1232 */
1233GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
1234
Camilla Berglund64afb192013-03-06 23:29:37 +01001235/*! @brief Sets the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001236 *
1237 * This function sets the value of the close flag of the specified window.
1238 * This can be used to override the user's attempt to close the window, or
1239 * to signal that it should be closed.
1240 *
Camilla Berglund64afb192013-03-06 23:29:37 +01001241 * @param[in] window The window whose flag to change.
Camilla Berglund6fadf372013-03-01 13:45:12 +01001242 * @param[in] value The new value.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001243 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01001244 * @ingroup window
Camilla Berglund6fadf372013-03-01 13:45:12 +01001245 */
1246GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
1247
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001248/*! @brief Sets the title of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001249 *
1250 * This function sets the window title, encoded as UTF-8, of the specified
1251 * window.
1252 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001253 * @param[in] window The window whose title to change.
1254 * @param[in] title The UTF-8 encoded window title.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001255 *
1256 * @note This function may only be called from the main thread.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001257 *
1258 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001259 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001260GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001261
Camilla Berglund7c193232013-01-24 19:30:31 +01001262/*! @brief Retrieves the position of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001263 *
1264 * This function retrieves the position, in screen coordinates, of the
1265 * upper-left corner of the client area of the specified window.
1266 *
Camilla Berglund7c193232013-01-24 19:30:31 +01001267 * @param[in] window The window to query.
1268 * @param[out] xpos The x-coordinate of the upper-left corner of the client area.
1269 * @param[out] ypos The y-coordinate of the upper-left corner of the client area.
Camilla Berglund7c193232013-01-24 19:30:31 +01001270 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001271 * @remarks Either or both coordinate parameters may be `NULL`.
Camilla Berglund7c193232013-01-24 19:30:31 +01001272 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001273 * @bug **Mac OS X:** The screen coordinate system is inverted.
1274 *
Camilla Berglund7c193232013-01-24 19:30:31 +01001275 * @sa glfwSetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001276 *
1277 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01001278 */
1279GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
1280
1281/*! @brief Sets the position of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001282 *
1283 * This function sets the position, in screen coordinates, of the upper-left
1284 * corner of the client area of the window.
1285 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001286 * If it is a full screen window, this function does nothing.
1287 *
Camilla Berglund7c193232013-01-24 19:30:31 +01001288 * @param[in] window The window to query.
1289 * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
1290 * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
Camilla Berglund7c193232013-01-24 19:30:31 +01001291 *
1292 * @remarks If you wish to set an initial window position you should create
Camilla Berglund71d2b572013-03-12 15:33:05 +01001293 * a hidden window (using @ref glfwWindowHint and `GLFW_VISIBLE`), set its
Camilla Berglund7c193232013-01-24 19:30:31 +01001294 * position and then show it.
1295 *
1296 * @note It is very rarely a good idea to move an already visible window, as it
1297 * will confuse and annoy the user.
1298 *
1299 * @note This function may only be called from the main thread.
1300 *
1301 * @note The window manager may put limits on what positions are allowed.
1302 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001303 * @bug **X11:** Some window managers ignore the set position of hidden (i.e.
1304 * unmapped) windows, instead placing them where it thinks is appropriate once
1305 * they are shown.
Camilla Berglund7c193232013-01-24 19:30:31 +01001306 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001307 * @bug **Mac OS X:** The screen coordinate system is inverted.
Camilla Berglund7c193232013-01-24 19:30:31 +01001308 *
1309 * @sa glfwGetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001310 *
1311 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01001312 */
Camilla Berglund52f718d2013-02-12 12:01:12 +01001313GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
Camilla Berglund7c193232013-01-24 19:30:31 +01001314
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001315/*! @brief Retrieves the size of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001316 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001317 * This function retrieves the size, in screen coordinates, of the client area
1318 * of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001319 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001320 * @param[in] window The window whose size to retrieve.
1321 * @param[out] width The width of the client area.
1322 * @param[out] height The height of the client area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001323 *
1324 * @sa glfwSetWindowSize
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001325 *
1326 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001327 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001328GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001329
1330/*! @brief Sets the size of the client area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001331 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001332 * This function sets the size, in screen coordinates, of the client area of
1333 * the specified window.
1334 *
1335 * For full screen windows, this function selects and switches to the resolution
1336 * closest to the specified size, without affecting the window's context. As
1337 * the context is unaffected, the bit depths of the framebuffer remain
1338 * unchanged.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001339 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001340 * @param[in] window The window to resize.
1341 * @param[in] width The desired width of the specified window.
1342 * @param[in] height The desired height of the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001343 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001344 * @note This function may only be called from the main thread.
1345 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001346 * @note The window manager may put limits on what window sizes are allowed.
1347 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001348 * @sa glfwGetWindowSize
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001349 *
1350 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001351 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001352GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001353
1354/*! @brief Iconifies the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001355 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001356 * This function iconifies/minimizes the specified window, if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001357 * restored. If it is a full screen window, the original monitor resolution is
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001358 * restored until the window is restored. If the window is already iconified,
1359 * this function does nothing.
1360 *
1361 * @param[in] window The window to iconify.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001362 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001363 * @note This function may only be called from the main thread.
1364 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001365 * @bug **Mac OS X:** This function is not yet implemented for
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001366 * full screen windows.
Camilla Berglund8954af62013-02-20 19:44:52 +01001367 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001368 * @sa glfwRestoreWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001369 *
1370 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001371 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001372GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001373
1374/*! @brief Restores the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001375 *
1376 * This function restores the specified window, if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001377 * iconified/minimized. If it is a full screen window, the resolution chosen
1378 * for the window is restored on the selected monitor. If the window is
1379 * already restored, this function does nothing.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001380 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001381 * @param[in] window The window to restore.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001382 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001383 * @note This function may only be called from the main thread.
1384 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001385 * @bug **Mac OS X:** This function is not yet implemented for full screen
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001386 * windows.
Camilla Berglund8954af62013-02-20 19:44:52 +01001387 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001388 * @sa glfwIconifyWindow
Camilla Berglunde248fb62013-03-29 14:06:23 +01001389 *
1390 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001391 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001392GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001393
1394/*! @brief Makes the specified window visible.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001395 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001396 * This function makes the specified window visible, if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001397 * hidden. If the window is already visible or is in full screen mode, this
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001398 * function does nothing.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001399 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001400 * @param[in] window The window to make visible.
1401 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001402 * @note This function may only be called from the main thread.
1403 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001404 * @sa glfwHideWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001405 *
1406 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001407 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001408GLFWAPI void glfwShowWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001409
1410/*! @brief Hides the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001411 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001412 * This function hides the specified window, if it was previously visible. If
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001413 * the window is already hidden or is in full screen mode, this function does
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001414 * nothing.
1415 *
1416 * @param[in] window The window to hide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001417 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001418 * @note This function may only be called from the main thread.
1419 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001420 * @sa glfwShowWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001421 *
1422 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001423 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001424GLFWAPI void glfwHideWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001425
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001426/*! @brief Returns the monitor that the window uses for full screen mode.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001427 *
1428 * This function returns the handle of the monitor that the specified window is
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001429 * in full screen on.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001430 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001431 * @param[in] window The window to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001432 * @return The monitor, or `NULL` if the window is in windowed mode.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001433 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001434 * @ingroup window
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001435 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001436GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001437
Camilla Berglundf8f81e52013-02-28 21:15:04 +01001438/*! @brief Returns a parameter of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001439 *
1440 * This function returns a property of the specified window. There are many
1441 * different properties, some related to the window and others to its context.
1442 *
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001443 * @param[in] window The window to query.
Camilla Berglundf8f81e52013-02-28 21:15:04 +01001444 * @param[in] param The parameter whose value to return.
1445 * @return The value of the parameter, or zero if an error occurred.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001446 *
Camilla Berglundf8f81e52013-02-28 21:15:04 +01001447 * @par Window parameters
Camilla Berglund1bd59842013-01-13 21:28:18 +01001448 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001449 * The `GLFW_FOCUSED` parameter indicates whether the window is focused.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001450 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001451 * The `GLFW_ICONIFIED` parameter indicates whether the window is iconified.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001452 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001453 * The `GLFW_VISIBLE` parameter indicates whether the window is visible.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001454 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001455 * The `GLFW_RESIZABLE` parameter indicates whether the window is resizable
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001456 * by the user.
1457 *
Camilla Berglund7b5b33e2013-04-08 15:28:38 +02001458 * The `GLFW_DECORATED` parameter indicates whether the window is decorated.
1459 *
Camilla Berglundf8f81e52013-02-28 21:15:04 +01001460 * @par Context parameters
Camilla Berglund1bd59842013-01-13 21:28:18 +01001461 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001462 * The `GLFW_CLIENT_API` parameter indicates the client API provided by the
1463 * window's context; either `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001464 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001465 * The `GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and
1466 * `GLFW_CONTEXT_REVISION` parameters indicate the client API version of the
Camilla Berglund3f5843f2012-12-13 02:22:39 +01001467 * window's context.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001468 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001469 * The `GLFW_OPENGL_FORWARD_COMPAT` parameter is `GL_TRUE` if the window's
1470 * context is an OpenGL forward-compatible one, or `GL_FALSE` otherwise.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001471 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001472 * The `GLFW_OPENGL_DEBUG_CONTEXT` parameter is `GL_TRUE` if the window's
1473 * context is an OpenGL debug context, or `GL_FALSE` otherwise.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001474 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001475 * The `GLFW_OPENGL_PROFILE` parameter indicates the OpenGL profile used by the
1476 * context. This is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE`
1477 * if the context uses a known profile, or `GLFW_OPENGL_NO_PROFILE` if the
1478 * OpenGL profile is unknown or the context is for another client API.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01001479 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001480 * The `GLFW_CONTEXT_ROBUSTNESS` parameter indicates the robustness strategy
1481 * used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or
1482 * `GLFW_NO_RESET_NOTIFICATION` if the window's context supports robustness, or
1483 * `GLFW_NO_ROBUSTNESS` otherwise.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001484 *
1485 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001486 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001487GLFWAPI int glfwGetWindowParam(GLFWwindow* window, int param);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001488
1489/*! @brief Sets the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001490 *
1491 * This function sets the user-defined pointer of the specified window. The
1492 * current value is retained until the window is destroyed. The initial value
1493 * is `NULL`.
1494 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001495 * @param[in] window The window whose pointer to set.
1496 * @param[in] pointer The new value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001497 *
1498 * @sa glfwGetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001499 *
1500 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001501 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001502GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001503
1504/*! @brief Returns the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001505 *
1506 * This function returns the current value of the user-defined pointer of the
1507 * specified window. The initial value is `NULL`.
1508 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001509 * @param[in] window The window whose pointer to return.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001510 *
1511 * @sa glfwSetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001512 *
1513 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001514 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001515GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001516
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001517/*! @brief Sets the position callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001518 *
1519 * This function sets the position callback of the specified window, which is
1520 * called when the window is moved. The callback is provided with the screen
1521 * position of the upper-left corner of the client area of the window.
1522 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001523 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001524 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001525 * callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001526 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001527 * @return The previously set callback, or `NULL` if an error occurred.
1528 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001529 * @ingroup window
1530 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001531GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001532
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001533/*! @brief Sets the size callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001534 *
1535 * This function sets the size callback of the specified window, which is
1536 * called when the window is resized. The callback is provided with the size,
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001537 * in screen coordinates, of the client area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001538 *
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 Berglund11a27de2013-04-08 21:21:21 +02001543 * @return The previously set callback, or `NULL` if an error occurred.
1544 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001545 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001546 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001547GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001548
1549/*! @brief Sets the close callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001550 *
1551 * This function sets the close callback of the specified window, which is
1552 * called when the user attempts to close the window, for example by clicking
1553 * the close widget in the title bar.
1554 *
1555 * The close flag is set before this callback is called, but you can modify it
1556 * at any time with @ref glfwSetWindowShouldClose.
1557 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001558 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001559 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001560 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001561 *
Camilla Berglund64afb192013-03-06 23:29:37 +01001562 * @remarks Calling @ref glfwDestroyWindow does not cause this callback to be
1563 * called.
Camilla Berglund1bd59842013-01-13 21:28:18 +01001564 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001565 * @return The previously set callback, or `NULL` if an error occurred.
1566 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001567 * @remarks **Mac OS X:** Selecting Quit from the application menu will
Camilla Berglund1bd59842013-01-13 21:28:18 +01001568 * trigger the close callback for all windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001569 *
1570 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001571 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001572GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001573
1574/*! @brief Sets the refresh callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001575 *
1576 * This function sets the refresh callback of the specified window, which is
1577 * called when the client area of the window needs to be redrawn, for example
1578 * if the window has been exposed after having been covered by another window.
1579 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001580 * On compositing window systems such as Aero, Compiz or Aqua, where the window
1581 * contents are saved off-screen, this callback may be called only very
1582 * infrequently or never at all.
1583 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001584 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001585 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001586 * callback.
Camilla Berglund11a27de2013-04-08 21:21:21 +02001587 * @return The previously set callback, or `NULL` if an error occurred.
1588 *
1589 * @note On compositing window systems such as Aero, Compiz or Aqua, where the
1590 * window contents are saved off-screen, this callback may be called only very
1591 * infrequently or never at all.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001592 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001593 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001594 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001595GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001596
1597/*! @brief Sets the focus callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001598 *
1599 * This function sets the focus callback of the specified window, which is
1600 * called when the window gains or loses focus.
1601 *
Camilla Berglund4538a522013-04-24 19:49:46 +02001602 * After the focus callback is called for a window that lost focus, synthetic
1603 * key and mouse button release events will be generated for all such that had
1604 * been pressed. For more information, see @ref glfwSetKeyCallback and @ref
1605 * glfwSetMouseButtonCallback.
1606 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001607 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001608 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001609 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001610 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001611 * @return The previously set callback, or `NULL` if an error occurred.
1612 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001613 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001614 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001615GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001616
1617/*! @brief Sets the iconify callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001618 *
1619 * This function sets the iconification callback of the specified window, which
1620 * is called when the window is iconified or restored.
1621 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001622 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001623 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001624 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001625 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001626 * @return The previously set callback, or `NULL` if an error occurred.
1627 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001628 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001629 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001630GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
Camilla Berglund135194a2010-09-09 18:15:32 +02001631
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001632/*! @brief Processes all pending events.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001633 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001634 * This function processes only those events that have already been received
Camilla Berglund948cc042013-04-16 02:02:22 +02001635 * and then returns immediately. Processing events will cause the window and
1636 * input callbacks associated with those events to be called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001637 *
Camilla Berglund401033c2013-03-12 19:17:07 +01001638 * @par New in GLFW 3
1639 * This function is no longer called by @ref glfwSwapBuffers. You need to call
1640 * it or @ref glfwWaitEvents yourself.
1641 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001642 * @remarks This function is not required for joystick input to work.
1643 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001644 * @note This function may only be called from the main thread.
1645 *
Camilla Berglundb48128f2013-02-14 18:49:03 +01001646 * @note This function may not be called from a callback.
1647 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001648 * @note On some platforms, certain callbacks may be called outside of a call
1649 * to one of the event processing functions.
1650 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001651 * @sa glfwWaitEvents
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001652 *
1653 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001654 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001655GLFWAPI void glfwPollEvents(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001656
1657/*! @brief Waits until events are pending and processes them.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001658 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001659 * This function puts the calling thread to sleep until at least one event has
1660 * been received. Once one or more events have been recevied, it behaves as if
1661 * @ref glfwPollEvents was called, i.e. the events are processed and the
1662 * function then returns immediately. Processing events will cause the window
1663 * and input callbacks associated with those events to be called.
1664 *
1665 * Since not all events are associated with callbacks, this function may return
1666 * without a callback having been called even if you are monitoring all
1667 * callbacks.
1668 *
1669 * @remarks This function is not required for joystick input to work.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001670 *
Camilla Berglund9ad1d972012-11-22 19:08:30 +01001671 * @note This function may only be called from the main thread.
1672 *
Camilla Berglundb48128f2013-02-14 18:49:03 +01001673 * @note This function may not be called from a callback.
1674 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001675 * @note On some platforms, certain callbacks may be called outside of a call
1676 * to one of the event processing functions.
1677 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001678 * @sa glfwPollEvents
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001679 *
1680 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001681 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001682GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +02001683
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001684/*! @brief Returns the value of an input option for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001685 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001686 * @param[in] window The window to query.
Camilla Berglund9264b5d2013-04-26 14:29:55 +02001687 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001688 * `GLFW_STICKY_MOUSE_BUTTONS`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001689 *
1690 * @sa glfwSetInputMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001691 *
1692 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001693 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001694GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001695
1696/*! @brief Sets an input option for the specified window.
Camilla Berglund9492fc52013-01-17 17:51:12 +01001697 * @param[in] window The window whose input mode to set.
Camilla Berglund9264b5d2013-04-26 14:29:55 +02001698 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
Camilla Berglund71d2b572013-03-12 15:33:05 +01001699 * `GLFW_STICKY_MOUSE_BUTTONS`.
Camilla Berglund9492fc52013-01-17 17:51:12 +01001700 * @param[in] value The new value of the specified input mode.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001701 *
Camilla Berglund9264b5d2013-04-26 14:29:55 +02001702 * If `mode` is `GLFW_CURSOR`, the value must be one of the supported input
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001703 * modes:
Camilla Berglund13ccf7d2013-04-07 13:46:38 +02001704 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
1705 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001706 * area of the window.
Camilla Berglund6df692b2013-04-26 17:20:31 +02001707 * - `GLFW_CURSOR_DISABLED` disables the cursor and removes any limitations on
1708 * cursor movement.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01001709 *
1710 * If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
1711 * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are
1712 * enabled, a key press will ensure that @ref glfwGetKey returns @ref
1713 * GLFW_PRESS the next time it is called even if the key had been released
1714 * before the call.
1715 *
1716 * If `mode` is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either `GL_TRUE`
1717 * to enable sticky mouse buttons, or `GL_FALSE` to disable it. If sticky
1718 * mouse buttons are enabled, a mouse button press will ensure that @ref
1719 * glfwGetMouseButton returns @ref GLFW_PRESS the next time it is called even
1720 * if the mouse button had been released before the call.
1721 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001722 * @sa glfwGetInputMode
Camilla Berglunde248fb62013-03-29 14:06:23 +01001723 *
1724 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001725 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001726GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001727
1728/*! @brief Returns the last reported state of a keyboard key for the specified
1729 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001730 *
1731 * This function returns the last state reported for the specified key to the
1732 * specified window. The returned state is one of `GLFW_PRESS` or
1733 * `GLFW_RELEASE`. The higher-level state `GLFW_REPEAT` is only reported to
1734 * the key callback.
1735 *
1736 * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
1737 * `GLFW_PRESS` the first time you call this function after a key has been
1738 * pressed, even if the key has already been released.
1739 *
1740 * The key functions deal with physical keys, with [key tokens](@ref keys)
1741 * named after their use on the standard US keyboard layout. If you want to
1742 * input text, use the Unicode character callback instead.
1743 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001744 * @param[in] window The desired window.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001745 * @param[in] key The desired [keyboard key](@ref keys).
1746 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001747 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001748 * @ingroup input
1749 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001750GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001751
1752/*! @brief Returns the last reported state of a mouse button for the specified
1753 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001754 *
1755 * This function returns the last state reported for the specified mouse button
1756 * to the specified window.
1757 *
1758 * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
1759 * returns `GLFW_PRESS` the first time you call this function after a mouse
1760 * button has been pressed, even if the mouse button has already been released.
1761 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001762 * @param[in] window The desired window.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001763 * @param[in] button The desired [mouse button](@ref buttons).
1764 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001765 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001766 * @ingroup input
1767 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001768GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001769
1770/*! @brief Retrieves the last reported cursor position, relative to the client
1771 * area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001772 *
1773 * This function returns the last reported position of the cursor to the
1774 * specified window.
1775 *
Camilla Berglund6df692b2013-04-26 17:20:31 +02001776 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
1777 * position is unbounded and limited only by the minimum and maximum values of
1778 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02001779 *
Camilla Berglund3ec29252013-04-25 18:03:15 +02001780 * The coordinate can be converted to their integer equivalents with the
1781 * `floor` function. Casting directly to an integer type works for positive
1782 * coordinates, but fails for negative ones.
1783 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001784 * @param[in] window The desired window.
1785 * @param[out] xpos The cursor x-coordinate, relative to the left edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001786 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001787 * @param[out] ypos The cursor y-coordinate, relative to the to top edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001788 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001789 *
1790 * @sa glfwSetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001791 *
1792 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001793 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02001794GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001795
1796/*! @brief Sets the position of the cursor, relative to the client area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001797 *
1798 * This function sets the position of the cursor. The specified window must be
1799 * focused. If the window does not have focus when this function is called, it
1800 * fails silently.
1801 *
Camilla Berglund6df692b2013-04-26 17:20:31 +02001802 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
1803 * position is unbounded and limited only by the minimum and maximum values of
1804 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02001805 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001806 * @param[in] window The desired window.
1807 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001808 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001809 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001810 * client area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001811 *
1812 * @sa glfwGetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001813 *
1814 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001815 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02001816GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001817
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001818/*! @brief Sets the key callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001819 *
1820 * This function sets the key callback of the specific window, which is called
1821 * when a key is pressed, repeated or released.
1822 *
Camilla Berglund948cc042013-04-16 02:02:22 +02001823 * The key functions deal with physical keys, with layout independent
1824 * [key tokens](@ref keys) named after their values in the standard US keyboard
1825 * layout. If you want to input text, use the [character callback](@ref
1826 * glfwSetCharCallback) instead.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001827 *
Camilla Berglund4538a522013-04-24 19:49:46 +02001828 * When a window loses focus, it will generate synthetic key release events
1829 * for all pressed keys. You can tell these events from user-generated events
1830 * by the fact that the synthetic ones are generated after the window has lost
1831 * focus, i.e. `GLFW_FOCUSED` will be false and the focus callback will have
1832 * already been called.
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 key callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001836 * set 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 GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001843
1844/*! @brief Sets the Unicode character callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001845 *
1846 * This function sets the character callback of the specific window, which is
1847 * called when a Unicode character is input.
1848 *
1849 * The character callback is intended for text input. If you want to know
1850 * whether a specific key was pressed or released, use the
1851 * [key callback](@ref glfwSetKeyCallback) instead.
1852 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001853 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001854 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001855 * callback.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001856 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001857 * @return The previously set callback, or `NULL` if an error occurred.
1858 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001859 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001860 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001861GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001862
1863/*! @brief Sets the mouse button callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001864 *
1865 * This function sets the mouse button callback of the specified window, which
1866 * is called when a mouse button is pressed or released.
1867 *
Camilla Berglund4538a522013-04-24 19:49:46 +02001868 * When a window loses focus, it will generate synthetic mouse button release
1869 * events for all pressed mouse buttons. You can tell these events from
1870 * user-generated events by the fact that the synthetic ones are generated
1871 * after the window has lost focus, i.e. `GLFW_FOCUSED` will be false and the
1872 * focus callback will have already been called.
1873 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001874 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001875 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001876 * callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001877 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001878 * @return The previously set callback, or `NULL` if an error occurred.
1879 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001880 * @ingroup input
1881 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001882GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001883
1884/*! @brief Sets the cursor position callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001885 *
1886 * This function sets the cursor position callback of the specified window,
1887 * which is called when the cursor is moved. The callback is provided with the
1888 * position relative to the upper-left corner of the client area of the window.
1889 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001890 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001891 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001892 * callback.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001893 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001894 * @return The previously set callback, or `NULL` if an error occurred.
1895 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001896 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001897 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001898GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001899
1900/*! @brief Sets the cursor enter/exit callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001901 *
1902 * This function sets the cursor boundary crossing callback of the specified
1903 * window, which is called when the cursor enters or leaves the client area of
1904 * the window.
1905 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001906 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001907 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01001908 * callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001909 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001910 * @return The previously set callback, or `NULL` if an error occurred.
1911 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001912 * @ingroup input
1913 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001914GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001915
1916/*! @brief Sets the scroll callback.
Camilla Berglunde248fb62013-03-29 14:06:23 +01001917 *
1918 * This function sets the scroll callback of the specified window, which is
1919 * called when a scrolling device is used, such as a mouse wheel or scrolling
1920 * area of a touchpad.
1921 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01001922 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001923 * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001924 * set callback.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001925 *
Camilla Berglunda59c82c2013-03-01 15:20:29 +01001926 * @remarks This receives all scrolling input, like that from a mouse wheel or
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001927 * a touchpad scrolling area.
Camilla Berglunde248fb62013-03-29 14:06:23 +01001928 *
Camilla Berglund11a27de2013-04-08 21:21:21 +02001929 * @return The previously set callback, or `NULL` if an error occurred.
1930 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001931 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001932 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001933GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
Camilla Berglund3249f812010-09-07 17:34:51 +02001934
Camilla Berglundfdd45182013-05-27 15:13:09 +02001935/*! @brief Returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001936 *
Camilla Berglundfdd45182013-05-27 15:13:09 +02001937 * This function returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001938 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001939 * @param[in] joy The joystick to query.
Camilla Berglundfdd45182013-05-27 15:13:09 +02001940 * @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001941 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001942 * @ingroup input
1943 */
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001944GLFWAPI int glfwJoystickPresent(int joy);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001945
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001946/*! @brief Returns the values of all axes of the specified joystick.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001947 * @param[in] joy The joystick to query.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001948 * @param[out] count The size of the returned array.
1949 * @return An array of axis values, or @c NULL if the joystick is not present.
1950 *
1951 * @note The returned array is valid only until the next call to @ref
1952 * glfwGetJoystickAxes for that joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001953 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001954 * @ingroup input
1955 */
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001956GLFWAPI float* glfwGetJoystickAxes(int joy, int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001957
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001958/*! @brief Returns the values of all buttons of the specified joystick.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001959 * @param[in] joy The joystick to query.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001960 * @param[out] count The size of the returned array.
1961 * @return An array of axis values, or @c NULL if the joystick is not present.
1962 *
1963 * @note The returned array is valid only until the next call to @ref
1964 * glfwGetJoystickButtons for that joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001965 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001966 * @ingroup input
1967 */
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02001968GLFWAPI unsigned char* glfwGetJoystickButtons(int joy, int* count);
Camilla Berglund3249f812010-09-07 17:34:51 +02001969
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001970/*! @brief Returns the name of the specified joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001971 *
1972 * This function returns the name, encoded as UTF-8, of the specified joystick.
1973 *
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001974 * @param[in] joy The joystick to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001975 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001976 * is not present.
Camilla Berglundd4a08b12012-12-02 17:13:41 +01001977 *
1978 * @note The returned string is valid only until the next call to @ref
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001979 * glfwGetJoystickName for that joystick.
1980 *
1981 * @ingroup input
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01001982 */
Camilla Berglund93a1d1c2012-09-07 01:01:34 +02001983GLFWAPI const char* glfwGetJoystickName(int joy);
Camilla Berglund3249f812010-09-07 17:34:51 +02001984
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001985/*! @brief Sets the clipboard to the specified string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001986 *
1987 * This function sets the system clipboard to the specified, UTF-8 encoded
1988 * string. The string is copied before returning, so you don't have to retain
1989 * it afterwards.
1990 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001991 * @param[in] window The window that will own the clipboard contents.
1992 * @param[in] string A UTF-8 encoded string.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001993 *
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01001994 * @note This function may only be called from the main thread.
1995 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001996 * @sa glfwGetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001997 *
1998 * @ingroup clipboard
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001999 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002000GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002001
2002/*! @brief Retrieves the contents of the clipboard as a string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002003 *
2004 * This function returns the contents of the system clipboard, if it contains
2005 * or is convertible to a UTF-8 encoded string.
2006 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002007 * @param[in] window The window that will request the clipboard contents.
Camilla Berglund71d2b572013-03-12 15:33:05 +01002008 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
Camilla Berglund5d6256c2013-02-25 17:53:02 +01002009 * if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002010 *
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01002011 * @note This function may only be called from the main thread.
2012 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002013 * @note The returned string is valid only until the next call to @ref
2014 * glfwGetClipboardString or @ref glfwSetClipboardString.
2015 *
2016 * @sa glfwSetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002017 *
2018 * @ingroup clipboard
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002019 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002020GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
Ralph Eastwood31c91542011-09-21 10:09:47 +01002021
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002022/*! @brief Returns the value of the GLFW timer.
2023 *
2024 * This function returns the value of the GLFW timer. Unless the timer has
2025 * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
2026 * was initialized.
2027 *
Camilla Berglund5d6256c2013-02-25 17:53:02 +01002028 * @return The current value, in seconds, or zero if an error occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002029 *
2030 * @remarks This function may be called from secondary threads.
2031 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002032 * @note The resolution of the timer is system dependent, but is usually on the
2033 * order of a few micro- or nanoseconds. It uses the highest-resolution
2034 * monotonic time source on each supported platform.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002035 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002036 * @ingroup time
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002037 */
Camilla Berglund9a716692010-09-08 16:40:43 +02002038GLFWAPI double glfwGetTime(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02002039
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002040/*! @brief Sets the GLFW timer.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002041 *
2042 * This function sets the value of the GLFW timer. It then continues to count
2043 * up from that value.
2044 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002045 * @param[in] time The new value, in seconds.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002046 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002047 * @note The resolution of the timer is system dependent, but is usually on the
2048 * order of a few micro- or nanoseconds. It uses the highest-resolution
2049 * monotonic time source on each supported platform.
Camilla Berglunde248fb62013-03-29 14:06:23 +01002050 *
2051 * @ingroup time
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002052 */
2053GLFWAPI void glfwSetTime(double time);
2054
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002055/*! @brief Makes the context of the specified window current for the calling
2056 * thread.
2057 *
2058 * This function makes the context of the specified window current on the
2059 * calling thread. A context can only be made current on a single thread at
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002060 * a time and each thread can have only a single current context at a time.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002061 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01002062 * @param[in] window The window whose context to make current, or `NULL` to
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002063 * detach the current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002064 *
2065 * @remarks This function may be called from secondary threads.
2066 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002067 * @sa glfwGetCurrentContext
Camilla Berglunde248fb62013-03-29 14:06:23 +01002068 *
2069 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002070 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002071GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002072
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002073/*! @brief Returns the window whose context is current on the calling thread.
2074 *
2075 * This function returns the window whose context is current on the calling
2076 * thread.
2077 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01002078 * @return The window whose context is current, or `NULL` if no window's
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002079 * context is current.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002080 *
2081 * @remarks This function may be called from secondary threads.
2082 *
2083 * @sa glfwMakeContextCurrent
Camilla Berglunde248fb62013-03-29 14:06:23 +01002084 *
2085 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002086 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002087GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002088
2089/*! @brief Swaps the front and back buffers of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002090 *
2091 * This function swaps the front and back buffers of the specified window. If
2092 * the swap interval is greater than zero, the GPU driver waits the specified
2093 * number of screen updates before swapping the buffers.
2094 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01002095 * @param[in] window The window whose buffers to swap.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002096 *
2097 * @remarks This function may be called from secondary threads.
2098 *
Camilla Berglund401033c2013-03-12 19:17:07 +01002099 * @par New in GLFW 3
2100 * This function no longer calls @ref glfwPollEvents. You need to call it or
2101 * @ref glfwWaitEvents yourself.
2102 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002103 * @sa glfwSwapInterval
Camilla Berglunde248fb62013-03-29 14:06:23 +01002104 *
2105 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002106 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002107GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002108
2109/*! @brief Sets the swap interval for the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002110 *
2111 * This function sets the swap interval for the current context, i.e. the
2112 * number of screen updates to wait before swapping the buffers of a window and
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002113 * returning from @ref glfwSwapBuffers. This is sometimes called 'vertical
2114 * synchronization', 'vertical retrace synchronization' or 'vsync'.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002115 *
2116 * @param[in] interval The minimum number of screen updates to wait for
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002117 * until the buffers are swapped by @ref glfwSwapBuffers.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002118 *
2119 * @remarks This function may be called from secondary threads.
2120 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002121 * @remarks Contexts that support either of the `WGL_EXT_swap_control_tear` and
2122 * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,
2123 * which allow the driver to swap even if a frame arrives a little bit late.
2124 * You can check for the presence of these extensions using @ref
2125 * glfwExtensionSupported. For more information about swap tearing, see the
2126 * extension specifications.
2127 *
2128 * @note Some GPU drivers do not honor the requested swap interval, either
2129 * because of user settings that override the request or due to bugs in the
2130 * driver.
2131 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002132 * @sa glfwSwapBuffers
Camilla Berglunde248fb62013-03-29 14:06:23 +01002133 *
2134 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002135 */
2136GLFWAPI void glfwSwapInterval(int interval);
2137
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002138/*! @brief Returns whether the specified extension is available.
2139 *
Camilla Berglund608109c2013-04-11 20:18:46 +02002140 * This function returns whether the specified
2141 * [OpenGL or context creation API extension](@ref glext) is supported by the
2142 * current context. For example, on Windows both the OpenGL and WGL extension
2143 * strings are checked.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002144 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002145 * @param[in] extension The ASCII encoded name of the extension.
Camilla Berglund71d2b572013-03-12 15:33:05 +01002146 * @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002147 *
2148 * @remarks This function may be called from secondary threads.
2149 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002150 * @note As this functions searches one or more extension strings on each call,
2151 * it is recommended that you cache its results if it's going to be used
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002152 * frequently. The extension strings will not change during the lifetime of
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002153 * a context, so there is no danger in doing this.
Camilla Berglunde248fb62013-03-29 14:06:23 +01002154 *
2155 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002156 */
2157GLFWAPI int glfwExtensionSupported(const char* extension);
2158
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002159/*! @brief Returns the address of the specified function for the current
2160 * context.
2161 *
Camilla Berglund608109c2013-04-11 20:18:46 +02002162 * This function returns the address of the specified
2163 * [client API or extension function](@ref glext), if it is supported by the
2164 * current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002165 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002166 * @param[in] procname The ASCII encoded name of the function.
Camilla Berglund71d2b572013-03-12 15:33:05 +01002167 * @return The address of the function, or `NULL` if the function is
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002168 * unavailable.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002169 *
2170 * @remarks This function may be called from secondary threads.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002171 *
2172 * @note The addresses of these functions are not guaranteed to be the same for
2173 * all contexts, especially if they use different client APIs or even different
2174 * context creation hints.
2175 *
2176 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002177 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02002178GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
Camilla Berglund3249f812010-09-07 17:34:51 +02002179
Camilla Berglund3249f812010-09-07 17:34:51 +02002180
Camilla Berglund4afc67c2011-07-27 17:09:17 +02002181/*************************************************************************
2182 * Global definition cleanup
2183 *************************************************************************/
2184
2185/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
2186
Camilla Berglund4afc67c2011-07-27 17:09:17 +02002187#ifdef GLFW_WINGDIAPI_DEFINED
2188 #undef WINGDIAPI
2189 #undef GLFW_WINGDIAPI_DEFINED
2190#endif
2191
2192#ifdef GLFW_CALLBACK_DEFINED
2193 #undef CALLBACK
2194 #undef GLFW_CALLBACK_DEFINED
2195#endif
2196
2197/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
2198
2199
Camilla Berglund3249f812010-09-07 17:34:51 +02002200#ifdef __cplusplus
2201}
2202#endif
2203
Camilla Berglundf8df91d2013-01-15 01:59:56 +01002204#endif /* _glfw3_h_ */
Camilla Berglund3249f812010-09-07 17:34:51 +02002205