blob: 57d5c9c0d5ffff7a5d5b3a3f7234db08898fcc23 [file] [log] [blame]
Camilla Berglund2955cd32010-11-17 15:42:55 +01001/*************************************************************************
Camilla Berglund53fafad2016-08-18 23:42:15 +02002 * GLFW 3.3 - www.glfw.org
Camilla Berglund3cfc4002013-07-29 20:53:17 +02003 * A library for OpenGL, window and input
Camilla Berglund3249f812010-09-07 17:34:51 +02004 *------------------------------------------------------------------------
5 * Copyright (c) 2002-2006 Marcus Geelnard
Camilla Löwyf4d0c832016-11-21 16:23:59 +01006 * Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
Camilla Berglund3249f812010-09-07 17:34:51 +02007 *
8 * This software is provided 'as-is', without any express or implied
9 * warranty. In no event will the authors be held liable for any damages
10 * arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose,
13 * including commercial applications, and to alter it and redistribute it
14 * freely, subject to the following restrictions:
15 *
16 * 1. The origin of this software must not be misrepresented; you must not
17 * claim that you wrote the original software. If you use this software
18 * in a product, an acknowledgment in the product documentation would
19 * be appreciated but is not required.
20 *
21 * 2. Altered source versions must be plainly marked as such, and must not
22 * be misrepresented as being the original software.
23 *
24 * 3. This notice may not be removed or altered from any source
25 * distribution.
26 *
27 *************************************************************************/
28
Camilla Berglundf8df91d2013-01-15 01:59:56 +010029#ifndef _glfw3_h_
30#define _glfw3_h_
Camilla Berglund3249f812010-09-07 17:34:51 +020031
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36
37/*************************************************************************
Camilla Berglundbce2cd62012-11-22 16:38:24 +010038 * Doxygen documentation
39 *************************************************************************/
40
Camilla Berglund318e8ac2015-10-24 20:48:46 +020041/*! @file glfw3.h
42 * @brief The header of the GLFW 3 API.
43 *
44 * This is the header file of the GLFW 3 API. It defines all its types and
45 * declares all its functions.
46 *
47 * For more information about how to use this file, see @ref build_include.
48 */
Camilla Berglund80c203f2016-02-19 10:29:13 +010049/*! @defgroup context Context reference
Camilla Löwy21eabd32017-02-06 17:31:25 +010050 * @brief Functions and types related to OpenGL and OpenGL ES contexts.
Camilla Berglund4591ad22014-09-18 15:03:29 +020051 *
Camilla Berglund80c203f2016-02-19 10:29:13 +010052 * This is the reference documentation for OpenGL and OpenGL ES context related
53 * functions. For more task-oriented information, see the @ref context_guide.
Camilla Berglund3f5843f2012-12-13 02:22:39 +010054 */
Camilla Berglund80c203f2016-02-19 10:29:13 +010055/*! @defgroup vulkan Vulkan reference
Camilla Löwy21eabd32017-02-06 17:31:25 +010056 * @brief Functions and types related to Vulkan.
Camilla Berglund9b75bff2015-08-10 20:19:04 +020057 *
Camilla Berglund80c203f2016-02-19 10:29:13 +010058 * This is the reference documentation for Vulkan related functions and types.
59 * For more task-oriented information, see the @ref vulkan_guide.
Camilla Berglund9b75bff2015-08-10 20:19:04 +020060 */
Camilla Berglund80c203f2016-02-19 10:29:13 +010061/*! @defgroup init Initialization, version and error reference
Camilla Löwy21eabd32017-02-06 17:31:25 +010062 * @brief Functions and types related to initialization and error handling.
Camilla Berglund4591ad22014-09-18 15:03:29 +020063 *
64 * This is the reference documentation for initialization and termination of
Camilla Berglund80c203f2016-02-19 10:29:13 +010065 * the library, version management and error handling. For more task-oriented
66 * information, see the @ref intro_guide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +010067 */
Camilla Berglund80c203f2016-02-19 10:29:13 +010068/*! @defgroup input Input reference
Camilla Löwy21eabd32017-02-06 17:31:25 +010069 * @brief Functions and types related to input handling.
Camilla Berglund4591ad22014-09-18 15:03:29 +020070 *
71 * This is the reference documentation for input related functions and types.
Camilla Berglund80c203f2016-02-19 10:29:13 +010072 * For more task-oriented information, see the @ref input_guide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +010073 */
Camilla Berglund80c203f2016-02-19 10:29:13 +010074/*! @defgroup monitor Monitor reference
Camilla Löwy21eabd32017-02-06 17:31:25 +010075 * @brief Functions and types related to monitors.
Camilla Berglundf5f55e32013-06-17 12:56:36 +020076 *
77 * This is the reference documentation for monitor related functions and types.
Camilla Berglund80c203f2016-02-19 10:29:13 +010078 * For more task-oriented information, see the @ref monitor_guide.
Camilla Berglund5f68e122012-11-27 17:07:28 +010079 */
Camilla Berglund80c203f2016-02-19 10:29:13 +010080/*! @defgroup window Window reference
Camilla Löwy21eabd32017-02-06 17:31:25 +010081 * @brief Functions and types related to windows.
Camilla Berglundbce2cd62012-11-22 16:38:24 +010082 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +020083 * This is the reference documentation for window related functions and types,
Camilla Berglund80c203f2016-02-19 10:29:13 +010084 * including creation, deletion and event polling. For more task-oriented
85 * information, see the @ref window_guide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +010086 */
Camilla Berglundbce2cd62012-11-22 16:38:24 +010087
88
89/*************************************************************************
Camilla Berglund8d910d72015-02-22 18:35:10 +010090 * Compiler- and platform-specific preprocessor work
Camilla Berglund3249f812010-09-07 17:34:51 +020091 *************************************************************************/
92
Camilla Berglund8d910d72015-02-22 18:35:10 +010093/* If we are we on Windows, we want a single define for it.
Camilla Berglund3249f812010-09-07 17:34:51 +020094 */
Camilla Berglunde8ce4ab2015-02-22 18:18:43 +010095#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
Camilla Berglund3249f812010-09-07 17:34:51 +020096 #define _WIN32
97#endif /* _WIN32 */
98
Camilla Berglund8d910d72015-02-22 18:35:10 +010099/* It is customary to use APIENTRY for OpenGL function pointer declarations on
100 * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
Camilla Berglund3249f812010-09-07 17:34:51 +0200101 */
102#ifndef APIENTRY
103 #ifdef _WIN32
104 #define APIENTRY __stdcall
105 #else
106 #define APIENTRY
107 #endif
Camilla Löwyc23fca62017-08-21 14:37:38 +0200108 #define GLFW_APIENTRY_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200109#endif /* APIENTRY */
110
Camilla Berglund8d910d72015-02-22 18:35:10 +0100111/* Some Windows OpenGL headers need this.
Camilla Berglund3249f812010-09-07 17:34:51 +0200112 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200113#if !defined(WINGDIAPI) && defined(_WIN32)
Camilla Berglundc5353642015-02-22 18:14:30 +0100114 #define WINGDIAPI __declspec(dllimport)
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200115 #define GLFW_WINGDIAPI_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200116#endif /* WINGDIAPI */
117
Camilla Berglund8d910d72015-02-22 18:35:10 +0100118/* Some Windows GLU headers need this.
119 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200120#if !defined(CALLBACK) && defined(_WIN32)
Camilla Berglundd586fe62015-02-22 18:17:34 +0100121 #define CALLBACK __stdcall
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200122 #define GLFW_CALLBACK_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200123#endif /* CALLBACK */
124
Camilla Berglund70423af2016-07-21 00:15:07 +0200125/* Include because most Windows GLU headers need wchar_t and
Camilla Berglund8d6f2652016-10-20 00:50:54 +0200126 * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
Camilla Berglund8221aad2016-03-06 09:40:16 +0100127 * Include it unconditionally to avoid surprising side-effects.
Camilla Berglund8d910d72015-02-22 18:35:10 +0100128 */
Camilla Berglund8221aad2016-03-06 09:40:16 +0100129#include <stddef.h>
Camilla Berglund70423af2016-07-21 00:15:07 +0200130
131/* Include because it is needed by Vulkan and related functions.
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200132 * Include it unconditionally to avoid surprising side-effects.
Camilla Berglund70423af2016-07-21 00:15:07 +0200133 */
Camilla Berglund5661d032016-03-23 10:09:07 +0100134#include <stdint.h>
Camilla Berglund3249f812010-09-07 17:34:51 +0200135
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200136/* Include the chosen OpenGL or OpenGL ES headers.
Camilla Berglundc93b1202013-09-08 16:07:34 +0200137 */
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200138#if defined(GLFW_INCLUDE_ES1)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200139
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200140 #include <GLES/gl.h>
141 #if defined(GLFW_INCLUDE_GLEXT)
142 #include <GLES/glext.h>
143 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200144
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200145#elif defined(GLFW_INCLUDE_ES2)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200146
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200147 #include <GLES2/gl2.h>
148 #if defined(GLFW_INCLUDE_GLEXT)
149 #include <GLES2/gl2ext.h>
150 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200151
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200152#elif defined(GLFW_INCLUDE_ES3)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200153
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200154 #include <GLES3/gl3.h>
155 #if defined(GLFW_INCLUDE_GLEXT)
156 #include <GLES2/gl2ext.h>
157 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200158
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200159#elif defined(GLFW_INCLUDE_ES31)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200160
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200161 #include <GLES3/gl31.h>
162 #if defined(GLFW_INCLUDE_GLEXT)
163 #include <GLES2/gl2ext.h>
164 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200165
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200166#elif defined(GLFW_INCLUDE_ES32)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200167
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200168 #include <GLES3/gl32.h>
169 #if defined(GLFW_INCLUDE_GLEXT)
170 #include <GLES2/gl2ext.h>
171 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200172
173#elif defined(GLFW_INCLUDE_GLCOREARB)
174
175 #if defined(__APPLE__)
176
Camilla Berglund1591caa2015-01-08 06:56:17 +0100177 #include <OpenGL/gl3.h>
178 #if defined(GLFW_INCLUDE_GLEXT)
179 #include <OpenGL/gl3ext.h>
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200180 #endif /*GLFW_INCLUDE_GLEXT*/
181
182 #else /*__APPLE__*/
183
184 #include <GL/glcorearb.h>
185
186 #endif /*__APPLE__*/
187
188#elif !defined(GLFW_INCLUDE_NONE)
189
190 #if defined(__APPLE__)
191
Camilla Berglund1591caa2015-01-08 06:56:17 +0100192 #if !defined(GLFW_INCLUDE_GLEXT)
193 #define GL_GLEXT_LEGACY
Camilla Berglundc93b1202013-09-08 16:07:34 +0200194 #endif
Camilla Berglund1591caa2015-01-08 06:56:17 +0100195 #include <OpenGL/gl.h>
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200196 #if defined(GLFW_INCLUDE_GLU)
197 #include <OpenGL/glu.h>
198 #endif
199
200 #else /*__APPLE__*/
201
Camilla Berglund1591caa2015-01-08 06:56:17 +0100202 #include <GL/gl.h>
203 #if defined(GLFW_INCLUDE_GLEXT)
204 #include <GL/glext.h>
205 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200206 #if defined(GLFW_INCLUDE_GLU)
207 #include <GL/glu.h>
208 #endif
209
210 #endif /*__APPLE__*/
211
212#endif /* OpenGL and OpenGL ES headers */
213
Camilla Berglund433db8f2016-09-14 21:13:33 +0200214#if defined(GLFW_INCLUDE_VULKAN)
Camilla Berglunde94d1662016-10-14 01:46:56 +0200215 #include <vulkan/vulkan.h>
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200216#endif /* Vulkan header */
Camilla Berglund3249f812010-09-07 17:34:51 +0200217
Camilla Berglundcc5d7cd2012-03-25 17:43:02 +0200218#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
Camilla Berglunde8e05d42014-04-23 13:30:11 +0200219 /* GLFW_DLL must be defined by applications that are linking against the DLL
220 * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
221 * configuration header when compiling the DLL version of the library.
Camilla Berglundbd2d5712013-07-23 01:59:27 +0200222 */
Camilla Berglund0df4e062015-12-13 14:07:27 +0100223 #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
Camilla Berglundcc5d7cd2012-03-25 17:43:02 +0200224#endif
225
Camilla Berglund1591caa2015-01-08 06:56:17 +0100226/* GLFWAPI is used to declare public API functions for export
227 * from the DLL / shared library / dynamic library.
228 */
Camilla Berglund2588c9b2012-03-25 17:40:30 +0200229#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
Camilla Berglund3afa8312014-10-13 14:13:08 +0200230 /* We are building GLFW as a Win32 DLL */
Camilla Berglund2955cd32010-11-17 15:42:55 +0100231 #define GLFWAPI __declspec(dllexport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200232#elif defined(_WIN32) && defined(GLFW_DLL)
Camilla Berglund3afa8312014-10-13 14:13:08 +0200233 /* We are calling GLFW as a Win32 DLL */
Camilla Berglund1247fc02015-02-22 18:10:20 +0100234 #define GLFWAPI __declspec(dllimport)
John Bartholomew93f4eff2013-05-01 13:08:09 +0100235#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
Camilla Berglund3afa8312014-10-13 14:13:08 +0200236 /* We are building GLFW as a shared / dynamic library */
John Bartholomew93f4eff2013-05-01 13:08:09 +0100237 #define GLFWAPI __attribute__((visibility("default")))
Camilla Berglund3249f812010-09-07 17:34:51 +0200238#else
Camilla Berglund3afa8312014-10-13 14:13:08 +0200239 /* We are building or calling GLFW as a static library */
Camilla Berglund3249f812010-09-07 17:34:51 +0200240 #define GLFWAPI
Camilla Berglund3249f812010-09-07 17:34:51 +0200241#endif
242
Camilla Berglund3249f812010-09-07 17:34:51 +0200243
244/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100245 * GLFW API tokens
Camilla Berglund3249f812010-09-07 17:34:51 +0200246 *************************************************************************/
247
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100248/*! @name GLFW version macros
249 * @{ */
250/*! @brief The major version number of the GLFW library.
251 *
252 * This is incremented when the API is changed in non-compatible ways.
253 * @ingroup init
254 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100255#define GLFW_VERSION_MAJOR 3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100256/*! @brief The minor version number of the GLFW library.
257 *
258 * This is incremented when features are added to the API but it remains
259 * backward-compatible.
260 * @ingroup init
261 */
Camilla Berglund53fafad2016-08-18 23:42:15 +0200262#define GLFW_VERSION_MINOR 3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100263/*! @brief The revision number of the GLFW library.
264 *
265 * This is incremented when a bug fix release is made that does not contain any
266 * API changes.
267 * @ingroup init
268 */
Camilla Berglund53fafad2016-08-18 23:42:15 +0200269#define GLFW_VERSION_REVISION 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100270/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200271
Camilla Berglund0eccf752015-08-23 19:30:04 +0200272/*! @brief One.
273 *
Camilla Löwy04116782018-11-05 17:37:49 +0100274 * This is only semantic sugar for the number 1. You can instead use `1` or
275 * `true` or `_True` or `GL_TRUE` or anything else that is equal to one.
276 *
277 * @ingroup init
Camilla Berglund0eccf752015-08-23 19:30:04 +0200278 */
279#define GLFW_TRUE 1
280/*! @brief Zero.
281 *
Camilla Löwy04116782018-11-05 17:37:49 +0100282 * This is only semantic sugar for the number 0. You can instead use `0` or
283 * `false` or `_False` or `GL_FALSE` or anything else that is equal to zero.
284 *
285 * @ingroup init
Camilla Berglund0eccf752015-08-23 19:30:04 +0200286 */
287#define GLFW_FALSE 0
Camilla Berglund0eccf752015-08-23 19:30:04 +0200288
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100289/*! @name Key and button actions
290 * @{ */
Camilla Berglund4591ad22014-09-18 15:03:29 +0200291/*! @brief The key or mouse button was released.
292 *
293 * The key or mouse button was released.
294 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100295 * @ingroup input
296 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100297#define GLFW_RELEASE 0
Camilla Berglund4591ad22014-09-18 15:03:29 +0200298/*! @brief The key or mouse button was pressed.
299 *
300 * The key or mouse button was pressed.
301 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100302 * @ingroup input
303 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100304#define GLFW_PRESS 1
Camilla Berglund253e0d62013-01-12 17:06:35 +0100305/*! @brief The key was held down until it repeated.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200306 *
307 * The key was held down until it repeated.
308 *
Camilla Berglund253e0d62013-01-12 17:06:35 +0100309 * @ingroup input
310 */
311#define GLFW_REPEAT 2
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100312/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200313
Camilla Löwy798d7c62017-03-01 23:27:20 +0100314/*! @defgroup hat_state Joystick hat states
Camilla Löwy04116782018-11-05 17:37:49 +0100315 * @brief Joystick hat states.
IntellectualKitty368dec72016-11-25 20:56:24 -0700316 *
317 * See [joystick hat input](@ref joystick_hat) for how these are used.
318 *
319 * @ingroup input
320 * @{ */
321#define GLFW_HAT_CENTERED 0
322#define GLFW_HAT_UP 1
323#define GLFW_HAT_RIGHT 2
324#define GLFW_HAT_DOWN 4
325#define GLFW_HAT_LEFT 8
326#define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP)
327#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
328#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
329#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
330/*! @} */
331
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200332/*! @defgroup keys Keyboard keys
Camilla Löwy21eabd32017-02-06 17:31:25 +0100333 * @brief Keyboard key IDs.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200334 *
Camilla Berglund4188c262015-01-18 01:55:25 +0100335 * See [key input](@ref input_key) for how these are used.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200336 *
Camilla Berglund4188c262015-01-18 01:55:25 +0100337 * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
338 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
339 * put in the 256+ range).
340 *
341 * The naming of the key codes follow these rules:
342 * - The US keyboard layout is used
343 * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
344 * "3", etc.)
345 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
346 * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
347 * correspond to the Unicode standard (usually for brevity)
348 * - Keys that lack a clear US mapping are named "WORLD_x"
349 * - For non-printable keys, custom names are used (e.g. "F4",
350 * "BACKSPACE", etc.)
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200351 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100352 * @ingroup input
353 * @{
354 */
355
Camilla Berglund11615fc2013-05-30 17:19:12 +0200356/* The unknown key */
357#define GLFW_KEY_UNKNOWN -1
358
Marcusc0cb4c22011-01-02 11:18:14 +0100359/* Printable keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100360#define GLFW_KEY_SPACE 32
361#define GLFW_KEY_APOSTROPHE 39 /* ' */
362#define GLFW_KEY_COMMA 44 /* , */
363#define GLFW_KEY_MINUS 45 /* - */
364#define GLFW_KEY_PERIOD 46 /* . */
365#define GLFW_KEY_SLASH 47 /* / */
366#define GLFW_KEY_0 48
367#define GLFW_KEY_1 49
368#define GLFW_KEY_2 50
369#define GLFW_KEY_3 51
370#define GLFW_KEY_4 52
371#define GLFW_KEY_5 53
372#define GLFW_KEY_6 54
373#define GLFW_KEY_7 55
374#define GLFW_KEY_8 56
375#define GLFW_KEY_9 57
376#define GLFW_KEY_SEMICOLON 59 /* ; */
377#define GLFW_KEY_EQUAL 61 /* = */
378#define GLFW_KEY_A 65
379#define GLFW_KEY_B 66
380#define GLFW_KEY_C 67
381#define GLFW_KEY_D 68
382#define GLFW_KEY_E 69
383#define GLFW_KEY_F 70
384#define GLFW_KEY_G 71
385#define GLFW_KEY_H 72
386#define GLFW_KEY_I 73
387#define GLFW_KEY_J 74
388#define GLFW_KEY_K 75
389#define GLFW_KEY_L 76
390#define GLFW_KEY_M 77
391#define GLFW_KEY_N 78
392#define GLFW_KEY_O 79
393#define GLFW_KEY_P 80
394#define GLFW_KEY_Q 81
395#define GLFW_KEY_R 82
396#define GLFW_KEY_S 83
397#define GLFW_KEY_T 84
398#define GLFW_KEY_U 85
399#define GLFW_KEY_V 86
400#define GLFW_KEY_W 87
401#define GLFW_KEY_X 88
402#define GLFW_KEY_Y 89
403#define GLFW_KEY_Z 90
404#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
405#define GLFW_KEY_BACKSLASH 92 /* \ */
406#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
407#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
408#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
409#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
Marcusc0cb4c22011-01-02 11:18:14 +0100410
411/* Function keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100412#define GLFW_KEY_ESCAPE 256
413#define GLFW_KEY_ENTER 257
414#define GLFW_KEY_TAB 258
415#define GLFW_KEY_BACKSPACE 259
416#define GLFW_KEY_INSERT 260
417#define GLFW_KEY_DELETE 261
418#define GLFW_KEY_RIGHT 262
419#define GLFW_KEY_LEFT 263
420#define GLFW_KEY_DOWN 264
421#define GLFW_KEY_UP 265
422#define GLFW_KEY_PAGE_UP 266
423#define GLFW_KEY_PAGE_DOWN 267
424#define GLFW_KEY_HOME 268
425#define GLFW_KEY_END 269
426#define GLFW_KEY_CAPS_LOCK 280
427#define GLFW_KEY_SCROLL_LOCK 281
428#define GLFW_KEY_NUM_LOCK 282
429#define GLFW_KEY_PRINT_SCREEN 283
430#define GLFW_KEY_PAUSE 284
431#define GLFW_KEY_F1 290
432#define GLFW_KEY_F2 291
433#define GLFW_KEY_F3 292
434#define GLFW_KEY_F4 293
435#define GLFW_KEY_F5 294
436#define GLFW_KEY_F6 295
437#define GLFW_KEY_F7 296
438#define GLFW_KEY_F8 297
439#define GLFW_KEY_F9 298
440#define GLFW_KEY_F10 299
441#define GLFW_KEY_F11 300
442#define GLFW_KEY_F12 301
443#define GLFW_KEY_F13 302
444#define GLFW_KEY_F14 303
445#define GLFW_KEY_F15 304
446#define GLFW_KEY_F16 305
447#define GLFW_KEY_F17 306
448#define GLFW_KEY_F18 307
449#define GLFW_KEY_F19 308
450#define GLFW_KEY_F20 309
451#define GLFW_KEY_F21 310
452#define GLFW_KEY_F22 311
453#define GLFW_KEY_F23 312
454#define GLFW_KEY_F24 313
455#define GLFW_KEY_F25 314
456#define GLFW_KEY_KP_0 320
457#define GLFW_KEY_KP_1 321
458#define GLFW_KEY_KP_2 322
459#define GLFW_KEY_KP_3 323
460#define GLFW_KEY_KP_4 324
461#define GLFW_KEY_KP_5 325
462#define GLFW_KEY_KP_6 326
463#define GLFW_KEY_KP_7 327
464#define GLFW_KEY_KP_8 328
465#define GLFW_KEY_KP_9 329
466#define GLFW_KEY_KP_DECIMAL 330
467#define GLFW_KEY_KP_DIVIDE 331
468#define GLFW_KEY_KP_MULTIPLY 332
469#define GLFW_KEY_KP_SUBTRACT 333
470#define GLFW_KEY_KP_ADD 334
471#define GLFW_KEY_KP_ENTER 335
472#define GLFW_KEY_KP_EQUAL 336
473#define GLFW_KEY_LEFT_SHIFT 340
474#define GLFW_KEY_LEFT_CONTROL 341
475#define GLFW_KEY_LEFT_ALT 342
476#define GLFW_KEY_LEFT_SUPER 343
477#define GLFW_KEY_RIGHT_SHIFT 344
478#define GLFW_KEY_RIGHT_CONTROL 345
479#define GLFW_KEY_RIGHT_ALT 346
480#define GLFW_KEY_RIGHT_SUPER 347
481#define GLFW_KEY_MENU 348
Camilla Berglund9c315412015-07-02 14:24:50 +0200482
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100483#define GLFW_KEY_LAST GLFW_KEY_MENU
Marcusc0cb4c22011-01-02 11:18:14 +0100484
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100485/*! @} */
486
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200487/*! @defgroup mods Modifier key flags
Camilla Löwy21eabd32017-02-06 17:31:25 +0100488 * @brief Modifier key flags.
Camilla Berglund4188c262015-01-18 01:55:25 +0100489 *
490 * See [key input](@ref input_key) for how these are used.
491 *
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200492 * @ingroup input
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100493 * @{ */
494
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200495/*! @brief If this bit is set one or more Shift keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100496 *
497 * If this bit is set one or more Shift keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100498 */
499#define GLFW_MOD_SHIFT 0x0001
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200500/*! @brief If this bit is set one or more Control keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100501 *
502 * If this bit is set one or more Control keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100503 */
Camilla Berglund3bcffba2013-05-23 14:11:05 +0200504#define GLFW_MOD_CONTROL 0x0002
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200505/*! @brief If this bit is set one or more Alt keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100506 *
507 * If this bit is set one or more Alt keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100508 */
509#define GLFW_MOD_ALT 0x0004
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200510/*! @brief If this bit is set one or more Super keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100511 *
512 * If this bit is set one or more Super keys were held down.
Noel Cowereff85f92013-05-23 13:22:27 +0200513 */
514#define GLFW_MOD_SUPER 0x0008
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100515/*! @brief If this bit is set the Caps Lock key is enabled.
516 *
517 * If this bit is set the Caps Lock key is enabled and the @ref
518 * GLFW_LOCK_KEY_MODS input mode is set.
519 */
520#define GLFW_MOD_CAPS_LOCK 0x0010
521/*! @brief If this bit is set the Num Lock key is enabled.
522 *
523 * If this bit is set the Num Lock key is enabled and the @ref
524 * GLFW_LOCK_KEY_MODS input mode is set.
525 */
526#define GLFW_MOD_NUM_LOCK 0x0020
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100527
528/*! @} */
529
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100530/*! @defgroup buttons Mouse buttons
Camilla Löwy21eabd32017-02-06 17:31:25 +0100531 * @brief Mouse button IDs.
Camilla Berglund4188c262015-01-18 01:55:25 +0100532 *
533 * See [mouse button input](@ref input_mouse_button) for how these are used.
534 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100535 * @ingroup input
536 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100537#define GLFW_MOUSE_BUTTON_1 0
538#define GLFW_MOUSE_BUTTON_2 1
539#define GLFW_MOUSE_BUTTON_3 2
540#define GLFW_MOUSE_BUTTON_4 3
541#define GLFW_MOUSE_BUTTON_5 4
542#define GLFW_MOUSE_BUTTON_6 5
543#define GLFW_MOUSE_BUTTON_7 6
544#define GLFW_MOUSE_BUTTON_8 7
545#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
546#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
547#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
548#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100549/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200550
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100551/*! @defgroup joysticks Joysticks
Camilla Löwy21eabd32017-02-06 17:31:25 +0100552 * @brief Joystick IDs.
Camilla Berglund4188c262015-01-18 01:55:25 +0100553 *
554 * See [joystick input](@ref joystick) for how these are used.
555 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100556 * @ingroup input
557 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100558#define GLFW_JOYSTICK_1 0
559#define GLFW_JOYSTICK_2 1
560#define GLFW_JOYSTICK_3 2
561#define GLFW_JOYSTICK_4 3
562#define GLFW_JOYSTICK_5 4
563#define GLFW_JOYSTICK_6 5
564#define GLFW_JOYSTICK_7 6
565#define GLFW_JOYSTICK_8 7
566#define GLFW_JOYSTICK_9 8
567#define GLFW_JOYSTICK_10 9
568#define GLFW_JOYSTICK_11 10
569#define GLFW_JOYSTICK_12 11
570#define GLFW_JOYSTICK_13 12
571#define GLFW_JOYSTICK_14 13
572#define GLFW_JOYSTICK_15 14
573#define GLFW_JOYSTICK_16 15
574#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100575/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200576
Camilla Löwy953106e2017-06-18 15:13:25 +0200577/*! @defgroup gamepad_buttons Gamepad buttons
578 * @brief Gamepad buttons.
579 *
580 * See @ref gamepad for how these are used.
581 *
582 * @ingroup input
583 * @{ */
584#define GLFW_GAMEPAD_BUTTON_A 0
585#define GLFW_GAMEPAD_BUTTON_B 1
586#define GLFW_GAMEPAD_BUTTON_X 2
587#define GLFW_GAMEPAD_BUTTON_Y 3
588#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
589#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
590#define GLFW_GAMEPAD_BUTTON_BACK 6
591#define GLFW_GAMEPAD_BUTTON_START 7
592#define GLFW_GAMEPAD_BUTTON_GUIDE 8
593#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
594#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
595#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
596#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
597#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
598#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
599#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
600
601#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
602#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
603#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
604#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
605/*! @} */
606
607/*! @defgroup gamepad_axes Gamepad axes
608 * @brief Gamepad axes.
609 *
610 * See @ref gamepad for how these are used.
611 *
612 * @ingroup input
613 * @{ */
614#define GLFW_GAMEPAD_AXIS_LEFT_X 0
615#define GLFW_GAMEPAD_AXIS_LEFT_Y 1
616#define GLFW_GAMEPAD_AXIS_RIGHT_X 2
617#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
618#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
619#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
620#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
621/*! @} */
622
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100623/*! @defgroup errors Error codes
Camilla Löwy21eabd32017-02-06 17:31:25 +0100624 * @brief Error codes.
Camilla Berglund4188c262015-01-18 01:55:25 +0100625 *
626 * See [error handling](@ref error_handling) for how these are used.
627 *
Camilla Berglund4591ad22014-09-18 15:03:29 +0200628 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100629 * @{ */
Camilla Löwy63506412017-05-01 19:20:57 +0200630/*! @brief No error has occurred.
631 *
632 * No error has occurred.
633 *
634 * @analysis Yay.
635 */
636#define GLFW_NO_ERROR 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100637/*! @brief GLFW has not been initialized.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200638 *
Camilla Berglund0df4e062015-12-13 14:07:27 +0100639 * This occurs if a GLFW function was called that must not be called unless the
Camilla Berglund4591ad22014-09-18 15:03:29 +0200640 * library is [initialized](@ref intro_init).
641 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100642 * @analysis Application programmer error. Initialize GLFW before calling any
643 * function that requires initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100644 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200645#define GLFW_NOT_INITIALIZED 0x00010001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100646/*! @brief No context is current for this thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200647 *
648 * This occurs if a GLFW function was called that needs and operates on the
649 * current OpenGL or OpenGL ES context but no context is current on the calling
650 * thread. One such function is @ref glfwSwapInterval.
651 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100652 * @analysis Application programmer error. Ensure a context is current before
653 * calling functions that require a current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100654 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200655#define GLFW_NO_CURRENT_CONTEXT 0x00010002
Camilla Berglund4591ad22014-09-18 15:03:29 +0200656/*! @brief One of the arguments to the function was an invalid enum value.
657 *
658 * One of the arguments to the function was an invalid enum value, for example
Camilla Löwyce161c22016-12-06 01:14:23 +0100659 * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200660 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100661 * @analysis Application programmer error. Fix the offending call.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100662 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200663#define GLFW_INVALID_ENUM 0x00010003
Camilla Berglund4591ad22014-09-18 15:03:29 +0200664/*! @brief One of the arguments to the function was an invalid value.
665 *
666 * One of the arguments to the function was an invalid value, for example
667 * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
668 *
669 * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
670 * result in a @ref GLFW_VERSION_UNAVAILABLE error.
671 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100672 * @analysis Application programmer error. Fix the offending call.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100673 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200674#define GLFW_INVALID_VALUE 0x00010004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100675/*! @brief A memory allocation failed.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200676 *
677 * A memory allocation failed.
678 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100679 * @analysis A bug in GLFW or the underlying operating system. Report the bug
680 * to our [issue tracker](https://github.com/glfw/glfw/issues).
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100681 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200682#define GLFW_OUT_OF_MEMORY 0x00010005
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200683/*! @brief GLFW could not find support for the requested API on the system.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200684 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200685 * GLFW could not find support for the requested API on the system.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200686 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100687 * @analysis The installed graphics driver does not support the requested
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200688 * API, or does not support it via the chosen context creation backend.
Camilla Berglund951a9582016-01-31 21:32:14 +0100689 * Below are a few examples.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200690 *
691 * @par
692 * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
Camilla Berglundd95b79f2015-03-30 23:20:49 +0200693 * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
Camilla Berglund8d6f2652016-10-20 00:50:54 +0200694 * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
Camilla Berglund138feb82015-01-05 16:46:04 +0100695 * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200696 * driver. Older graphics drivers do not support Vulkan.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100697 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200698#define GLFW_API_UNAVAILABLE 0x00010006
Camilla Berglund4591ad22014-09-18 15:03:29 +0200699/*! @brief The requested OpenGL or OpenGL ES version is not available.
700 *
Camilla Berglundd493a822015-03-10 19:51:14 +0100701 * The requested OpenGL or OpenGL ES version (including any requested context
702 * or framebuffer hints) is not available on this machine.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200703 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100704 * @analysis The machine does not support your requirements. If your
705 * application is sufficiently flexible, downgrade your requirements and try
706 * again. Otherwise, inform the user that their machine does not match your
Camilla Berglund4591ad22014-09-18 15:03:29 +0200707 * requirements.
708 *
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200709 * @par
710 * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
711 * comes out before the 4.x series gets that far, also fail with this error and
712 * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
713 * will exist.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100714 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200715#define GLFW_VERSION_UNAVAILABLE 0x00010007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100716/*! @brief A platform-specific error occurred that does not match any of the
717 * more specific categories.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200718 *
719 * A platform-specific error occurred that does not match any of the more
720 * specific categories.
721 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100722 * @analysis A bug or configuration error in GLFW, the underlying operating
723 * system or its drivers, or a lack of required resources. Report the issue to
724 * our [issue tracker](https://github.com/glfw/glfw/issues).
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100725 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200726#define GLFW_PLATFORM_ERROR 0x00010008
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200727/*! @brief The requested format is not supported or available.
728 *
729 * If emitted during window creation, the requested pixel format is not
730 * supported.
731 *
732 * If emitted when querying the clipboard, the contents of the clipboard could
733 * not be converted to the requested format.
734 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100735 * @analysis If emitted during window creation, one or more
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200736 * [hard constraints](@ref window_hints_hard) did not match any of the
737 * available pixel formats. If your application is sufficiently flexible,
738 * downgrade your requirements and try again. Otherwise, inform the user that
739 * their machine does not match your requirements.
740 *
741 * @par
742 * If emitted when querying the clipboard, ignore the error or report it to
743 * the user, as appropriate.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100744 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200745#define GLFW_FORMAT_UNAVAILABLE 0x00010009
Camilla Berglund496f5592015-06-18 14:03:02 +0200746/*! @brief The specified window does not have an OpenGL or OpenGL ES context.
747 *
748 * A window that does not have an OpenGL or OpenGL ES context was passed to
749 * a function that requires it to have one.
750 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100751 * @analysis Application programmer error. Fix the offending call.
Camilla Berglund496f5592015-06-18 14:03:02 +0200752 */
753#define GLFW_NO_WINDOW_CONTEXT 0x0001000A
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100754/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200755
Camilla Löwyce161c22016-12-06 01:14:23 +0100756/*! @addtogroup window
757 * @{ */
758/*! @brief Input focus window hint and attribute
759 *
760 * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
761 * [window attribute](@ref GLFW_FOCUSED_attrib).
762 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100763#define GLFW_FOCUSED 0x00020001
Camilla Löwyce161c22016-12-06 01:14:23 +0100764/*! @brief Window iconification window attribute
765 *
766 * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
767 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100768#define GLFW_ICONIFIED 0x00020002
Camilla Löwyce161c22016-12-06 01:14:23 +0100769/*! @brief Window resize-ability window hint and attribute
770 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100771 * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100772 * [window attribute](@ref GLFW_RESIZABLE_attrib).
773 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200774#define GLFW_RESIZABLE 0x00020003
Camilla Löwyce161c22016-12-06 01:14:23 +0100775/*! @brief Window visibility window hint and attribute
776 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100777 * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100778 * [window attribute](@ref GLFW_VISIBLE_attrib).
779 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200780#define GLFW_VISIBLE 0x00020004
Camilla Löwyce161c22016-12-06 01:14:23 +0100781/*! @brief Window decoration window hint and attribute
782 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100783 * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100784 * [window attribute](@ref GLFW_DECORATED_attrib).
785 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200786#define GLFW_DECORATED 0x00020005
Camilla Löwy9e560992016-09-30 01:52:22 +0200787/*! @brief Window auto-iconification window hint and attribute
Camilla Löwyce161c22016-12-06 01:14:23 +0100788 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100789 * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
Camilla Löwy9e560992016-09-30 01:52:22 +0200790 * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
Camilla Löwyce161c22016-12-06 01:14:23 +0100791 */
Camilla Berglund25e7ff12014-04-08 15:32:34 +0200792#define GLFW_AUTO_ICONIFY 0x00020006
Camilla Löwyce161c22016-12-06 01:14:23 +0100793/*! @brief Window decoration window hint and attribute
794 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100795 * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100796 * [window attribute](@ref GLFW_FLOATING_attrib).
797 */
Camilla Berglund3ce7bfe2014-05-23 14:01:02 +0200798#define GLFW_FLOATING 0x00020007
Camilla Löwyce161c22016-12-06 01:14:23 +0100799/*! @brief Window maximization window hint and attribute
800 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100801 * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100802 * [window attribute](@ref GLFW_MAXIMIZED_attrib).
803 */
Camilla Berglunda10caa42015-10-13 12:50:59 +0200804#define GLFW_MAXIMIZED 0x00020008
Camilla Löwy5a74b502017-02-06 15:03:50 +0100805/*! @brief Cursor centering window hint
806 *
807 * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
808 */
Liam Middlebrook72ac5ba2016-08-18 11:47:54 -0400809#define GLFW_CENTER_CURSOR 0x00020009
Camilla Löwy32e78ae2017-09-18 18:10:57 +0200810/*! @brief Window framebuffer transparency hint and attribute
811 *
Camilla Löwy49130ab2017-11-07 22:50:01 +0100812 * Window framebuffer transparency
813 * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
814 * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
Camilla Löwy32e78ae2017-09-18 18:10:57 +0200815 */
Camilla Löwy49130ab2017-11-07 22:50:01 +0100816#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
Camilla Löwyd6b3a602018-01-11 14:13:54 +0100817/*! @brief Mouse cursor hover window attribute.
818 *
819 * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
820 */
Camilla Löwyee9dffc2018-01-04 13:50:58 +0100821#define GLFW_HOVERED 0x0002000B
Doug Binks0be4f3f2018-05-29 14:51:36 +0100822/*! @brief Input focus on calling show window hint and attribute
823 *
824 * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
825 * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
826 */
827#define GLFW_FOCUS_ON_SHOW 0x0002000C
Camilla Berglund2c091572010-09-09 21:09:11 +0200828
Camilla Löwyce161c22016-12-06 01:14:23 +0100829/*! @brief Framebuffer bit depth hint.
830 *
831 * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
832 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200833#define GLFW_RED_BITS 0x00021001
Camilla Löwyce161c22016-12-06 01:14:23 +0100834/*! @brief Framebuffer bit depth hint.
835 *
836 * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
837 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200838#define GLFW_GREEN_BITS 0x00021002
Camilla Löwyce161c22016-12-06 01:14:23 +0100839/*! @brief Framebuffer bit depth hint.
840 *
841 * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
842 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200843#define GLFW_BLUE_BITS 0x00021003
Camilla Löwyce161c22016-12-06 01:14:23 +0100844/*! @brief Framebuffer bit depth hint.
845 *
846 * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
847 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200848#define GLFW_ALPHA_BITS 0x00021004
Camilla Löwyce161c22016-12-06 01:14:23 +0100849/*! @brief Framebuffer bit depth hint.
850 *
851 * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
852 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200853#define GLFW_DEPTH_BITS 0x00021005
Camilla Löwyce161c22016-12-06 01:14:23 +0100854/*! @brief Framebuffer bit depth hint.
855 *
856 * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
857 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200858#define GLFW_STENCIL_BITS 0x00021006
Camilla Löwyce161c22016-12-06 01:14:23 +0100859/*! @brief Framebuffer bit depth hint.
860 *
861 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
862 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200863#define GLFW_ACCUM_RED_BITS 0x00021007
Camilla Löwyce161c22016-12-06 01:14:23 +0100864/*! @brief Framebuffer bit depth hint.
865 *
866 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
867 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200868#define GLFW_ACCUM_GREEN_BITS 0x00021008
Camilla Löwyce161c22016-12-06 01:14:23 +0100869/*! @brief Framebuffer bit depth hint.
870 *
871 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
872 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200873#define GLFW_ACCUM_BLUE_BITS 0x00021009
Camilla Löwyce161c22016-12-06 01:14:23 +0100874/*! @brief Framebuffer bit depth hint.
875 *
876 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
877 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200878#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
Camilla Löwyce161c22016-12-06 01:14:23 +0100879/*! @brief Framebuffer auxiliary buffer hint.
880 *
881 * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
882 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200883#define GLFW_AUX_BUFFERS 0x0002100B
Camilla Löwyce161c22016-12-06 01:14:23 +0100884/*! @brief OpenGL stereoscopic rendering hint.
885 *
886 * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
887 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200888#define GLFW_STEREO 0x0002100C
Camilla Löwyce161c22016-12-06 01:14:23 +0100889/*! @brief Framebuffer MSAA samples hint.
890 *
891 * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
892 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200893#define GLFW_SAMPLES 0x0002100D
Camilla Löwyce161c22016-12-06 01:14:23 +0100894/*! @brief Framebuffer sRGB hint.
895 *
896 * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
897 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200898#define GLFW_SRGB_CAPABLE 0x0002100E
Camilla Löwyce161c22016-12-06 01:14:23 +0100899/*! @brief Monitor refresh rate hint.
900 *
901 * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
902 */
Camilla Berglund2cd34382013-05-30 20:42:50 +0200903#define GLFW_REFRESH_RATE 0x0002100F
Camilla Löwyce161c22016-12-06 01:14:23 +0100904/*! @brief Framebuffer double buffering hint.
905 *
906 * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
907 */
Camilla Berglundc9808582014-04-24 19:21:10 +0200908#define GLFW_DOUBLEBUFFER 0x00021010
Bailey Cosier93e66662017-09-19 18:27:45 +0200909
Camilla Löwy831426c2016-12-08 17:08:36 +0100910/*! @brief Context client API hint and attribute.
911 *
912 * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
913 * [attribute](@ref GLFW_CLIENT_API_attrib).
914 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200915#define GLFW_CLIENT_API 0x00022001
Camilla Löwy831426c2016-12-08 17:08:36 +0100916/*! @brief Context client API major version hint and attribute.
917 *
918 * Context client API major version [hint](@ref GLFW_CLIENT_API_hint) and
919 * [attribute](@ref GLFW_CLIENT_API_attrib).
920 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200921#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
Camilla Löwy831426c2016-12-08 17:08:36 +0100922/*! @brief Context client API minor version hint and attribute.
923 *
924 * Context client API minor version [hint](@ref GLFW_CLIENT_API_hint) and
925 * [attribute](@ref GLFW_CLIENT_API_attrib).
926 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200927#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
Camilla Löwy831426c2016-12-08 17:08:36 +0100928/*! @brief Context client API revision number hint and attribute.
929 *
930 * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and
931 * [attribute](@ref GLFW_CLIENT_API_attrib).
932 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200933#define GLFW_CONTEXT_REVISION 0x00022004
Camilla Löwy831426c2016-12-08 17:08:36 +0100934/*! @brief Context robustness hint and attribute.
935 *
936 * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and
937 * [attribute](@ref GLFW_CLIENT_API_attrib).
938 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200939#define GLFW_CONTEXT_ROBUSTNESS 0x00022005
Camilla Löwy831426c2016-12-08 17:08:36 +0100940/*! @brief OpenGL forward-compatibility hint and attribute.
941 *
942 * OpenGL forward-compatibility [hint](@ref GLFW_CLIENT_API_hint) and
943 * [attribute](@ref GLFW_CLIENT_API_attrib).
944 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200945#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
Camilla Löwy831426c2016-12-08 17:08:36 +0100946/*! @brief OpenGL debug context hint and attribute.
947 *
948 * OpenGL debug context [hint](@ref GLFW_CLIENT_API_hint) and
949 * [attribute](@ref GLFW_CLIENT_API_attrib).
950 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200951#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
Camilla Löwy831426c2016-12-08 17:08:36 +0100952/*! @brief OpenGL profile hint and attribute.
953 *
954 * OpenGL profile [hint](@ref GLFW_CLIENT_API_hint) and
955 * [attribute](@ref GLFW_CLIENT_API_attrib).
956 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200957#define GLFW_OPENGL_PROFILE 0x00022008
Camilla Löwy831426c2016-12-08 17:08:36 +0100958/*! @brief Context flush-on-release hint and attribute.
959 *
960 * Context flush-on-release [hint](@ref GLFW_CLIENT_API_hint) and
961 * [attribute](@ref GLFW_CLIENT_API_attrib).
962 */
Camilla Berglund44c899c2014-08-21 19:21:45 +0200963#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
Camilla Löwy831426c2016-12-08 17:08:36 +0100964/*! @brief Context error suppression hint and attribute.
965 *
966 * Context error suppression [hint](@ref GLFW_CLIENT_API_hint) and
967 * [attribute](@ref GLFW_CLIENT_API_attrib).
968 */
Camilla Berglund7be82092015-08-10 12:46:14 +0200969#define GLFW_CONTEXT_NO_ERROR 0x0002200A
Camilla Löwy831426c2016-12-08 17:08:36 +0100970/*! @brief Context creation API hint and attribute.
971 *
972 * Context creation API [hint](@ref GLFW_CLIENT_API_hint) and
973 * [attribute](@ref GLFW_CLIENT_API_attrib).
974 */
Camilla Berglundef80bea2016-03-28 13:19:31 +0200975#define GLFW_CONTEXT_CREATION_API 0x0002200B
Camilla Löwy089ea9a2018-08-31 13:33:48 +0200976/*! @brief Window content area scaling window
977 * [window hint](@ref GLFW_SCALE_TO_MONITOR).
978 */
979#define GLFW_SCALE_TO_MONITOR 0x0002200C
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100980
Camilla Löwy58ceab52016-12-07 00:41:54 +0100981#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
Camilla Löwy9da22852017-12-12 16:45:38 +0100982#define GLFW_COCOA_FRAME_NAME 0x00023002
Camilla Löwy77a8f102017-01-27 12:02:09 +0100983#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
Camilla Löwy61588012017-12-12 10:54:18 +0100984
985#define GLFW_X11_CLASS_NAME 0x00024001
986#define GLFW_X11_INSTANCE_NAME 0x00024002
Camilla Löwy831426c2016-12-08 17:08:36 +0100987/*! @} */
Camilla Löwy58ceab52016-12-07 00:41:54 +0100988
Camilla Berglund496f5592015-06-18 14:03:02 +0200989#define GLFW_NO_API 0
Camilla Berglund393e4392013-05-27 22:16:59 +0200990#define GLFW_OPENGL_API 0x00030001
991#define GLFW_OPENGL_ES_API 0x00030002
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100992
Camilla Berglund393e4392013-05-27 22:16:59 +0200993#define GLFW_NO_ROBUSTNESS 0
994#define GLFW_NO_RESET_NOTIFICATION 0x00031001
995#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100996
Camilla Berglund44e84012013-06-05 16:13:30 +0200997#define GLFW_OPENGL_ANY_PROFILE 0
Camilla Berglund393e4392013-05-27 22:16:59 +0200998#define GLFW_OPENGL_CORE_PROFILE 0x00032001
999#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001000
Camilla Berglund393e4392013-05-27 22:16:59 +02001001#define GLFW_CURSOR 0x00033001
1002#define GLFW_STICKY_KEYS 0x00033002
1003#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01001004#define GLFW_LOCK_KEY_MODS 0x00033004
Camilla Löwy1155c832019-02-11 19:10:20 +01001005#define GLFW_RAW_MOUSE_MOTION 0x00033005
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001006
Camilla Berglund393e4392013-05-27 22:16:59 +02001007#define GLFW_CURSOR_NORMAL 0x00034001
1008#define GLFW_CURSOR_HIDDEN 0x00034002
1009#define GLFW_CURSOR_DISABLED 0x00034003
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001010
Camilla Berglund44c899c2014-08-21 19:21:45 +02001011#define GLFW_ANY_RELEASE_BEHAVIOR 0
1012#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
1013#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
1014
Camilla Berglundef80bea2016-03-28 13:19:31 +02001015#define GLFW_NATIVE_CONTEXT_API 0x00036001
1016#define GLFW_EGL_CONTEXT_API 0x00036002
Camilla Löwye9560ef2017-02-28 19:23:25 +01001017#define GLFW_OSMESA_CONTEXT_API 0x00036003
Camilla Berglundef80bea2016-03-28 13:19:31 +02001018
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001019/*! @defgroup shapes Standard cursor shapes
Camilla Löwy21eabd32017-02-06 17:31:25 +01001020 * @brief Standard system cursor shapes.
Camilla Berglund4188c262015-01-18 01:55:25 +01001021 *
1022 * See [standard cursor creation](@ref cursor_standard) for how these are used.
1023 *
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001024 * @ingroup input
1025 * @{ */
1026
1027/*! @brief The regular arrow cursor shape.
1028 *
1029 * The regular arrow cursor.
1030 */
1031#define GLFW_ARROW_CURSOR 0x00036001
1032/*! @brief The text input I-beam cursor shape.
1033 *
1034 * The text input I-beam cursor shape.
1035 */
1036#define GLFW_IBEAM_CURSOR 0x00036002
1037/*! @brief The crosshair shape.
1038 *
1039 * The crosshair shape.
1040 */
1041#define GLFW_CROSSHAIR_CURSOR 0x00036003
1042/*! @brief The hand shape.
1043 *
1044 * The hand shape.
1045 */
1046#define GLFW_HAND_CURSOR 0x00036004
1047/*! @brief The horizontal resize arrow shape.
1048 *
1049 * The horizontal resize arrow shape.
1050 */
1051#define GLFW_HRESIZE_CURSOR 0x00036005
1052/*! @brief The vertical resize arrow shape.
1053 *
1054 * The vertical resize arrow shape.
1055 */
1056#define GLFW_VRESIZE_CURSOR 0x00036006
1057/*! @} */
1058
Camilla Berglund393e4392013-05-27 22:16:59 +02001059#define GLFW_CONNECTED 0x00040001
1060#define GLFW_DISCONNECTED 0x00040002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001061
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001062/*! @addtogroup init
1063 * @{ */
Camilla Löwy04116782018-11-05 17:37:49 +01001064/*! @brief Joystick hat buttons init hint.
1065 *
1066 * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS)
1067 */
Camilla Löwy798d7c62017-03-01 23:27:20 +01001068#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
Camilla Löwy04116782018-11-05 17:37:49 +01001069/*! @brief macOS specific init hint.
1070 *
1071 * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES)
1072 */
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001073#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
Camilla Löwy04116782018-11-05 17:37:49 +01001074/*! @brief macOS specific init hint.
1075 *
1076 * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR)
1077 */
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001078#define GLFW_COCOA_MENUBAR 0x00051002
1079/*! @} */
1080
Camilla Berglund28101302014-04-08 18:57:43 +02001081#define GLFW_DONT_CARE -1
1082
Camilla Berglund97387282011-10-06 23:28:56 +02001083
Camilla Berglund3249f812010-09-07 17:34:51 +02001084/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001085 * GLFW API types
Camilla Berglund3249f812010-09-07 17:34:51 +02001086 *************************************************************************/
1087
Camilla Berglund3f5843f2012-12-13 02:22:39 +01001088/*! @brief Client API function pointer type.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001089 *
1090 * Generic function pointer used for returning client API function pointers
1091 * without forcing a cast from a regular pointer.
1092 *
Camilla Berglundbce20c32015-11-05 13:58:52 +01001093 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001094 * @sa @ref glfwGetProcAddress
Camilla Berglundbce20c32015-11-05 13:58:52 +01001095 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001096 * @since Added in version 3.0.
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00001097 *
Camilla Berglund3f5843f2012-12-13 02:22:39 +01001098 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001099 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02001100typedef void (*GLFWglproc)(void);
1101
Camilla Berglund9b75bff2015-08-10 20:19:04 +02001102/*! @brief Vulkan API function pointer type.
1103 *
1104 * Generic function pointer used for returning Vulkan API function pointers
1105 * without forcing a cast from a regular pointer.
1106 *
1107 * @sa @ref vulkan_proc
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001108 * @sa @ref glfwGetInstanceProcAddress
Camilla Berglund9b75bff2015-08-10 20:19:04 +02001109 *
1110 * @since Added in version 3.2.
1111 *
1112 * @ingroup vulkan
1113 */
1114typedef void (*GLFWvkproc)(void);
1115
Camilla Berglunddba2d802013-01-17 23:06:56 +01001116/*! @brief Opaque monitor object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001117 *
1118 * Opaque monitor object.
1119 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001120 * @see @ref monitor_object
1121 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001122 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001123 *
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001124 * @ingroup monitor
1125 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001126typedef struct GLFWmonitor GLFWmonitor;
Camilla Berglunde0ce9202012-08-29 20:39:05 +02001127
Camilla Berglunddba2d802013-01-17 23:06:56 +01001128/*! @brief Opaque window object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001129 *
1130 * Opaque window object.
1131 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001132 * @see @ref window_object
1133 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001134 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001135 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001136 * @ingroup window
1137 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001138typedef struct GLFWwindow GLFWwindow;
Camilla Berglund135194a2010-09-09 18:15:32 +02001139
urraka40c04a72013-12-04 10:19:22 -03001140/*! @brief Opaque cursor object.
1141 *
1142 * Opaque cursor object.
1143 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001144 * @see @ref cursor_object
1145 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001146 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001147 *
Camilla Löwy04116782018-11-05 17:37:49 +01001148 * @ingroup input
urraka40c04a72013-12-04 10:19:22 -03001149 */
1150typedef struct GLFWcursor GLFWcursor;
1151
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001152/*! @brief The function signature for error callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001153 *
1154 * This is the function signature for error callback functions.
1155 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001156 * @param[in] error An [error code](@ref errors).
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001157 * @param[in] description A UTF-8 encoded string describing the error.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001158 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001159 * @sa @ref error_handling
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001160 * @sa @ref glfwSetErrorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001161 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001162 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001163 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001164 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001165 */
Camilla Berglund897558f2011-03-07 13:34:58 +01001166typedef void (* GLFWerrorfun)(int,const char*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001167
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001168/*! @brief The function signature for window position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001169 *
1170 * This is the function signature for window position callback functions.
1171 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001172 * @param[in] window The window that was moved.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001173 * @param[in] xpos The new x-coordinate, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001174 * upper-left corner of the content area of the window.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001175 * @param[in] ypos The new y-coordinate, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001176 * upper-left corner of the content area of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001177 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001178 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001179 * @sa @ref glfwSetWindowPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001180 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001181 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001182 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001183 * @ingroup window
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001184 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001185typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001186
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001187/*! @brief The function signature for window resize callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001188 *
1189 * This is the function signature for window size callback functions.
1190 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001191 * @param[in] window The window that was resized.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001192 * @param[in] width The new width, in screen coordinates, of the window.
1193 * @param[in] height The new height, in screen coordinates, of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001194 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001195 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001196 * @sa @ref glfwSetWindowSizeCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001197 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001198 * @since Added in version 1.0.
1199 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001200 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001201 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001202 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001203typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001204
1205/*! @brief The function signature for window close callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001206 *
1207 * This is the function signature for window close callback functions.
1208 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001209 * @param[in] window The window that the user attempted to close.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001210 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001211 * @sa @ref window_close
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001212 * @sa @ref glfwSetWindowCloseCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001213 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001214 * @since Added in version 2.5.
1215 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001216 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001217 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001218 */
Camilla Berglund64afb192013-03-06 23:29:37 +01001219typedef void (* GLFWwindowclosefun)(GLFWwindow*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001220
1221/*! @brief The function signature for window content refresh callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001222 *
1223 * This is the function signature for window refresh callback functions.
1224 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001225 * @param[in] window The window whose content needs to be refreshed.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001226 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001227 * @sa @ref window_refresh
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001228 * @sa @ref glfwSetWindowRefreshCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001229 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001230 * @since Added in version 2.5.
1231 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001232 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001233 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001234 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001235typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001236
1237/*! @brief The function signature for window focus/defocus callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001238 *
1239 * This is the function signature for window focus callback functions.
1240 *
Camilla Berglund4188c262015-01-18 01:55:25 +01001241 * @param[in] window The window that gained or lost input focus.
Camilla Berglund0eccf752015-08-23 19:30:04 +02001242 * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
1243 * `GLFW_FALSE` if it lost it.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001244 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001245 * @sa @ref window_focus
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001246 * @sa @ref glfwSetWindowFocusCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001247 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001248 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001249 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001250 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001251 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001252typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001253
Camilla Berglund06e7a962012-11-22 19:14:27 +01001254/*! @brief The function signature for window iconify/restore callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001255 *
1256 * This is the function signature for window iconify/restore callback
1257 * functions.
1258 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001259 * @param[in] window The window that was iconified or restored.
Camilla Berglund0eccf752015-08-23 19:30:04 +02001260 * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
1261 * `GLFW_FALSE` if it was restored.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001262 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001263 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001264 * @sa @ref glfwSetWindowIconifyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001265 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001266 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001267 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001268 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001269 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001270typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001271
Camilla Berglundc156b502016-06-16 13:09:28 +02001272/*! @brief The function signature for window maximize/restore callbacks.
1273 *
1274 * This is the function signature for window maximize/restore callback
1275 * functions.
1276 *
1277 * @param[in] window The window that was maximized or restored.
1278 * @param[in] iconified `GLFW_TRUE` if the window was maximized, or
1279 * `GLFW_FALSE` if it was restored.
1280 *
1281 * @sa @ref window_maximize
1282 * @sa glfwSetWindowMaximizeCallback
1283 *
1284 * @since Added in version 3.3.
1285 *
1286 * @ingroup window
1287 */
1288typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
1289
Camilla Berglund34981632013-06-03 12:51:57 +02001290/*! @brief The function signature for framebuffer resize callbacks.
1291 *
1292 * This is the function signature for framebuffer resize callback
1293 * functions.
1294 *
1295 * @param[in] window The window whose framebuffer was resized.
1296 * @param[in] width The new width, in pixels, of the framebuffer.
1297 * @param[in] height The new height, in pixels, of the framebuffer.
1298 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001299 * @sa @ref window_fbsize
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001300 * @sa @ref glfwSetFramebufferSizeCallback
Camilla Berglund34981632013-06-03 12:51:57 +02001301 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001302 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001303 *
Camilla Berglund34981632013-06-03 12:51:57 +02001304 * @ingroup window
1305 */
1306typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
1307
Camilla Löwy370eac32017-12-11 21:26:40 +01001308/*! @brief The function signature for window content scale callbacks.
1309 *
1310 * This is the function signature for window content scale callback
1311 * functions.
1312 *
1313 * @param[in] window The window whose content scale changed.
1314 * @param[in] xscale The new x-axis content scale of the window.
1315 * @param[in] yscale The new y-axis content scale of the window.
1316 *
1317 * @sa @ref window_scale
1318 * @sa @ref glfwSetWindowContentScaleCallback
1319 *
1320 * @since Added in version 3.3.
1321 *
1322 * @ingroup window
1323 */
1324typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
1325
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001326/*! @brief The function signature for mouse button callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001327 *
1328 * This is the function signature for mouse button callback functions.
1329 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001330 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001331 * @param[in] button The [mouse button](@ref buttons) that was pressed or
1332 * released.
1333 * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +02001334 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1335 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001336 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001337 * @sa @ref input_mouse_button
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001338 * @sa @ref glfwSetMouseButtonCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001339 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001340 * @since Added in version 1.0.
1341 * @glfw3 Added window handle and modifier mask parameters.
Camilla Berglund810bab72015-12-13 17:38:14 +01001342 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001343 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001344 */
Camilla Berglund2d1b8352012-12-09 19:19:00 +01001345typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001346
1347/*! @brief The function signature for cursor position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001348 *
1349 * This is the function signature for cursor position callback functions.
1350 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001351 * @param[in] window The window that received the event.
Camilla Berglund95c44ab2016-02-17 14:52:01 +01001352 * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001353 * the content area.
Camilla Berglund95c44ab2016-02-17 14:52:01 +01001354 * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001355 * content area.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001356 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001357 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001358 * @sa @ref glfwSetCursorPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001359 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001360 * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
Camilla Berglund810bab72015-12-13 17:38:14 +01001361 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001362 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001363 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02001364typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001365
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001366/*! @brief The function signature for cursor enter/leave callbacks.
1367 *
1368 * This is the function signature for cursor enter/leave callback functions.
1369 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001370 * @param[in] window The window that received the event.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001371 * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
Camilla Berglund0eccf752015-08-23 19:30:04 +02001372 * area, or `GLFW_FALSE` if it left it.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001373 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001374 * @sa @ref cursor_enter
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001375 * @sa @ref glfwSetCursorEnterCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001376 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001377 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001378 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001379 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001380 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001381typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001382
1383/*! @brief The function signature for scroll callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001384 *
1385 * This is the function signature for scroll callback functions.
1386 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001387 * @param[in] window The window that received the event.
mewmewcf2d2602013-06-06 19:49:23 +02001388 * @param[in] xoffset The scroll offset along the x-axis.
1389 * @param[in] yoffset The scroll offset along the y-axis.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001390 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001391 * @sa @ref scrolling
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001392 * @sa @ref glfwSetScrollCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001393 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001394 * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
Camilla Berglund810bab72015-12-13 17:38:14 +01001395 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001396 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001397 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001398typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001399
1400/*! @brief The function signature for keyboard key callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001401 *
1402 * This is the function signature for keyboard key callback functions.
1403 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001404 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001405 * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
Camilla Berglund11615fc2013-05-30 17:19:12 +02001406 * @param[in] scancode The system-specific scancode of the key.
Camilla Berglund95654cf2014-10-02 17:35:10 +02001407 * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +02001408 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1409 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001410 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001411 * @sa @ref input_key
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001412 * @sa @ref glfwSetKeyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001413 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001414 * @since Added in version 1.0.
1415 * @glfw3 Added window handle, scancode and modifier mask parameters.
Camilla Berglund810bab72015-12-13 17:38:14 +01001416 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001417 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001418 */
Camilla Berglund11615fc2013-05-30 17:19:12 +02001419typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001420
1421/*! @brief The function signature for Unicode character callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001422 *
1423 * This is the function signature for Unicode character callback functions.
1424 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001425 * @param[in] window The window that received the event.
Camilla Berglund2c920fb2013-10-10 19:41:56 +02001426 * @param[in] codepoint The Unicode code point of the character.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001427 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001428 * @sa @ref input_char
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001429 * @sa @ref glfwSetCharCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001430 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001431 * @since Added in version 2.4.
1432 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001433 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001434 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001435 */
Camilla Berglund182e0af2013-02-25 17:02:28 +01001436typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
Camilla Berglund5f68e122012-11-27 17:07:28 +01001437
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001438/*! @brief The function signature for Unicode character with modifiers
1439 * callbacks.
1440 *
1441 * This is the function signature for Unicode character with modifiers callback
1442 * functions. It is called for each input character, regardless of what
1443 * modifier keys are held down.
1444 *
1445 * @param[in] window The window that received the event.
1446 * @param[in] codepoint The Unicode code point of the character.
1447 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1448 * held down.
1449 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001450 * @sa @ref input_char
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001451 * @sa @ref glfwSetCharModsCallback
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001452 *
Camilla Löwyadebcc72017-11-14 23:28:12 +01001453 * @deprecated Scheduled for removal in version 4.0.
1454 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001455 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001456 *
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001457 * @ingroup input
1458 */
1459typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
1460
Camilla Berglund5c8121e2014-03-29 21:35:21 +01001461/*! @brief The function signature for file drop callbacks.
arturo89d07232013-07-10 11:42:14 +02001462 *
Camilla Berglund5c8121e2014-03-29 21:35:21 +01001463 * This is the function signature for file drop callbacks.
arturo89d07232013-07-10 11:42:14 +02001464 *
1465 * @param[in] window The window that received the event.
Camilla Berglund5c8121e2014-03-29 21:35:21 +01001466 * @param[in] count The number of dropped files.
Camilla Berglund93855ae2015-01-27 23:04:22 +01001467 * @param[in] paths The UTF-8 encoded file and/or directory path names.
arturo89d07232013-07-10 11:42:14 +02001468 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001469 * @sa @ref path_drop
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001470 * @sa @ref glfwSetDropCallback
arturo89d07232013-07-10 11:42:14 +02001471 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001472 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001473 *
arturo89d07232013-07-10 11:42:14 +02001474 * @ingroup input
1475 */
Camilla Berglund8f349e82013-12-22 19:28:46 +01001476typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);
arturo89d07232013-07-10 11:42:14 +02001477
Camilla Berglund5f68e122012-11-27 17:07:28 +01001478/*! @brief The function signature for monitor configuration callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001479 *
1480 * This is the function signature for monitor configuration callback functions.
1481 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001482 * @param[in] monitor The monitor that was connected or disconnected.
Camilla Löwyb0204672018-02-06 13:10:08 +01001483 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
1484 * values reserved for future use.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001485 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001486 * @sa @ref monitor_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001487 * @sa @ref glfwSetMonitorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001488 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001489 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001490 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001491 * @ingroup monitor
Camilla Berglund5f68e122012-11-27 17:07:28 +01001492 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001493typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
Camilla Berglund897558f2011-03-07 13:34:58 +01001494
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001495/*! @brief The function signature for joystick configuration callbacks.
1496 *
1497 * This is the function signature for joystick configuration callback
1498 * functions.
1499 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02001500 * @param[in] jid The joystick that was connected or disconnected.
Camilla Löwyb0204672018-02-06 13:10:08 +01001501 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
1502 * values reserved for future use.
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001503 *
1504 * @sa @ref joystick_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001505 * @sa @ref glfwSetJoystickCallback
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001506 *
1507 * @since Added in version 3.2.
1508 *
1509 * @ingroup input
1510 */
1511typedef void (* GLFWjoystickfun)(int,int);
1512
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001513/*! @brief Video mode type.
1514 *
1515 * This describes a single video mode.
1516 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001517 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001518 * @sa @ref glfwGetVideoMode
1519 * @sa @ref glfwGetVideoModes
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001520 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001521 * @since Added in version 1.0.
1522 * @glfw3 Added refresh rate member.
Camilla Berglund810bab72015-12-13 17:38:14 +01001523 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001524 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001525 */
Systemclusterd0a0e372013-08-29 06:15:55 +02001526typedef struct GLFWvidmode
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001527{
Camilla Berglund95835af2013-05-30 13:53:25 +02001528 /*! The width, in screen coordinates, of the video mode.
Camilla Berglundc1594112013-05-27 22:29:06 +02001529 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001530 int width;
Camilla Berglund95835af2013-05-30 13:53:25 +02001531 /*! The height, in screen coordinates, of the video mode.
Camilla Berglundc1594112013-05-27 22:29:06 +02001532 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001533 int height;
Camilla Berglundc1594112013-05-27 22:29:06 +02001534 /*! The bit depth of the red channel of the video mode.
1535 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001536 int redBits;
Camilla Berglundc1594112013-05-27 22:29:06 +02001537 /*! The bit depth of the green channel of the video mode.
1538 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001539 int greenBits;
Camilla Berglundc1594112013-05-27 22:29:06 +02001540 /*! The bit depth of the blue channel of the video mode.
1541 */
Camilla Berglund2e8446f2013-04-11 01:31:00 +02001542 int blueBits;
Camilla Berglund731812c2013-05-30 15:52:42 +02001543 /*! The refresh rate, in Hz, of the video mode.
1544 */
1545 int refreshRate;
Camilla Berglund3249f812010-09-07 17:34:51 +02001546} GLFWvidmode;
1547
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001548/*! @brief Gamma ramp.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001549 *
1550 * This describes the gamma ramp for a monitor.
1551 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001552 * @sa @ref monitor_gamma
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001553 * @sa @ref glfwGetGammaRamp
1554 * @sa @ref glfwSetGammaRamp
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001555 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001556 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001557 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02001558 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001559 */
Systemclusterd0a0e372013-08-29 06:15:55 +02001560typedef struct GLFWgammaramp
Camilla Berglund2630d492010-10-13 04:04:43 +02001561{
Camilla Berglundc1594112013-05-27 22:29:06 +02001562 /*! An array of value describing the response of the red channel.
1563 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02001564 unsigned short* red;
Camilla Berglundc1594112013-05-27 22:29:06 +02001565 /*! An array of value describing the response of the green channel.
1566 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02001567 unsigned short* green;
Camilla Berglundc1594112013-05-27 22:29:06 +02001568 /*! An array of value describing the response of the blue channel.
1569 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02001570 unsigned short* blue;
Camilla Berglundc1594112013-05-27 22:29:06 +02001571 /*! The number of elements in each array.
1572 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02001573 unsigned int size;
Camilla Berglund2630d492010-10-13 04:04:43 +02001574} GLFWgammaramp;
1575
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01001576/*! @brief Image data.
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001577 *
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02001578 * This describes a single 2D image. See the documentation for each related
1579 * function what the expected pixel format is.
1580 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001581 * @sa @ref cursor_custom
Camilla Berglundfe0317a2016-08-01 11:51:30 +02001582 * @sa @ref window_icon
Camilla Berglund810bab72015-12-13 17:38:14 +01001583 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001584 * @since Added in version 2.1.
1585 * @glfw3 Removed format and bytes-per-pixel members.
Camilla Löwy04116782018-11-05 17:37:49 +01001586 *
1587 * @ingroup window
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01001588 */
1589typedef struct GLFWimage
1590{
1591 /*! The width, in pixels, of this image.
1592 */
1593 int width;
1594 /*! The height, in pixels, of this image.
1595 */
1596 int height;
1597 /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
1598 */
1599 unsigned char* pixels;
1600} GLFWimage;
1601
Camilla Löwy953106e2017-06-18 15:13:25 +02001602/*! @brief Gamepad input state
1603 *
1604 * This describes the input state of a gamepad.
1605 *
1606 * @sa @ref gamepad
1607 * @sa @ref glfwGetGamepadState
1608 *
1609 * @since Added in version 3.3.
Camilla Löwy04116782018-11-05 17:37:49 +01001610 *
1611 * @ingroup input
Camilla Löwy953106e2017-06-18 15:13:25 +02001612 */
1613typedef struct GLFWgamepadstate
1614{
1615 /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
1616 * or `GLFW_RELEASE`.
1617 */
Camilla Löwy2d8d8f52017-07-17 21:18:15 +02001618 unsigned char buttons[15];
Camilla Löwy953106e2017-06-18 15:13:25 +02001619 /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
1620 * to 1.0 inclusive.
1621 */
1622 float axes[6];
1623} GLFWgamepadstate;
1624
Camilla Berglund3249f812010-09-07 17:34:51 +02001625
1626/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001627 * GLFW API functions
Camilla Berglund3249f812010-09-07 17:34:51 +02001628 *************************************************************************/
1629
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001630/*! @brief Initializes the GLFW library.
1631 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001632 * This function initializes the GLFW library. Before most GLFW functions can
Camilla Berglund4591ad22014-09-18 15:03:29 +02001633 * be used, GLFW must be initialized, and before an application terminates GLFW
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001634 * should be terminated in order to free any resources allocated during or
1635 * after initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001636 *
Camilla Berglund23f61762013-03-12 19:53:29 +01001637 * If this function fails, it calls @ref glfwTerminate before returning. If it
Camilla Berglund4591ad22014-09-18 15:03:29 +02001638 * succeeds, you should call @ref glfwTerminate before the application exits.
Camilla Berglund23f61762013-03-12 19:53:29 +01001639 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001640 * Additional calls to this function after successful initialization but before
Camilla Berglund0eccf752015-08-23 19:30:04 +02001641 * termination will return `GLFW_TRUE` immediately.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001642 *
Camilla Berglund0eccf752015-08-23 19:30:04 +02001643 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02001644 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001645 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001646 * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
1647 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02001648 * @remark @macos This function will change the current directory of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01001649 * application to the `Contents/Resources` subdirectory of the application's
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001650 * bundle, if present. This can be disabled with the @ref
1651 * GLFW_COCOA_CHDIR_RESOURCES init hint.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001652 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001653 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001654 *
1655 * @sa @ref intro_init
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001656 * @sa @ref glfwTerminate
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001657 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001658 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001659 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001660 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001661 */
1662GLFWAPI int glfwInit(void);
1663
1664/*! @brief Terminates the GLFW library.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001665 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001666 * This function destroys all remaining windows and cursors, restores any
1667 * modified gamma ramps and frees any other allocated resources. Once this
1668 * function is called, you must again call @ref glfwInit successfully before
1669 * you will be able to use most GLFW functions.
Camilla Berglund23f61762013-03-12 19:53:29 +01001670 *
1671 * If GLFW has been successfully initialized, this function should be called
Camilla Berglund4591ad22014-09-18 15:03:29 +02001672 * before the application exits. If initialization fails, there is no need to
1673 * call this function, as it is called by @ref glfwInit before it returns
1674 * failure.
Camilla Berglund23f61762013-03-12 19:53:29 +01001675 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001676 * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
1677 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001678 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001679 *
Camilla Berglund0df4e062015-12-13 14:07:27 +01001680 * @warning The contexts of any remaining windows must not be current on any
1681 * other thread when this function is called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001682 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001683 * @reentrancy This function must not be called from a callback.
Camilla Berglund20858762015-01-01 18:41:22 +01001684 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001685 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001686 *
1687 * @sa @ref intro_init
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001688 * @sa @ref glfwInit
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001689 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001690 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001691 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001692 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001693 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001694GLFWAPI void glfwTerminate(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001695
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001696/*! @brief Sets the specified init hint to the desired value.
1697 *
Camilla Löwy61588012017-12-12 10:54:18 +01001698 * This function sets hints for the next initialization of GLFW.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001699 *
Camilla Löwy213dd2d2017-07-25 01:55:08 +02001700 * The values you set hints to are never reset by GLFW, but they only take
1701 * effect during initialization. Once GLFW has been initialized, any values
1702 * you set will be ignored until the library is terminated and initialized
1703 * again.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001704 *
Camilla Löwy213dd2d2017-07-25 01:55:08 +02001705 * Some hints are platform specific. These may be set on any platform but they
Camilla Löwy1be81a12017-10-22 16:27:17 +02001706 * will only affect their specific platform. Other platforms will ignore them.
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00001707 * Setting these hints requires no platform specific headers or functions.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001708 *
1709 * @param[in] hint The [init hint](@ref init_hints) to set.
1710 * @param[in] value The new value of the init hint.
1711 *
1712 * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
1713 * GLFW_INVALID_VALUE.
1714 *
1715 * @remarks This function may be called before @ref glfwInit.
1716 *
1717 * @thread_safety This function must only be called from the main thread.
1718 *
1719 * @sa init_hints
1720 * @sa glfwInit
1721 *
1722 * @since Added in version 3.3.
1723 *
1724 * @ingroup init
1725 */
1726GLFWAPI void glfwInitHint(int hint, int value);
1727
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001728/*! @brief Retrieves the version of the GLFW library.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001729 *
1730 * This function retrieves the major, minor and revision numbers of the GLFW
1731 * library. It is intended for when you are using GLFW as a shared library and
1732 * want to ensure that you are using the minimum required version.
1733 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001734 * Any or all of the version arguments may be `NULL`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001735 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001736 * @param[out] major Where to store the major version number, or `NULL`.
1737 * @param[out] minor Where to store the minor version number, or `NULL`.
1738 * @param[out] rev Where to store the revision number, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001739 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001740 * @errors None.
1741 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001742 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001743 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001744 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001745 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001746 * @sa @ref intro_version
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001747 * @sa @ref glfwGetVersionString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001748 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001749 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001750 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001751 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001752 */
Camilla Berglund9a716692010-09-08 16:40:43 +02001753GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001754
Camilla Berglund6f8084f2013-02-14 13:14:17 +01001755/*! @brief Returns a string describing the compile-time configuration.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001756 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001757 * This function returns the compile-time generated
1758 * [version string](@ref intro_version_string) of the GLFW library binary. It
1759 * describes the version, platform, compiler and any platform-specific
Camilla Berglund386b6032016-02-10 13:48:49 +01001760 * compile-time options. It should not be confused with the OpenGL or OpenGL
1761 * ES version string, queried with `glGetString`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001762 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01001763 * __Do not use the version string__ to parse the GLFW library version. The
Camilla Berglund386b6032016-02-10 13:48:49 +01001764 * @ref glfwGetVersion function provides the version of the running library
1765 * binary in numerical format.
Camilla Berglundce8f97c2015-01-11 23:33:14 +01001766 *
Camilla Berglund386b6032016-02-10 13:48:49 +01001767 * @return The ASCII encoded GLFW version string.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001768 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001769 * @errors None.
1770 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001771 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001772 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001773 * @pointer_lifetime The returned string is static and compile-time generated.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001774 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001775 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001776 *
1777 * @sa @ref intro_version
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001778 * @sa @ref glfwGetVersion
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001779 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001780 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001781 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001782 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001783 */
Camilla Berglundd6fe4472010-09-13 18:05:59 +02001784GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02001785
Camilla Löwy63506412017-05-01 19:20:57 +02001786/*! @brief Returns and clears the last error for the calling thread.
1787 *
Camilla Löwy2e9aff72017-07-09 14:46:39 +02001788 * This function returns and clears the [error code](@ref errors) of the last
Camilla Löwy14a3fe02017-05-25 18:23:09 +02001789 * error that occurred on the calling thread, and optionally a UTF-8 encoded
1790 * human-readable description of it. If no error has occurred since the last
Camilla Löwy539a7282017-06-11 18:04:17 +02001791 * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
1792 * set to `NULL`.
Camilla Löwy63506412017-05-01 19:20:57 +02001793 *
Camilla Löwy14a3fe02017-05-25 18:23:09 +02001794 * @param[in] description Where to store the error description pointer, or `NULL`.
Camilla Löwy539a7282017-06-11 18:04:17 +02001795 * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
1796 * (zero).
Camilla Löwy63506412017-05-01 19:20:57 +02001797 *
1798 * @errors None.
1799 *
Camilla Löwy14a3fe02017-05-25 18:23:09 +02001800 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
1801 * should not free it yourself. It is guaranteed to be valid only until the
1802 * next error occurs or the library is terminated.
1803 *
Camilla Löwy63506412017-05-01 19:20:57 +02001804 * @remark This function may be called before @ref glfwInit.
1805 *
1806 * @thread_safety This function may be called from any thread.
1807 *
1808 * @sa @ref error_handling
1809 * @sa @ref glfwSetErrorCallback
1810 *
1811 * @since Added in version 3.3.
1812 *
1813 * @ingroup init
1814 */
Camilla Löwy14a3fe02017-05-25 18:23:09 +02001815GLFWAPI int glfwGetError(const char** description);
Camilla Löwy63506412017-05-01 19:20:57 +02001816
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001817/*! @brief Sets the error callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001818 *
1819 * This function sets the error callback, which is called with an error code
1820 * and a human-readable description each time a GLFW error occurs.
1821 *
Camilla Löwy63506412017-05-01 19:20:57 +02001822 * The error code is set before the callback is called. Calling @ref
1823 * glfwGetError from the error callback will return the same value as the error
1824 * code argument.
1825 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001826 * The error callback is called on the thread where the error occurred. If you
1827 * are using GLFW from multiple threads, your error callback needs to be
1828 * written accordingly.
1829 *
1830 * Because the description string may have been generated specifically for that
1831 * error, it is not guaranteed to be valid after the callback has returned. If
1832 * you wish to use it after the callback returns, you need to make a copy.
1833 *
Camilla Berglund20858762015-01-01 18:41:22 +01001834 * Once set, the error callback remains set even after the library has been
1835 * terminated.
1836 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01001837 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001838 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001839 * @return The previously set callback, or `NULL` if no callback was set.
1840 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001841 * @errors None.
1842 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001843 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001844 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001845 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01001846 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001847 * @sa @ref error_handling
Camilla Löwy63506412017-05-01 19:20:57 +02001848 * @sa @ref glfwGetError
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001849 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001850 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001851 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001852 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001853 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02001854GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
Camilla Berglundf5d74c42010-09-09 21:06:59 +02001855
Camilla Berglund5f68e122012-11-27 17:07:28 +01001856/*! @brief Returns the currently connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001857 *
1858 * This function returns an array of handles for all currently connected
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02001859 * monitors. The primary monitor is always first in the returned array. If no
1860 * monitors were found, this function returns `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001861 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001862 * @param[out] count Where to store the number of monitors in the returned
1863 * array. This is set to zero if an error occurred.
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02001864 * @return An array of monitor handles, or `NULL` if no monitors were found or
1865 * if an [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001866 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001867 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
1868 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001869 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
1870 * should not free it yourself. It is guaranteed to be valid only until the
1871 * monitor configuration changes or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01001872 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001873 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02001874 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001875 * @sa @ref monitor_monitors
1876 * @sa @ref monitor_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001877 * @sa @ref glfwGetPrimaryMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001878 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001879 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001880 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001881 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001882 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001883GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001884
Camilla Berglund5f68e122012-11-27 17:07:28 +01001885/*! @brief Returns the primary monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001886 *
1887 * This function returns the primary monitor. This is usually the monitor
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02001888 * where elements like the task bar or global menu bar are located.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001889 *
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02001890 * @return The primary monitor, or `NULL` if no monitors were found or if an
1891 * [error](@ref error_handling) occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001892 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001893 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
1894 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001895 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01001896 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001897 * @remark The primary monitor is always first in the array returned by @ref
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02001898 * glfwGetMonitors.
1899 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001900 * @sa @ref monitor_monitors
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001901 * @sa @ref glfwGetMonitors
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001902 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001903 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001904 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001905 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001906 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001907GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001908
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001909/*! @brief Returns the position of the monitor's viewport on the virtual screen.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001910 *
1911 * This function returns the position, in screen coordinates, of the upper-left
1912 * corner of the specified monitor.
1913 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001914 * Any or all of the position arguments may be `NULL`. If an error occurs, all
1915 * non-`NULL` position arguments will be set to zero.
1916 *
Camilla Berglunddba2d802013-01-17 23:06:56 +01001917 * @param[in] monitor The monitor to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02001918 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
1919 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001920 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001921 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
1922 * GLFW_PLATFORM_ERROR.
1923 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001924 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001925 *
1926 * @sa @ref monitor_properties
1927 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001928 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01001929 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001930 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001931 */
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001932GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
1933
1934/*! @brief Returns the physical size of the monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001935 *
1936 * This function returns the size, in millimetres, of the display area of the
1937 * specified monitor.
1938 *
Camilla Berglund4188c262015-01-18 01:55:25 +01001939 * Some systems do not provide accurate monitor size information, either
1940 * because the monitor
1941 * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
1942 * data is incorrect or because the driver does not report it accurately.
1943 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001944 * Any or all of the size arguments may be `NULL`. If an error occurs, all
1945 * non-`NULL` size arguments will be set to zero.
1946 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001947 * @param[in] monitor The monitor to query.
Camilla Berglundce8f97c2015-01-11 23:33:14 +01001948 * @param[out] widthMM Where to store the width, in millimetres, of the
1949 * monitor's display area, or `NULL`.
1950 * @param[out] heightMM Where to store the height, in millimetres, of the
1951 * monitor's display area, or `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001952 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01001953 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
1954 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001955 * @remark @win32 calculates the returned physical size from the
Camilla Berglund4188c262015-01-18 01:55:25 +01001956 * current resolution and system DPI instead of querying the monitor EDID data.
Camilla Berglund0e205772014-03-24 11:58:35 +01001957 *
Camilla Berglund951a9582016-01-31 21:32:14 +01001958 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02001959 *
1960 * @sa @ref monitor_properties
1961 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001962 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001963 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01001964 * @ingroup monitor
1965 */
Camilla Berglundce8f97c2015-01-11 23:33:14 +01001966GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001967
Camilla Löwy16bf8722017-08-29 19:19:00 +02001968/*! @brief Retrieves the content scale for the specified monitor.
1969 *
1970 * This function retrieves the content scale for the specified monitor. The
1971 * content scale is the ratio between the current DPI and the platform's
1972 * default DPI. If you scale all pixel dimensions by this scale then your
1973 * content should appear at an appropriate size. This is especially important
1974 * for text and any UI elements.
1975 *
1976 * The content scale may depend on both the monitor resolution and pixel
1977 * density and on user settings. It may be very different from the raw DPI
1978 * calculated from the physical size and current resolution.
1979 *
1980 * @param[in] monitor The monitor to query.
1981 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
1982 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
1983 *
1984 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
1985 * GLFW_PLATFORM_ERROR.
1986 *
1987 * @thread_safety This function must only be called from the main thread.
1988 *
1989 * @sa @ref monitor_scale
1990 * @sa @ref glfwGetWindowContentScale
1991 *
1992 * @since Added in version 3.3.
1993 *
1994 * @ingroup monitor
1995 */
1996GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
1997
Camilla Berglund5f68e122012-11-27 17:07:28 +01001998/*! @brief Returns the name of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01001999 *
2000 * This function returns a human-readable name, encoded as UTF-8, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02002001 * specified monitor. The name typically reflects the make and model of the
2002 * monitor and is not guaranteed to be unique among the connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002003 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002004 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002005 * @return The UTF-8 encoded name of the monitor, or `NULL` if an
2006 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002007 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002008 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2009 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002010 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2011 * should not free it yourself. It is valid until the specified monitor is
2012 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002013 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002014 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002015 *
2016 * @sa @ref monitor_properties
2017 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002018 * @since Added in version 3.0.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002019 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002020 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002021 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002022GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002023
Camilla Löwy7c2c7852017-12-07 16:19:57 +01002024/*! @brief Sets the user pointer of the specified monitor.
2025 *
2026 * This function sets the user-defined pointer of the specified monitor. The
2027 * current value is retained until the monitor is disconnected. The initial
2028 * value is `NULL`.
2029 *
2030 * This function may be called from the monitor callback, even for a monitor
2031 * that is being disconnected.
2032 *
2033 * @param[in] monitor The monitor whose pointer to set.
2034 * @param[in] pointer The new value.
2035 *
2036 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2037 *
2038 * @thread_safety This function may be called from any thread. Access is not
2039 * synchronized.
2040 *
2041 * @sa @ref monitor_userptr
2042 * @sa @ref glfwGetMonitorUserPointer
2043 *
2044 * @since Added in version 3.3.
2045 *
2046 * @ingroup monitor
2047 */
2048GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
2049
2050/*! @brief Returns the user pointer of the specified monitor.
2051 *
2052 * This function returns the current value of the user-defined pointer of the
2053 * specified monitor. The initial value is `NULL`.
2054 *
2055 * This function may be called from the monitor callback, even for a monitor
2056 * that is being disconnected.
2057 *
2058 * @param[in] monitor The monitor whose pointer to return.
2059 *
2060 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2061 *
2062 * @thread_safety This function may be called from any thread. Access is not
2063 * synchronized.
2064 *
2065 * @sa @ref monitor_userptr
2066 * @sa @ref glfwSetMonitorUserPointer
2067 *
2068 * @since Added in version 3.3.
2069 *
2070 * @ingroup monitor
2071 */
2072GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
2073
Camilla Berglund5f68e122012-11-27 17:07:28 +01002074/*! @brief Sets the monitor configuration callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002075 *
2076 * This function sets the monitor configuration callback, or removes the
2077 * currently set callback. This is called when a monitor is connected to or
2078 * disconnected from the system.
2079 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01002080 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01002081 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002082 * @return The previously set callback, or `NULL` if no callback was set or the
2083 * library had not been [initialized](@ref intro_init).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002084 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002085 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2086 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002087 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002088 *
2089 * @sa @ref monitor_event
2090 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002091 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002092 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002093 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002094 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02002095GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
Marcel Metzbeacbb32011-05-07 10:53:50 +02002096
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002097/*! @brief Returns the available video modes for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002098 *
2099 * This function returns an array of all video modes supported by the specified
Camilla Berglund948cc042013-04-16 02:02:22 +02002100 * monitor. The returned array is sorted in ascending order, first by color
2101 * bit depth (the sum of all channel depths) and then by resolution area (the
2102 * product of width and height).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002103 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002104 * @param[in] monitor The monitor to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002105 * @param[out] count Where to store the number of video modes in the returned
2106 * array. This is set to zero if an error occurred.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002107 * @return An array of video modes, or `NULL` if an
2108 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002109 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002110 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2111 * GLFW_PLATFORM_ERROR.
2112 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002113 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2114 * should not free it yourself. It is valid until the specified monitor is
2115 * disconnected, this function is called again for that monitor or the library
2116 * is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002117 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002118 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002119 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002120 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002121 * @sa @ref glfwGetVideoMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002122 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002123 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01002124 * @glfw3 Changed to return an array of modes for a specific monitor.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002125 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002126 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002127 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002128GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002129
Camilla Berglund5f68e122012-11-27 17:07:28 +01002130/*! @brief Returns the current mode of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002131 *
Camilla Berglund948cc042013-04-16 02:02:22 +02002132 * This function returns the current video mode of the specified monitor. If
Camilla Berglund4591ad22014-09-18 15:03:29 +02002133 * you have created a full screen window for that monitor, the return value
2134 * will depend on whether that window is iconified.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002135 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002136 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002137 * @return The current mode of the monitor, or `NULL` if an
2138 * [error](@ref error_handling) occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002139 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002140 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2141 * GLFW_PLATFORM_ERROR.
2142 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002143 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2144 * should not free it yourself. It is valid until the specified monitor is
2145 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002146 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002147 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002148 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002149 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002150 * @sa @ref glfwGetVideoModes
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002151 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002152 * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002153 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002154 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002155 */
Camilla Berglundce1e84d2013-05-22 22:16:43 +02002156GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
Camilla Berglund3249f812010-09-07 17:34:51 +02002157
Camilla Berglund92a71e02013-02-12 13:50:41 +01002158/*! @brief Generates a gamma ramp and sets it for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002159 *
Camilla Löwy3531c322018-12-17 17:40:18 +01002160 * This function generates an appropriately sized gamma ramp from the specified
2161 * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
2162 * a finite number greater than zero.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002163 *
Camilla Löwyce161c22016-12-06 01:14:23 +01002164 * The software controlled gamma ramp is applied _in addition_ to the hardware
2165 * gamma correction, which today is usually an approximation of sRGB gamma.
2166 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2167 * the default (usually sRGB-like) behavior.
2168 *
2169 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2170 * GLFW_SRGB_CAPABLE hint.
2171 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002172 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01002173 * @param[in] gamma The desired exponent.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002174 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002175 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2176 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
2177 *
Emmanuel Gil Peyrot9c513342017-11-17 12:17:43 +00002178 * @remark @wayland Gamma handling is a priviledged protocol, this function
2179 * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
linkmauvebc8b0482016-10-16 15:52:39 +01002180 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002181 * @thread_safety This function must only be called from the main thread.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002182 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002183 * @sa @ref monitor_gamma
2184 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002185 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01002186 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002187 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002188 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01002189GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002190
Camilla Berglund4591ad22014-09-18 15:03:29 +02002191/*! @brief Returns the current gamma ramp for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002192 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002193 * This function returns the current gamma ramp of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002194 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002195 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002196 * @return The current gamma ramp, or `NULL` if an
2197 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002198 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002199 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2200 * GLFW_PLATFORM_ERROR.
2201 *
Emmanuel Gil Peyrot9c513342017-11-17 12:17:43 +00002202 * @remark @wayland Gamma handling is a priviledged protocol, this function
2203 * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
2204 * returning `NULL`.
linkmauvebc8b0482016-10-16 15:52:39 +01002205 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002206 * @pointer_lifetime The returned structure and its arrays are allocated and
2207 * freed by GLFW. You should not free them yourself. They are valid until the
2208 * specified monitor is disconnected, this function is called again for that
2209 * monitor or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002210 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002211 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002212 *
2213 * @sa @ref monitor_gamma
2214 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002215 * @since Added in version 3.0.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002216 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002217 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002218 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002219GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002220
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002221/*! @brief Sets the current gamma ramp for the specified monitor.
2222 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002223 * This function sets the current gamma ramp for the specified monitor. The
2224 * original gamma ramp for that monitor is saved by GLFW the first time this
2225 * function is called and is restored by @ref glfwTerminate.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002226 *
Camilla Löwyce161c22016-12-06 01:14:23 +01002227 * The software controlled gamma ramp is applied _in addition_ to the hardware
2228 * gamma correction, which today is usually an approximation of sRGB gamma.
2229 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2230 * the default (usually sRGB-like) behavior.
2231 *
2232 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2233 * GLFW_SRGB_CAPABLE hint.
2234 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002235 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002236 * @param[in] ramp The gamma ramp to use.
Camilla Berglund8954af62013-02-20 19:44:52 +01002237 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002238 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2239 * GLFW_PLATFORM_ERROR.
2240 *
Camilla Löwy3531c322018-12-17 17:40:18 +01002241 * @remark The size of the specified gamma ramp should match the size of the
2242 * current ramp for that monitor.
Camilla Berglund76fff4d2015-03-10 19:02:28 +01002243 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002244 * @remark @win32 The gamma ramp size must be 256.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002245 *
Emmanuel Gil Peyrot9c513342017-11-17 12:17:43 +00002246 * @remark @wayland Gamma handling is a priviledged protocol, this function
2247 * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
linkmauvebc8b0482016-10-16 15:52:39 +01002248 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002249 * @pointer_lifetime The specified gamma ramp is copied before this function
2250 * returns.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002251 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002252 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002253 *
2254 * @sa @ref monitor_gamma
2255 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002256 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002257 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002258 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002259 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01002260GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
Camilla Berglund2630d492010-10-13 04:04:43 +02002261
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002262/*! @brief Resets all window hints to their default values.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002263 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002264 * This function resets all window hints to their
Camilla Berglunde248fb62013-03-29 14:06:23 +01002265 * [default values](@ref window_hints_values).
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002266 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002267 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2268 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002269 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01002270 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002271 * @sa @ref window_hints
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002272 * @sa @ref glfwWindowHint
Camilla Löwy61588012017-12-12 10:54:18 +01002273 * @sa @ref glfwWindowHintString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002274 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002275 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002276 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002277 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002278 */
Camilla Berglund5df4df62012-10-22 02:59:05 +02002279GLFWAPI void glfwDefaultWindowHints(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002280
2281/*! @brief Sets the specified window hint to the desired value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002282 *
Camilla Berglunded9e4032012-12-23 15:59:09 +01002283 * This function sets hints for the next call to @ref glfwCreateWindow. The
Camilla Löwy61588012017-12-12 10:54:18 +01002284 * hints, once set, retain their values until changed by a call to this
2285 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
2286 *
2287 * Only integer value hints can be set with this function. String value hints
2288 * are set with @ref glfwWindowHintString.
Camilla Berglunded9e4032012-12-23 15:59:09 +01002289 *
Camilla Berglundd6e0a432016-02-09 07:41:48 +01002290 * This function does not check whether the specified hint values are valid.
2291 * If you set hints to invalid values this will instead be reported by the next
2292 * call to @ref glfwCreateWindow.
2293 *
Camilla Löwy61588012017-12-12 10:54:18 +01002294 * Some hints are platform specific. These may be set on any platform but they
2295 * will only affect their specific platform. Other platforms will ignore them.
2296 * Setting these hints requires no platform specific headers or functions.
2297 *
Camilla Berglundd0649e62016-01-27 03:25:21 +01002298 * @param[in] hint The [window hint](@ref window_hints) to set.
2299 * @param[in] value The new value of the window hint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002300 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002301 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2302 * GLFW_INVALID_ENUM.
2303 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002304 * @thread_safety This function must only be called from the main thread.
Camilla Berglund401033c2013-03-12 19:17:07 +01002305 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002306 * @sa @ref window_hints
Camilla Löwy61588012017-12-12 10:54:18 +01002307 * @sa @ref glfwWindowHintString
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002308 * @sa @ref glfwDefaultWindowHints
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002309 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002310 * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002311 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002312 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002313 */
Camilla Berglundd0649e62016-01-27 03:25:21 +01002314GLFWAPI void glfwWindowHint(int hint, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002315
Camilla Löwy61588012017-12-12 10:54:18 +01002316/*! @brief Sets the specified window hint to the desired value.
2317 *
2318 * This function sets hints for the next call to @ref glfwCreateWindow. The
2319 * hints, once set, retain their values until changed by a call to this
2320 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
2321 *
2322 * Only string type hints can be set with this function. Integer value hints
2323 * are set with @ref glfwWindowHint.
2324 *
2325 * This function does not check whether the specified hint values are valid.
2326 * If you set hints to invalid values this will instead be reported by the next
2327 * call to @ref glfwCreateWindow.
2328 *
2329 * Some hints are platform specific. These may be set on any platform but they
2330 * will only affect their specific platform. Other platforms will ignore them.
2331 * Setting these hints requires no platform specific headers or functions.
2332 *
2333 * @param[in] hint The [window hint](@ref window_hints) to set.
2334 * @param[in] value The new value of the window hint.
2335 *
2336 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2337 * GLFW_INVALID_ENUM.
2338 *
2339 * @pointer_lifetime The specified string is copied before this function
2340 * returns.
2341 *
2342 * @thread_safety This function must only be called from the main thread.
2343 *
2344 * @sa @ref window_hints
2345 * @sa @ref glfwWindowHint
2346 * @sa @ref glfwDefaultWindowHints
2347 *
2348 * @since Added in version 3.3.
2349 *
2350 * @ingroup window
2351 */
2352GLFWAPI void glfwWindowHintString(int hint, const char* value);
2353
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002354/*! @brief Creates a window and its associated context.
2355 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002356 * This function creates a window and its associated OpenGL or OpenGL ES
2357 * context. Most of the options controlling how the window and its context
2358 * should be created are specified with [window hints](@ref window_hints).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002359 *
2360 * Successful creation does not change which context is current. Before you
Camilla Berglund4591ad22014-09-18 15:03:29 +02002361 * can use the newly created context, you need to
2362 * [make it current](@ref context_current). For information about the `share`
2363 * parameter, see @ref context_sharing.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002364 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002365 * The created window, framebuffer and context may differ from what you
2366 * requested, as not all parameters and hints are
Camilla Berglundfa0cbd92013-04-11 01:07:07 +02002367 * [hard constraints](@ref window_hints_hard). This includes the size of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02002368 * window, especially for full screen windows. To query the actual attributes
Camilla Berglunde8bceaa2015-04-07 14:37:42 +02002369 * of the created window, framebuffer and context, see @ref
2370 * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002371 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002372 * To create a full screen window, you need to specify the monitor the window
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002373 * will cover. If no monitor is specified, the window will be windowed mode.
2374 * Unless you have a way for the user to choose a specific monitor, it is
2375 * recommended that you pick the primary monitor. For more information on how
2376 * to query connected monitors, see @ref monitor_monitors.
Camilla Berglund4b7ae492013-07-07 12:06:59 +02002377 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02002378 * For full screen windows, the specified size becomes the resolution of the
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002379 * window's _desired video mode_. As long as a full screen window is not
2380 * iconified, the supported video mode most closely matching the desired video
2381 * mode is set for the specified monitor. For more information about full
2382 * screen windows, including the creation of so called _windowed full screen_
2383 * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
Camilla Berglund95654cf2014-10-02 17:35:10 +02002384 *
Camilla Berglund999f3552016-08-17 16:48:22 +02002385 * Once you have created the window, you can switch it between windowed and
Camilla Berglunde83be1d2016-11-08 12:19:06 +01002386 * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
2387 * OpenGL or OpenGL ES context.
Camilla Berglund999f3552016-08-17 16:48:22 +02002388 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002389 * By default, newly created windows use the placement recommended by the
2390 * window system. To create the window at a specific position, make it
Camilla Löwyce161c22016-12-06 01:14:23 +01002391 * initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002392 * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
2393 * it.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002394 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002395 * As long as at least one full screen window is not iconified, the screensaver
2396 * is prohibited from starting.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002397 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002398 * Window systems put limits on window sizes. Very large or very small window
2399 * dimensions may be overridden by the window system on creation. Check the
Camilla Berglund95654cf2014-10-02 17:35:10 +02002400 * actual [size](@ref window_size) after creation.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002401 *
Camilla Berglund4188c262015-01-18 01:55:25 +01002402 * The [swap interval](@ref buffer_swap) is not set during window creation and
Camilla Berglund4591ad22014-09-18 15:03:29 +02002403 * the initial value may vary depending on driver settings and defaults.
2404 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002405 * @param[in] width The desired width, in screen coordinates, of the window.
2406 * This must be greater than zero.
2407 * @param[in] height The desired height, in screen coordinates, of the window.
2408 * This must be greater than zero.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002409 * @param[in] title The initial, UTF-8 encoded window title.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002410 * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002411 * windowed mode.
Camilla Berglund71d2b572013-03-12 15:33:05 +01002412 * @param[in] share The window whose context to share resources with, or `NULL`
2413 * to not share resources.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002414 * @return The handle of the created window, or `NULL` if an
2415 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002416 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002417 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2418 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
2419 * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
2420 * GLFW_PLATFORM_ERROR.
2421 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002422 * @remark @win32 Window creation will fail if the Microsoft GDI software
2423 * OpenGL implementation is the only one available.
Camilla Berglund07db5da2013-09-26 19:15:36 +02002424 *
Camilla Berglund20bce152016-05-30 16:04:37 +02002425 * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
2426 * will be set as the initial icon for the window. If no such icon is present,
Camilla Löwyd73ab0b2017-11-16 10:08:38 +01002427 * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
2428 * see @ref glfwSetWindowIcon.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002429 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002430 * @remark @win32 The context to share resources with must not be current on
2431 * any other thread.
Camilla Berglundb19fb4c2014-12-27 21:14:41 +01002432 *
Camilla Löwyfd127d52016-12-03 19:32:00 +01002433 * @remark @macos The OS only supports forward-compatible core profile contexts
2434 * for OpenGL versions 3.2 and later. Before creating an OpenGL context of
2435 * version 3.2 or later you must set the
Camilla Löwyce161c22016-12-06 01:14:23 +01002436 * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and
2437 * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly.
2438 * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
Camilla Löwyfd127d52016-12-03 19:32:00 +01002439 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02002440 * @remark @macos The GLFW window has no icon, as it is not a document
Camilla Berglund71d2b572013-03-12 15:33:05 +01002441 * window, but the dock icon will be the same as the application bundle's icon.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002442 * For more information on bundles, see the
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002443 * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
2444 * in the Mac Developer Library.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002445 *
Camilla Löwyc50aba12017-03-01 04:09:51 +01002446 * @remark @macos The first time a window is created the menu bar is created.
2447 * If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu
2448 * bar. Otherwise a minimal menu bar is created manually with common commands
2449 * like Hide, Quit and About. The About entry opens a minimal about dialog
2450 * with information from the application's bundle. Menu bar creation can be
2451 * disabled entirely with the @ref GLFW_COCOA_MENUBAR init hint.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002452 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02002453 * @remark @macos On OS X 10.10 and later the window frame will not be rendered
Camilla Löwy58ceab52016-12-07 00:41:54 +01002454 * at full resolution on Retina displays unless the
2455 * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
2456 * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
2457 * application bundle's `Info.plist`. For more information, see
Camilla Berglund821f3e62015-03-16 22:39:14 +01002458 * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
Camilla Berglundd12b3432015-07-21 17:42:01 +02002459 * in the Mac Developer Library. The GLFW test and example programs use
2460 * a custom `Info.plist` template for this, which can be found as
2461 * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
Camilla Berglund821f3e62015-03-16 22:39:14 +01002462 *
Camilla Löwy46613152017-01-01 19:41:50 +01002463 * @remark @macos When activating frame autosaving with
Camilla Löwy9da22852017-12-12 16:45:38 +01002464 * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
2465 * window size and position may be overriden by previously saved values.
Camilla Löwy46613152017-01-01 19:41:50 +01002466 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002467 * @remark @x11 Some window managers will not respect the placement of
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002468 * initially hidden windows.
Camilla Berglund3af1c412013-09-19 21:37:01 +02002469 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002470 * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
2471 * a window to reach its requested state. This means you may not be able to
2472 * query the final size, position or other attributes directly after window
2473 * creation.
Camilla Berglund20ed0a12015-08-12 21:31:54 +02002474 *
Camilla Löwy61588012017-12-12 10:54:18 +01002475 * @remark @x11 The class part of the `WM_CLASS` window property will by
2476 * default be set to the window title passed to this function. The instance
2477 * part will use the contents of the `RESOURCE_NAME` environment variable, if
2478 * present and not empty, or fall back to the window title. Set the @ref
2479 * GLFW_X11_CLASS_NAME and @ref GLFW_X11_INSTANCE_NAME window hints to override
2480 * this.
Camilla Löwy213dd2d2017-07-25 01:55:08 +02002481 *
Emmanuel Gil Peyrotbcd8f9a2019-02-15 19:02:32 +01002482 * @remark @wayland Compositors should implement the xdg-decoration protocol
2483 * for GLFW to decorate the window properly. If this protocol isn't
2484 * supported, or if the compositor prefers client-side decorations, a very
2485 * simple fallback frame will be drawn using the wp_viewporter protocol. A
2486 * compositor can still emit close, maximize or fullscreen events, using for
2487 * instance a keybind mechanism. If neither of these protocols is supported,
2488 * the window won't be decorated.
linkmauvebc8b0482016-10-16 15:52:39 +01002489 *
2490 * @remark @wayland A full screen window will not attempt to change the mode,
2491 * no matter what the requested size or refresh rate.
2492 *
Emmanuel Gil Peyrot65166852017-02-17 15:52:50 +00002493 * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
2494 * to be implemented in the user's compositor.
linkmauvebc8b0482016-10-16 15:52:39 +01002495 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002496 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002497 *
2498 * @sa @ref window_creation
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002499 * @sa @ref glfwDestroyWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002500 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002501 * @since Added in version 3.0. Replaces `glfwOpenWindow`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002502 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002503 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002504 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002505GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002506
2507/*! @brief Destroys the specified window and its context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002508 *
2509 * This function destroys the specified window and its context. On calling
2510 * this function, no further callbacks will be called for that window.
2511 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002512 * If the context of the specified window is current on the main thread, it is
2513 * detached before being destroyed.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002514 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002515 * @param[in] window The window to destroy.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01002516 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002517 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2518 * GLFW_PLATFORM_ERROR.
2519 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002520 * @note The context of the specified window must not be current on any other
2521 * thread when this function is called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002522 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002523 * @reentrancy This function must not be called from a callback.
Camilla Berglund44372b82014-12-17 01:31:36 +01002524 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002525 * @thread_safety This function must only be called from the main thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002526 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002527 * @sa @ref window_creation
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002528 * @sa @ref glfwCreateWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002529 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002530 * @since Added in version 3.0. Replaces `glfwCloseWindow`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002531 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002532 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002533 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002534GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002535
Camilla Berglund64afb192013-03-06 23:29:37 +01002536/*! @brief Checks the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002537 *
2538 * This function returns the value of the close flag of the specified window.
2539 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01002540 * @param[in] window The window to query.
Camilla Berglund64afb192013-03-06 23:29:37 +01002541 * @return The value of the close flag.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002542 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002543 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2544 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002545 * @thread_safety This function may be called from any thread. Access is not
2546 * synchronized.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002547 *
2548 * @sa @ref window_close
2549 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002550 * @since Added in version 3.0.
Camilla Berglund6632cc72013-07-11 02:00:48 +02002551 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01002552 * @ingroup window
2553 */
2554GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
2555
Camilla Berglund64afb192013-03-06 23:29:37 +01002556/*! @brief Sets the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002557 *
2558 * This function sets the value of the close flag of the specified window.
2559 * This can be used to override the user's attempt to close the window, or
2560 * to signal that it should be closed.
2561 *
Camilla Berglund64afb192013-03-06 23:29:37 +01002562 * @param[in] window The window whose flag to change.
Camilla Berglund6fadf372013-03-01 13:45:12 +01002563 * @param[in] value The new value.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002564 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002565 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2566 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002567 * @thread_safety This function may be called from any thread. Access is not
2568 * synchronized.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002569 *
2570 * @sa @ref window_close
2571 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002572 * @since Added in version 3.0.
Camilla Berglund6632cc72013-07-11 02:00:48 +02002573 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01002574 * @ingroup window
Camilla Berglund6fadf372013-03-01 13:45:12 +01002575 */
2576GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
2577
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002578/*! @brief Sets the title of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002579 *
2580 * This function sets the window title, encoded as UTF-8, of the specified
2581 * window.
2582 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002583 * @param[in] window The window whose title to change.
2584 * @param[in] title The UTF-8 encoded window title.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01002585 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002586 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2587 * GLFW_PLATFORM_ERROR.
2588 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02002589 * @remark @macos The window title will not be updated until the next time you
Camilla Berglund951a9582016-01-31 21:32:14 +01002590 * process events.
Camilla Berglund6412dcb2015-04-07 21:52:29 +02002591 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002592 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002593 *
2594 * @sa @ref window_title
2595 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002596 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01002597 * @glfw3 Added window handle parameter.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002598 *
2599 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002600 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002601GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002602
Camilla Berglundb823f712016-03-07 14:55:30 +01002603/*! @brief Sets the icon for the specified window.
2604 *
2605 * This function sets the icon of the specified window. If passed an array of
2606 * candidate images, those of or closest to the sizes desired by the system are
2607 * selected. If no images are specified, the window reverts to its default
2608 * icon.
2609 *
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02002610 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
2611 * bits per channel with the red channel first. They are arranged canonically
2612 * as packed sequential rows, starting from the top-left corner.
2613 *
Camilla Berglundb823f712016-03-07 14:55:30 +01002614 * The desired image sizes varies depending on platform and system settings.
2615 * The selected images will be rescaled as needed. Good sizes include 16x16,
2616 * 32x32 and 48x48.
2617 *
2618 * @param[in] window The window whose icon to set.
2619 * @param[in] count The number of images in the specified array, or zero to
2620 * revert to the default window icon.
2621 * @param[in] images The images to create the icon from. This is ignored if
2622 * count is zero.
2623 *
2624 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2625 * GLFW_PLATFORM_ERROR.
2626 *
2627 * @pointer_lifetime The specified image data is copied before this function
2628 * returns.
2629 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02002630 * @remark @macos The GLFW window has no icon, as it is not a document
Camilla Berglund20bce152016-05-30 16:04:37 +02002631 * window, so this function does nothing. The dock icon will be the same as
2632 * the application bundle's icon. For more information on bundles, see the
Camilla Berglundb823f712016-03-07 14:55:30 +01002633 * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
2634 * in the Mac Developer Library.
2635 *
Emmanuel Gil Peyrota1620042017-12-03 04:19:15 +01002636 * @remark @wayland There is no existing protocol to change an icon, the
2637 * window will thus inherit the one defined in the application's desktop file.
2638 * This function always emits @ref GLFW_PLATFORM_ERROR.
linkmauvebc8b0482016-10-16 15:52:39 +01002639 *
Camilla Berglundb823f712016-03-07 14:55:30 +01002640 * @thread_safety This function must only be called from the main thread.
2641 *
2642 * @sa @ref window_icon
2643 *
2644 * @since Added in version 3.2.
2645 *
2646 * @ingroup window
2647 */
2648GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
2649
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002650/*! @brief Retrieves the position of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002651 *
2652 * This function retrieves the position, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002653 * upper-left corner of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002654 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002655 * Any or all of the position arguments may be `NULL`. If an error occurs, all
2656 * non-`NULL` position arguments will be set to zero.
2657 *
Camilla Berglund7c193232013-01-24 19:30:31 +01002658 * @param[in] window The window to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002659 * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002660 * the content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002661 * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002662 * the content area, or `NULL`.
Camilla Berglund7c193232013-01-24 19:30:31 +01002663 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002664 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2665 * GLFW_PLATFORM_ERROR.
2666 *
linkmauvebc8b0482016-10-16 15:52:39 +01002667 * @remark @wayland There is no way for an application to retrieve the global
2668 * position of its windows, this function will always emit @ref
2669 * GLFW_PLATFORM_ERROR.
2670 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002671 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01002672 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002673 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002674 * @sa @ref glfwSetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002675 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002676 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002677 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002678 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01002679 */
2680GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
2681
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002682/*! @brief Sets the position of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002683 *
2684 * This function sets the position, in screen coordinates, of the upper-left
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002685 * corner of the content area of the specified windowed mode window. If the
Camilla Berglund4591ad22014-09-18 15:03:29 +02002686 * window is a full screen window, this function does nothing.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002687 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002688 * __Do not use this function__ to move an already visible window unless you
2689 * have very good reasons for doing so, as it will confuse and annoy the user.
2690 *
2691 * The window manager may put limits on what positions are allowed. GLFW
2692 * cannot and should not override these limits.
2693 *
Camilla Berglund7c193232013-01-24 19:30:31 +01002694 * @param[in] window The window to query.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002695 * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
2696 * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
Camilla Berglund7c193232013-01-24 19:30:31 +01002697 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002698 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2699 * GLFW_PLATFORM_ERROR.
2700 *
linkmauvebc8b0482016-10-16 15:52:39 +01002701 * @remark @wayland There is no way for an application to set the global
2702 * position of its windows, this function will always emit @ref
2703 * GLFW_PLATFORM_ERROR.
2704 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002705 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002706 *
2707 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002708 * @sa @ref glfwGetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002709 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002710 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01002711 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002712 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002713 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01002714 */
Camilla Berglund52f718d2013-02-12 12:01:12 +01002715GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
Camilla Berglund7c193232013-01-24 19:30:31 +01002716
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002717/*! @brief Retrieves the size of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002718 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002719 * This function retrieves the size, in screen coordinates, of the content area
Camilla Berglund521fa7d2013-09-26 20:02:19 +02002720 * of the specified window. If you wish to retrieve the size of the
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002721 * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002722 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002723 * Any or all of the size arguments may be `NULL`. If an error occurs, all
2724 * non-`NULL` size arguments will be set to zero.
2725 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002726 * @param[in] window The window whose size to retrieve.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002727 * @param[out] width Where to store the width, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002728 * content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002729 * @param[out] height Where to store the height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002730 * content area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002731 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002732 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2733 * GLFW_PLATFORM_ERROR.
2734 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002735 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01002736 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002737 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002738 * @sa @ref glfwSetWindowSize
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002739 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002740 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01002741 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002742 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002743 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002744 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002745GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002746
Camilla Berglundd84772d2014-02-13 02:57:59 +01002747/*! @brief Sets the size limits of the specified window.
2748 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002749 * This function sets the size limits of the content area of the specified
Emmanuel Gil Peyrotf0f5d9f2016-04-09 00:42:58 +01002750 * window. If the window is full screen, the size limits only take effect
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002751 * once it is made windowed. If the window is not resizable, this function
2752 * does nothing.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002753 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002754 * The size limits are applied immediately to a windowed mode window and may
2755 * cause it to be resized.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002756 *
Camilla Berglund12a69562016-05-04 16:28:08 +02002757 * The maximum dimensions must be greater than or equal to the minimum
2758 * dimensions and all must be greater than or equal to zero.
2759 *
Camilla Berglundd84772d2014-02-13 02:57:59 +01002760 * @param[in] window The window to set limits for.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002761 * @param[in] minwidth The minimum width, in screen coordinates, of the content
Camilla Berglundd84772d2014-02-13 02:57:59 +01002762 * area, or `GLFW_DONT_CARE`.
2763 * @param[in] minheight The minimum height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002764 * content area, or `GLFW_DONT_CARE`.
2765 * @param[in] maxwidth The maximum width, in screen coordinates, of the content
Camilla Berglundd84772d2014-02-13 02:57:59 +01002766 * area, or `GLFW_DONT_CARE`.
2767 * @param[in] maxheight The maximum height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002768 * content area, or `GLFW_DONT_CARE`.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002769 *
Camilla Berglund12a69562016-05-04 16:28:08 +02002770 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2771 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01002772 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002773 * @remark If you set size limits and an aspect ratio that conflict, the
Camilla Berglundd84772d2014-02-13 02:57:59 +01002774 * results are undefined.
2775 *
linkmauvebc8b0482016-10-16 15:52:39 +01002776 * @remark @wayland The size limits will not be applied until the window is
2777 * actually resized, either by the user or by the compositor.
2778 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002779 * @thread_safety This function must only be called from the main thread.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002780 *
2781 * @sa @ref window_sizelimits
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002782 * @sa @ref glfwSetWindowAspectRatio
Camilla Berglundd84772d2014-02-13 02:57:59 +01002783 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002784 * @since Added in version 3.2.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002785 *
2786 * @ingroup window
2787 */
2788GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
2789
2790/*! @brief Sets the aspect ratio of the specified window.
2791 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002792 * This function sets the required aspect ratio of the content area of the
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002793 * specified window. If the window is full screen, the aspect ratio only takes
2794 * effect once it is made windowed. If the window is not resizable, this
Camilla Berglundd84772d2014-02-13 02:57:59 +01002795 * function does nothing.
2796 *
Camilla Berglundaf5b82a2015-10-19 16:01:42 +02002797 * The aspect ratio is specified as a numerator and a denominator and both
2798 * values must be greater than zero. For example, the common 16:9 aspect ratio
2799 * is specified as 16 and 9, respectively.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002800 *
Camilla Berglundaf5b82a2015-10-19 16:01:42 +02002801 * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
2802 * ratio limit is disabled.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002803 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002804 * The aspect ratio is applied immediately to a windowed mode window and may
2805 * cause it to be resized.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002806 *
2807 * @param[in] window The window to set limits for.
2808 * @param[in] numer The numerator of the desired aspect ratio, or
2809 * `GLFW_DONT_CARE`.
2810 * @param[in] denom The denominator of the desired aspect ratio, or
2811 * `GLFW_DONT_CARE`.
2812 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002813 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
2814 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
2815 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002816 * @remark If you set size limits and an aspect ratio that conflict, the
Camilla Berglundd84772d2014-02-13 02:57:59 +01002817 * results are undefined.
2818 *
linkmauvebc8b0482016-10-16 15:52:39 +01002819 * @remark @wayland The aspect ratio will not be applied until the window is
2820 * actually resized, either by the user or by the compositor.
2821 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002822 * @thread_safety This function must only be called from the main thread.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002823 *
2824 * @sa @ref window_sizelimits
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002825 * @sa @ref glfwSetWindowSizeLimits
Camilla Berglundd84772d2014-02-13 02:57:59 +01002826 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002827 * @since Added in version 3.2.
Camilla Berglundd84772d2014-02-13 02:57:59 +01002828 *
2829 * @ingroup window
2830 */
2831GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
2832
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002833/*! @brief Sets the size of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002834 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002835 * This function sets the size, in screen coordinates, of the content area of
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002836 * the specified window.
2837 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002838 * For full screen windows, this function updates the resolution of its desired
2839 * video mode and switches to the video mode closest to it, without affecting
2840 * the window's context. As the context is unaffected, the bit depths of the
2841 * framebuffer remain unchanged.
2842 *
2843 * If you wish to update the refresh rate of the desired video mode in addition
2844 * to its resolution, see @ref glfwSetWindowMonitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002845 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002846 * The window manager may put limits on what sizes are allowed. GLFW cannot
2847 * and should not override these limits.
2848 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002849 * @param[in] window The window to resize.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002850 * @param[in] width The desired width, in screen coordinates, of the window
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002851 * content area.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01002852 * @param[in] height The desired height, in screen coordinates, of the window
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01002853 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002854 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002855 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2856 * GLFW_PLATFORM_ERROR.
2857 *
linkmauvebc8b0482016-10-16 15:52:39 +01002858 * @remark @wayland A full screen window will not attempt to change the mode,
2859 * no matter what the requested size.
2860 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002861 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002862 *
2863 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002864 * @sa @ref glfwGetWindowSize
2865 * @sa @ref glfwSetWindowMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002866 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002867 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01002868 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002869 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002870 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002871 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002872GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002873
Camilla Berglund34981632013-06-03 12:51:57 +02002874/*! @brief Retrieves the size of the framebuffer of the specified window.
2875 *
2876 * This function retrieves the size, in pixels, of the framebuffer of the
Camilla Berglund521fa7d2013-09-26 20:02:19 +02002877 * specified window. If you wish to retrieve the size of the window in screen
2878 * coordinates, see @ref glfwGetWindowSize.
Camilla Berglund34981632013-06-03 12:51:57 +02002879 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002880 * Any or all of the size arguments may be `NULL`. If an error occurs, all
2881 * non-`NULL` size arguments will be set to zero.
2882 *
Camilla Berglund34981632013-06-03 12:51:57 +02002883 * @param[in] window The window whose framebuffer to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002884 * @param[out] width Where to store the width, in pixels, of the framebuffer,
2885 * or `NULL`.
2886 * @param[out] height Where to store the height, in pixels, of the framebuffer,
2887 * or `NULL`.
Camilla Berglund34981632013-06-03 12:51:57 +02002888 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002889 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2890 * GLFW_PLATFORM_ERROR.
2891 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002892 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01002893 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002894 * @sa @ref window_fbsize
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002895 * @sa @ref glfwSetFramebufferSizeCallback
Camilla Berglund34981632013-06-03 12:51:57 +02002896 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002897 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002898 *
Camilla Berglund34981632013-06-03 12:51:57 +02002899 * @ingroup window
2900 */
2901GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
2902
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01002903/*! @brief Retrieves the size of the frame of the window.
2904 *
2905 * This function retrieves the size, in screen coordinates, of each edge of the
2906 * frame of the specified window. This size includes the title bar, if the
2907 * window has one. The size of the frame may vary depending on the
2908 * [window-related hints](@ref window_hints_wnd) used to create it.
2909 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002910 * Because this function retrieves the size of each window frame edge and not
2911 * the offset along a particular coordinate axis, the retrieved values will
2912 * always be zero or positive.
2913 *
2914 * Any or all of the size arguments may be `NULL`. If an error occurs, all
2915 * non-`NULL` size arguments will be set to zero.
2916 *
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01002917 * @param[in] window The window whose frame size to query.
2918 * @param[out] left Where to store the size, in screen coordinates, of the left
Camilla Berglund4591ad22014-09-18 15:03:29 +02002919 * edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02002920 * @param[out] top Where to store the size, in screen coordinates, of the top
Camilla Berglund4591ad22014-09-18 15:03:29 +02002921 * edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02002922 * @param[out] right Where to store the size, in screen coordinates, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02002923 * right edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02002924 * @param[out] bottom Where to store the size, in screen coordinates, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02002925 * bottom edge of the window frame, or `NULL`.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01002926 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002927 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2928 * GLFW_PLATFORM_ERROR.
2929 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002930 * @thread_safety This function must only be called from the main thread.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01002931 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002932 * @sa @ref window_size
2933 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002934 * @since Added in version 3.1.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01002935 *
2936 * @ingroup window
2937 */
2938GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
2939
Camilla Löwy16bf8722017-08-29 19:19:00 +02002940/*! @brief Retrieves the content scale for the specified window.
2941 *
2942 * This function retrieves the content scale for the specified window. The
2943 * content scale is the ratio between the current DPI and the platform's
2944 * default DPI. If you scale all pixel dimensions by this scale then your
2945 * content should appear at an appropriate size. This is especially important
2946 * for text and any UI elements.
2947 *
2948 * On systems where each monitors can have its own content scale, the window
2949 * content scale will depend on which monitor the system considers the window
2950 * to be on.
2951 *
2952 * @param[in] window The window to query.
2953 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
2954 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
2955 *
2956 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2957 * GLFW_PLATFORM_ERROR.
2958 *
2959 * @thread_safety This function must only be called from the main thread.
2960 *
2961 * @sa @ref window_scale
Camilla Löwy370eac32017-12-11 21:26:40 +01002962 * @sa @ref glfwSetWindowContentScaleCallback
Camilla Löwy16bf8722017-08-29 19:19:00 +02002963 * @sa @ref glfwGetMonitorContentScale
2964 *
2965 * @since Added in version 3.3.
2966 *
2967 * @ingroup window
2968 */
2969GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
2970
Camilla Löwy11e47f02017-09-25 23:14:45 +02002971/*! @brief Returns the opacity of the whole window.
2972 *
2973 * This function returns the opacity of the window, including any decorations.
2974 *
2975 * The opacity (or alpha) value is a positive finite number between zero and
2976 * one, where zero is fully transparent and one is fully opaque. If the system
2977 * does not support whole window transparency, this function always returns one.
2978 *
2979 * The initial opacity value for newly created windows is one.
2980 *
2981 * @param[in] window The window to query.
2982 * @return The opacity value of the specified window.
2983 *
2984 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2985 * GLFW_PLATFORM_ERROR.
2986 *
2987 * @thread_safety This function must only be called from the main thread.
2988 *
2989 * @sa @ref window_transparency
2990 * @sa @ref glfwSetWindowOpacity
2991 *
2992 * @since Added in version 3.3.
2993 *
2994 * @ingroup window
2995 */
2996GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
2997
2998/*! @brief Sets the opacity of the whole window.
2999 *
3000 * This function sets the opacity of the window, including any decorations.
3001 *
3002 * The opacity (or alpha) value is a positive finite number between zero and
3003 * one, where zero is fully transparent and one is fully opaque.
3004 *
3005 * The initial opacity value for newly created windows is one.
3006 *
3007 * A window created with framebuffer transparency may not use whole window
3008 * transparency. The results of doing this are undefined.
3009 *
3010 * @param[in] window The window to set the opacity for.
3011 * @param[in] opacity The desired opacity of the specified window.
3012 *
3013 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3014 * GLFW_PLATFORM_ERROR.
3015 *
3016 * @thread_safety This function must only be called from the main thread.
3017 *
3018 * @sa @ref window_transparency
3019 * @sa @ref glfwGetWindowOpacity
3020 *
3021 * @since Added in version 3.3.
3022 *
3023 * @ingroup window
3024 */
3025GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
3026
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003027/*! @brief Iconifies the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003028 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003029 * This function iconifies (minimizes) the specified window if it was
3030 * previously restored. If the window is already iconified, this function does
3031 * nothing.
3032 *
3033 * If the specified window is a full screen window, the original monitor
3034 * resolution is restored until the window is restored.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003035 *
3036 * @param[in] window The window to iconify.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003037 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003038 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3039 * GLFW_PLATFORM_ERROR.
3040 *
linkmauvebc8b0482016-10-16 15:52:39 +01003041 * @remark @wayland There is no concept of iconification in wl_shell, this
Emmanuel Gil Peyrota1620042017-12-03 04:19:15 +01003042 * function will emit @ref GLFW_PLATFORM_ERROR when using this deprecated
3043 * protocol.
linkmauvebc8b0482016-10-16 15:52:39 +01003044 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003045 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003046 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003047 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003048 * @sa @ref glfwRestoreWindow
3049 * @sa @ref glfwMaximizeWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003050 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003051 * @since Added in version 2.1.
Camilla Berglund951a9582016-01-31 21:32:14 +01003052 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003053 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003054 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003055 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003056GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003057
3058/*! @brief Restores the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003059 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003060 * This function restores the specified window if it was previously iconified
Camilla Berglunda10caa42015-10-13 12:50:59 +02003061 * (minimized) or maximized. If the window is already restored, this function
3062 * does nothing.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003063 *
3064 * If the specified window is a full screen window, the resolution chosen for
3065 * the window is restored on the selected monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003066 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003067 * @param[in] window The window to restore.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003068 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003069 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3070 * GLFW_PLATFORM_ERROR.
3071 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003072 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003073 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003074 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003075 * @sa @ref glfwIconifyWindow
3076 * @sa @ref glfwMaximizeWindow
Camilla Berglunde248fb62013-03-29 14:06:23 +01003077 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003078 * @since Added in version 2.1.
Camilla Berglund951a9582016-01-31 21:32:14 +01003079 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003080 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01003081 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003082 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003083GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003084
Camilla Berglunda10caa42015-10-13 12:50:59 +02003085/*! @brief Maximizes the specified window.
3086 *
3087 * This function maximizes the specified window if it was previously not
3088 * maximized. If the window is already maximized, this function does nothing.
3089 *
3090 * If the specified window is a full screen window, this function does nothing.
3091 *
3092 * @param[in] window The window to maximize.
3093 *
Camilla Berglundf5b71f52016-05-27 14:20:39 +02003094 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3095 * GLFW_PLATFORM_ERROR.
3096 *
Camilla Berglunda10caa42015-10-13 12:50:59 +02003097 * @par Thread Safety
3098 * This function may only be called from the main thread.
3099 *
3100 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003101 * @sa @ref glfwIconifyWindow
3102 * @sa @ref glfwRestoreWindow
Camilla Berglunda10caa42015-10-13 12:50:59 +02003103 *
3104 * @since Added in GLFW 3.2.
3105 *
3106 * @ingroup window
3107 */
3108GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
3109
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003110/*! @brief Makes the specified window visible.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003111 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003112 * This function makes the specified window visible if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003113 * hidden. If the window is already visible or is in full screen mode, this
Camilla Berglund1e9383d2012-11-23 11:41:53 +01003114 * function does nothing.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003115 *
Doug Binks0be4f3f2018-05-29 14:51:36 +01003116 * By default, windowed mode windows are focused when shown
3117 * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
3118 * to change this behavior for all newly created windows, or change the
3119 * behavior for an existing window with @ref glfwSetWindowAttrib.
3120 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003121 * @param[in] window The window to make visible.
3122 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003123 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3124 * GLFW_PLATFORM_ERROR.
3125 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003126 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003127 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003128 * @sa @ref window_hide
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003129 * @sa @ref glfwHideWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003130 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003131 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003132 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003133 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003134 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003135GLFWAPI void glfwShowWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003136
3137/*! @brief Hides the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003138 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003139 * This function hides the specified window if it was previously visible. If
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003140 * the window is already hidden or is in full screen mode, this function does
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003141 * nothing.
3142 *
3143 * @param[in] window The window to hide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003144 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003145 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3146 * GLFW_PLATFORM_ERROR.
3147 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003148 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003149 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003150 * @sa @ref window_hide
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003151 * @sa @ref glfwShowWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003152 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003153 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003154 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003155 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003156 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003157GLFWAPI void glfwHideWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003158
Camilla Berglundbaf57442016-02-21 15:42:49 +01003159/*! @brief Brings the specified window to front and sets input focus.
3160 *
3161 * This function brings the specified window to front and sets input focus.
3162 * The window should already be visible and not iconified.
3163 *
3164 * By default, both windowed and full screen mode windows are focused when
Camilla Löwyce161c22016-12-06 01:14:23 +01003165 * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
3166 * disable this behavior.
Camilla Berglundbaf57442016-02-21 15:42:49 +01003167 *
Doug Binks0be4f3f2018-05-29 14:51:36 +01003168 * Also by default, windowed mode windows are focused when shown
3169 * with @ref glfwShowWindow. Set the
3170 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
3171 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003172 * __Do not use this function__ to steal focus from other applications unless
3173 * you are certain that is what the user wants. Focus stealing can be
3174 * extremely disruptive.
3175 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003176 * For a less disruptive way of getting the user's attention, see
3177 * [attention requests](@ref window_attention).
3178 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003179 * @param[in] window The window to give input focus.
3180 *
3181 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3182 * GLFW_PLATFORM_ERROR.
3183 *
linkmauvebc8b0482016-10-16 15:52:39 +01003184 * @remark @wayland It is not possible for an application to bring its windows
3185 * to front, this function will always emit @ref GLFW_PLATFORM_ERROR.
3186 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003187 * @thread_safety This function must only be called from the main thread.
3188 *
3189 * @sa @ref window_focus
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003190 * @sa @ref window_attention
Camilla Berglundbaf57442016-02-21 15:42:49 +01003191 *
3192 * @since Added in version 3.2.
3193 *
3194 * @ingroup window
3195 */
3196GLFWAPI void glfwFocusWindow(GLFWwindow* window);
3197
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003198/*! @brief Requests user attention to the specified window.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003199 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003200 * This function requests user attention to the specified window. On
3201 * platforms where this is not supported, attention is requested to the
3202 * application as a whole.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003203 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003204 * Once the user has given attention, usually by focusing the window or
3205 * application, the system will end the request automatically.
3206 *
3207 * @param[in] window The window to request attention to.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003208 *
3209 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3210 * GLFW_PLATFORM_ERROR.
3211 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003212 * @remark @macos Attention is requested to the application as a whole, not the
3213 * specific window.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003214 *
3215 * @thread_safety This function must only be called from the main thread.
3216 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003217 * @sa @ref window_attention
3218 *
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003219 * @since Added in version 3.3.
3220 *
3221 * @ingroup window
3222 */
3223GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
3224
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003225/*! @brief Returns the monitor that the window uses for full screen mode.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003226 *
3227 * This function returns the handle of the monitor that the specified window is
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003228 * in full screen on.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003229 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01003230 * @param[in] window The window to query.
Camilla Berglund999f3552016-08-17 16:48:22 +02003231 * @return The monitor, or `NULL` if the window is in windowed mode or an
3232 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003233 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003234 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3235 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003236 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003237 *
3238 * @sa @ref window_monitor
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003239 * @sa @ref glfwSetWindowMonitor
Camilla Berglund4591ad22014-09-18 15:03:29 +02003240 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003241 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01003242 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01003243 * @ingroup window
Camilla Berglund41bc0d12012-11-27 16:55:04 +01003244 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003245GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01003246
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003247/*! @brief Sets the mode, monitor, video mode and placement of a window.
3248 *
3249 * This function sets the monitor that the window uses for full screen mode or,
3250 * if the monitor is `NULL`, makes it windowed mode.
3251 *
3252 * When setting a monitor, this function updates the width, height and refresh
3253 * rate of the desired video mode and switches to the video mode closest to it.
3254 * The window position is ignored when setting a monitor.
3255 *
3256 * When the monitor is `NULL`, the position, width and height are used to
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003257 * place the window content area. The refresh rate is ignored when no monitor
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003258 * is specified.
3259 *
3260 * If you only wish to update the resolution of a full screen window or the
3261 * size of a windowed mode window, see @ref glfwSetWindowSize.
3262 *
3263 * When a window transitions from full screen to windowed mode, this function
3264 * restores any previous window settings such as whether it is decorated,
linkmauvebc8b0482016-10-16 15:52:39 +01003265 * floating, resizable, has size or aspect ratio limits, etc.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003266 *
3267 * @param[in] window The window whose monitor, size or video mode to set.
3268 * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
3269 * @param[in] xpos The desired x-coordinate of the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003270 * content area.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003271 * @param[in] ypos The desired y-coordinate of the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003272 * content area.
3273 * @param[in] width The desired with, in screen coordinates, of the content
3274 * area or video mode.
3275 * @param[in] height The desired height, in screen coordinates, of the content
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003276 * area or video mode.
Camilla Berglund325729d2016-05-22 14:25:04 +02003277 * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
3278 * or `GLFW_DONT_CARE`.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003279 *
3280 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3281 * GLFW_PLATFORM_ERROR.
3282 *
Camilla Berglundec171612016-10-28 06:20:20 +02003283 * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
3284 * affected by any resizing or mode switching, although you may need to update
3285 * your viewport if the framebuffer size has changed.
3286 *
linkmauvebc8b0482016-10-16 15:52:39 +01003287 * @remark @wayland The desired window position is ignored, as there is no way
3288 * for an application to set this property.
3289 *
3290 * @remark @wayland Setting the window to full screen will not attempt to
3291 * change the mode, no matter what the requested size or refresh rate.
3292 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003293 * @thread_safety This function must only be called from the main thread.
3294 *
3295 * @sa @ref window_monitor
3296 * @sa @ref window_full_screen
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003297 * @sa @ref glfwGetWindowMonitor
3298 * @sa @ref glfwSetWindowSize
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003299 *
3300 * @since Added in version 3.2.
3301 *
3302 * @ingroup window
3303 */
3304GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
3305
Camilla Berglundad1f6f02013-05-27 15:30:32 +02003306/*! @brief Returns an attribute of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003307 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003308 * This function returns the value of an attribute of the specified window or
3309 * its OpenGL or OpenGL ES context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003310 *
Camilla Berglund1e9383d2012-11-23 11:41:53 +01003311 * @param[in] window The window to query.
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02003312 * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
3313 * return.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003314 * @return The value of the attribute, or zero if an
3315 * [error](@ref error_handling) occurred.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01003316 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003317 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3318 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
3319 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003320 * @remark Framebuffer related hints are not window attributes. See @ref
Camilla Berglund59abeeb2015-04-07 14:34:12 +02003321 * window_attribs_fb for more information.
3322 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003323 * @remark Zero is a valid value for many window and context related
Camilla Berglund59abeeb2015-04-07 14:34:12 +02003324 * attributes so you cannot use a return value of zero as an indication of
3325 * errors. However, this function should not fail as long as it is passed
3326 * valid arguments and the library has been [initialized](@ref intro_init).
3327 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003328 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003329 *
3330 * @sa @ref window_attribs
Camilla Löwy9e560992016-09-30 01:52:22 +02003331 * @sa @ref glfwSetWindowAttrib
Camilla Berglund4591ad22014-09-18 15:03:29 +02003332 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003333 * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
Camilla Berglund4188c262015-01-18 01:55:25 +01003334 * `glfwGetGLVersion`.
Camilla Berglund0e205772014-03-24 11:58:35 +01003335 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003336 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003337 */
Camilla Berglundad1f6f02013-05-27 15:30:32 +02003338GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003339
Camilla Löwy9e560992016-09-30 01:52:22 +02003340/*! @brief Sets an attribute of the specified window.
3341 *
3342 * This function sets the value of an attribute of the specified window.
3343 *
3344 * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
3345 * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
Doug Binks0be4f3f2018-05-29 14:51:36 +01003346 * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
3347 * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
3348 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
Camilla Löwy9e560992016-09-30 01:52:22 +02003349 *
3350 * Some of these attributes are ignored for full screen windows. The new
3351 * value will take effect if the window is later made windowed.
3352 *
3353 * Some of these attributes are ignored for windowed mode windows. The new
3354 * value will take effect if the window is later made full screen.
3355 *
3356 * @param[in] window The window to set the attribute for.
3357 * @param[in] attrib A supported window attribute.
3358 * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
3359 *
3360 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3361 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3362 *
3363 * @remark Calling @ref glfwGetWindowAttrib will always return the latest
3364 * value, even if that value is ignored by the current mode of the window.
3365 *
3366 * @thread_safety This function must only be called from the main thread.
3367 *
3368 * @sa @ref window_attribs
3369 * @sa @ref glfwGetWindowAttrib
3370 *
3371 * @since Added in version 3.3.
3372 *
3373 * @ingroup window
3374 */
3375GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
3376
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003377/*! @brief Sets the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003378 *
3379 * This function sets the user-defined pointer of the specified window. The
3380 * current value is retained until the window is destroyed. The initial value
3381 * is `NULL`.
3382 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003383 * @param[in] window The window whose pointer to set.
3384 * @param[in] pointer The new value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003385 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003386 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3387 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003388 * @thread_safety This function may be called from any thread. Access is not
3389 * synchronized.
Camilla Berglund0e205772014-03-24 11:58:35 +01003390 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003391 * @sa @ref window_userptr
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003392 * @sa @ref glfwGetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003393 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003394 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003395 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003396 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003397 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003398GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003399
3400/*! @brief Returns the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003401 *
3402 * This function returns the current value of the user-defined pointer of the
3403 * specified window. The initial value is `NULL`.
3404 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003405 * @param[in] window The window whose pointer to return.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003406 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003407 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3408 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003409 * @thread_safety This function may be called from any thread. Access is not
3410 * synchronized.
Camilla Berglund0e205772014-03-24 11:58:35 +01003411 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003412 * @sa @ref window_userptr
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003413 * @sa @ref glfwSetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003414 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003415 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003416 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003417 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003418 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003419GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003420
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01003421/*! @brief Sets the position callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003422 *
3423 * This function sets the position callback of the specified window, which is
Camilla Löwy2867ca12017-10-29 16:27:15 +01003424 * called when the window is moved. The callback is provided with the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003425 * position, in screen coordinates, of the upper-left corner of the content
3426 * area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003427 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01003428 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003429 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01003430 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003431 * @return The previously set callback, or `NULL` if no callback was set or the
3432 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02003433 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003434 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3435 *
linkmauvebc8b0482016-10-16 15:52:39 +01003436 * @remark @wayland This callback will never be called, as there is no way for
3437 * an application to know its global position.
3438 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003439 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003440 *
3441 * @sa @ref window_pos
3442 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003443 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003444 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01003445 * @ingroup window
3446 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02003447GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01003448
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003449/*! @brief Sets the size callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003450 *
3451 * This function sets the size callback of the specified window, which is
3452 * called when the window is resized. The callback is provided with the size,
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003453 * in screen coordinates, of the content area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003454 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003455 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003456 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003457 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003458 * @return The previously set callback, or `NULL` if no callback was set or the
3459 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02003460 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003461 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3462 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003463 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003464 *
3465 * @sa @ref window_size
3466 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003467 * @since Added in version 1.0.
3468 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01003469 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003470 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003471 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02003472GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003473
3474/*! @brief Sets the close callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003475 *
3476 * This function sets the close callback of the specified window, which is
3477 * called when the user attempts to close the window, for example by clicking
3478 * the close widget in the title bar.
3479 *
3480 * The close flag is set before this callback is called, but you can modify it
3481 * at any time with @ref glfwSetWindowShouldClose.
3482 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003483 * The close callback is not triggered by @ref glfwDestroyWindow.
3484 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003485 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003486 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003487 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003488 * @return The previously set callback, or `NULL` if no callback was set or the
3489 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02003490 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003491 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3492 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02003493 * @remark @macos Selecting Quit from the application menu will trigger the
3494 * close callback for all windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003495 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003496 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003497 *
3498 * @sa @ref window_close
3499 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003500 * @since Added in version 2.5.
3501 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01003502 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003503 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003504 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02003505GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003506
3507/*! @brief Sets the refresh callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003508 *
3509 * This function sets the refresh callback of the specified window, which is
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003510 * called when the content area of the window needs to be redrawn, for example
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003511 * if the window has been exposed after having been covered by another window.
3512 *
linkmauvebc8b0482016-10-16 15:52:39 +01003513 * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
3514 * the window contents are saved off-screen, this callback may be called only
3515 * very infrequently or never at all.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003516 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003517 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003518 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003519 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003520 * @return The previously set callback, or `NULL` if no callback was set or the
3521 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02003522 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003523 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3524 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003525 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003526 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003527 * @sa @ref window_refresh
3528 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003529 * @since Added in version 2.5.
3530 * @glfw3 Added window handle parameter and return value.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01003531 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003532 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003533 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02003534GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003535
3536/*! @brief Sets the focus callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003537 *
3538 * This function sets the focus callback of the specified window, which is
Camilla Berglund4188c262015-01-18 01:55:25 +01003539 * called when the window gains or loses input focus.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003540 *
Camilla Berglund4188c262015-01-18 01:55:25 +01003541 * After the focus callback is called for a window that lost input focus,
3542 * synthetic key and mouse button release events will be generated for all such
3543 * that had been pressed. For more information, see @ref glfwSetKeyCallback
3544 * and @ref glfwSetMouseButtonCallback.
Camilla Berglund4538a522013-04-24 19:49:46 +02003545 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003546 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003547 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003548 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003549 * @return The previously set callback, or `NULL` if no callback was set or the
3550 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02003551 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003552 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3553 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003554 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003555 *
3556 * @sa @ref window_focus
3557 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003558 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01003559 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003560 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003561 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02003562GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003563
3564/*! @brief Sets the iconify callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003565 *
3566 * This function sets the iconification callback of the specified window, which
3567 * is called when the window is iconified or restored.
3568 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003569 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003570 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003571 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003572 * @return The previously set callback, or `NULL` if no callback was set or the
3573 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02003574 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003575 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3576 *
linkmauvebc8b0482016-10-16 15:52:39 +01003577 * @remark @wayland The wl_shell protocol has no concept of iconification,
Emmanuel Gil Peyrota1620042017-12-03 04:19:15 +01003578 * this callback will never be called when using this deprecated protocol.
linkmauvebc8b0482016-10-16 15:52:39 +01003579 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003580 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003581 *
3582 * @sa @ref window_iconify
3583 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003584 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01003585 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003586 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003587 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02003588GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
Camilla Berglund135194a2010-09-09 18:15:32 +02003589
Camilla Berglundc156b502016-06-16 13:09:28 +02003590/*! @brief Sets the maximize callback for the specified window.
3591 *
3592 * This function sets the maximization callback of the specified window, which
3593 * is called when the window is maximized or restored.
3594 *
3595 * @param[in] window The window whose callback to set.
3596 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
3597 * callback.
3598 * @return The previously set callback, or `NULL` if no callback was set or the
3599 * library had not been [initialized](@ref intro_init).
3600 *
3601 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3602 *
3603 * @thread_safety This function must only be called from the main thread.
3604 *
3605 * @sa @ref window_maximize
3606 *
3607 * @since Added in version 3.3.
3608 *
3609 * @ingroup window
3610 */
3611GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun cbfun);
3612
Camilla Berglund34981632013-06-03 12:51:57 +02003613/*! @brief Sets the framebuffer resize callback for the specified window.
3614 *
3615 * This function sets the framebuffer resize callback of the specified window,
3616 * which is called when the framebuffer of the specified window is resized.
3617 *
3618 * @param[in] window The window whose callback to set.
3619 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
3620 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003621 * @return The previously set callback, or `NULL` if no callback was set or the
3622 * library had not been [initialized](@ref intro_init).
Camilla Berglund34981632013-06-03 12:51:57 +02003623 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003624 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3625 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003626 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003627 *
3628 * @sa @ref window_fbsize
3629 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003630 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01003631 *
Camilla Berglund34981632013-06-03 12:51:57 +02003632 * @ingroup window
3633 */
3634GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
3635
Camilla Löwy370eac32017-12-11 21:26:40 +01003636/*! @brief Sets the window content scale callback for the specified window.
3637 *
3638 * This function sets the window content scale callback of the specified window,
3639 * which is called when the content scale of the specified window changes.
3640 *
3641 * @param[in] window The window whose callback to set.
3642 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
3643 * callback.
3644 * @return The previously set callback, or `NULL` if no callback was set or the
3645 * library had not been [initialized](@ref intro_init).
3646 *
3647 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3648 *
3649 * @thread_safety This function must only be called from the main thread.
3650 *
3651 * @sa @ref window_scale
3652 * @sa @ref glfwGetWindowContentScale
3653 *
3654 * @since Added in version 3.3.
3655 *
3656 * @ingroup window
3657 */
3658GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun cbfun);
3659
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003660/*! @brief Processes all pending events.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003661 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003662 * This function processes only those events that are already in the event
3663 * queue and then returns immediately. Processing events will cause the window
3664 * and input callbacks associated with those events to be called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003665 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003666 * On some platforms, a window move, resize or menu operation will cause event
3667 * processing to block. This is due to how event processing is designed on
3668 * those platforms. You can use the
3669 * [window refresh callback](@ref window_refresh) to redraw the contents of
3670 * your window when necessary during such operations.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003671 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01003672 * Do not assume that callbacks you set will _only_ be called in response to
3673 * event processing functions like this one. While it is necessary to poll for
3674 * events, window systems that require GLFW to register callbacks of its own
3675 * can pass events to GLFW in response to many window system function calls.
3676 * GLFW will pass those events on to the application callbacks before
3677 * returning.
Camilla Berglund401033c2013-03-12 19:17:07 +01003678 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003679 * Event processing is not required for joystick input to work.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003680 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003681 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3682 * GLFW_PLATFORM_ERROR.
3683 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003684 * @reentrancy This function must not be called from a callback.
Camilla Berglundb48128f2013-02-14 18:49:03 +01003685 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003686 * @thread_safety This function must only be called from the main thread.
Camilla Berglund948cc042013-04-16 02:02:22 +02003687 *
Camilla Berglund4188c262015-01-18 01:55:25 +01003688 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003689 * @sa @ref glfwWaitEvents
3690 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003691 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003692 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003693 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003694 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003695 */
Camilla Berglund9a716692010-09-08 16:40:43 +02003696GLFWAPI void glfwPollEvents(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003697
Camilla Berglund4591ad22014-09-18 15:03:29 +02003698/*! @brief Waits until events are queued and processes them.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003699 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003700 * This function puts the calling thread to sleep until at least one event is
3701 * available in the event queue. Once one or more events are available,
3702 * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
3703 * are processed and the function then returns immediately. Processing events
3704 * will cause the window and input callbacks associated with those events to be
3705 * called.
Camilla Berglund948cc042013-04-16 02:02:22 +02003706 *
3707 * Since not all events are associated with callbacks, this function may return
3708 * without a callback having been called even if you are monitoring all
3709 * callbacks.
3710 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003711 * On some platforms, a window move, resize or menu operation will cause event
3712 * processing to block. This is due to how event processing is designed on
3713 * those platforms. You can use the
3714 * [window refresh callback](@ref window_refresh) to redraw the contents of
3715 * your window when necessary during such operations.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003716 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01003717 * Do not assume that callbacks you set will _only_ be called in response to
3718 * event processing functions like this one. While it is necessary to poll for
3719 * events, window systems that require GLFW to register callbacks of its own
3720 * can pass events to GLFW in response to many window system function calls.
3721 * GLFW will pass those events on to the application callbacks before
3722 * returning.
Camilla Berglund4188c262015-01-18 01:55:25 +01003723 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003724 * Event processing is not required for joystick input to work.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003725 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003726 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3727 * GLFW_PLATFORM_ERROR.
3728 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003729 * @reentrancy This function must not be called from a callback.
Camilla Berglund44372b82014-12-17 01:31:36 +01003730 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003731 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003732 *
Camilla Berglund4188c262015-01-18 01:55:25 +01003733 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003734 * @sa @ref glfwPollEvents
3735 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003736 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003737 * @since Added in version 2.5.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003738 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003739 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003740 */
Camilla Berglund9a716692010-09-08 16:40:43 +02003741GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +02003742
Camilla Berglund56208952016-02-02 21:11:16 +01003743/*! @brief Waits with timeout until events are queued and processes them.
3744 *
3745 * This function puts the calling thread to sleep until at least one event is
3746 * available in the event queue, or until the specified timeout is reached. If
3747 * one or more events are available, it behaves exactly like @ref
3748 * glfwPollEvents, i.e. the events in the queue are processed and the function
3749 * then returns immediately. Processing events will cause the window and input
3750 * callbacks associated with those events to be called.
3751 *
3752 * The timeout value must be a positive finite number.
3753 *
3754 * Since not all events are associated with callbacks, this function may return
3755 * without a callback having been called even if you are monitoring all
3756 * callbacks.
3757 *
3758 * On some platforms, a window move, resize or menu operation will cause event
3759 * processing to block. This is due to how event processing is designed on
3760 * those platforms. You can use the
3761 * [window refresh callback](@ref window_refresh) to redraw the contents of
3762 * your window when necessary during such operations.
3763 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01003764 * Do not assume that callbacks you set will _only_ be called in response to
3765 * event processing functions like this one. While it is necessary to poll for
3766 * events, window systems that require GLFW to register callbacks of its own
3767 * can pass events to GLFW in response to many window system function calls.
3768 * GLFW will pass those events on to the application callbacks before
3769 * returning.
Camilla Berglund56208952016-02-02 21:11:16 +01003770 *
Camilla Berglund56208952016-02-02 21:11:16 +01003771 * Event processing is not required for joystick input to work.
3772 *
3773 * @param[in] timeout The maximum amount of time, in seconds, to wait.
3774 *
Sylvain Boilard3b255af2018-09-13 16:23:44 +02003775 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy8e313d92018-12-13 20:33:17 +01003776 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Sylvain Boilard3b255af2018-09-13 16:23:44 +02003777 *
Camilla Berglund56208952016-02-02 21:11:16 +01003778 * @reentrancy This function must not be called from a callback.
3779 *
3780 * @thread_safety This function must only be called from the main thread.
3781 *
3782 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003783 * @sa @ref glfwPollEvents
3784 * @sa @ref glfwWaitEvents
Camilla Berglund56208952016-02-02 21:11:16 +01003785 *
3786 * @since Added in version 3.2.
3787 *
3788 * @ingroup window
3789 */
3790GLFWAPI void glfwWaitEventsTimeout(double timeout);
3791
Camilla Berglund1ccc2322014-02-10 18:16:58 +01003792/*! @brief Posts an empty event to the event queue.
3793 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003794 * This function posts an empty event from the current thread to the event
Camilla Berglund73abf8a2016-07-06 13:06:59 +02003795 * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
Camilla Berglund1ccc2322014-02-10 18:16:58 +01003796 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003797 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3798 * GLFW_PLATFORM_ERROR.
3799 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003800 * @thread_safety This function may be called from any thread.
Camilla Berglund1ccc2322014-02-10 18:16:58 +01003801 *
Camilla Berglund4188c262015-01-18 01:55:25 +01003802 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003803 * @sa @ref glfwWaitEvents
3804 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund1ccc2322014-02-10 18:16:58 +01003805 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003806 * @since Added in version 3.1.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003807 *
Camilla Berglund1ccc2322014-02-10 18:16:58 +01003808 * @ingroup window
3809 */
3810GLFWAPI void glfwPostEmptyEvent(void);
3811
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003812/*! @brief Returns the value of an input option for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003813 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02003814 * This function returns the value of an input option for the specified window.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01003815 * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
Nathan Poirier9e29f552018-12-14 03:08:25 +01003816 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
Camilla Löwy1155c832019-02-11 19:10:20 +01003817 * @ref GLFW_RAW_MOUSE_MOTION.
Camilla Berglund95654cf2014-10-02 17:35:10 +02003818 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003819 * @param[in] window The window to query.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01003820 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
Camilla Löwy1155c832019-02-11 19:10:20 +01003821 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
3822 * `GLFW_RAW_MOUSE_MOTION`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003823 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003824 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3825 * GLFW_INVALID_ENUM.
3826 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003827 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003828 *
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003829 * @sa @ref glfwSetInputMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003830 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003831 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003832 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003833 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003834 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003835GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003836
3837/*! @brief Sets an input option for the specified window.
Camilla Berglund95654cf2014-10-02 17:35:10 +02003838 *
3839 * This function sets an input mode option for the specified window. The mode
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01003840 * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
Nathan Poirier9e29f552018-12-14 03:08:25 +01003841 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
Camilla Löwy1155c832019-02-11 19:10:20 +01003842 * @ref GLFW_RAW_MOUSE_MOTION.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003843 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003844 * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
Camilla Berglund39fe1f12013-03-12 19:39:36 +01003845 * modes:
Camilla Berglund13ccf7d2013-04-07 13:46:38 +02003846 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003847 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
3848 * content area of the window but does not restrict the cursor from leaving.
Camilla Berglunda18b1872013-12-05 03:27:12 +01003849 * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
3850 * and unlimited cursor movement. This is useful for implementing for
3851 * example 3D camera controls.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01003852 *
Camilla Berglund0eccf752015-08-23 19:30:04 +02003853 * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
3854 * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
Camilla Berglund95654cf2014-10-02 17:35:10 +02003855 * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
3856 * the next time it is called even if the key had been released before the
3857 * call. This is useful when you are only interested in whether keys have been
3858 * pressed but not when or in which order.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01003859 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003860 * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
Camilla Berglund0eccf752015-08-23 19:30:04 +02003861 * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
3862 * If sticky mouse buttons are enabled, a mouse button press will ensure that
3863 * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
3864 * if the mouse button had been released before the call. This is useful when
3865 * you are only interested in whether mouse buttons have been pressed but not
3866 * when or in which order.
Camilla Berglund95654cf2014-10-02 17:35:10 +02003867 *
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01003868 * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
3869 * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
3870 * callbacks that receive modifier bits will also have the @ref
3871 * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
3872 * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
3873 *
Camilla Löwy1155c832019-02-11 19:10:20 +01003874 * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
3875 * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
3876 * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
3877 * attempting to set this will emit @ref GLFW_PLATFORM_ERROR. Call @ref
3878 * glfwRawMouseMotionSupported to check for support.
Nathan Poirier9e29f552018-12-14 03:08:25 +01003879 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02003880 * @param[in] window The window whose input mode to set.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01003881 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
Camilla Löwy1155c832019-02-11 19:10:20 +01003882 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
3883 * `GLFW_RAW_MOUSE_MOTION`.
Camilla Berglund95654cf2014-10-02 17:35:10 +02003884 * @param[in] value The new value of the specified input mode.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01003885 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003886 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3887 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
3888 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003889 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003890 *
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003891 * @sa @ref glfwGetInputMode
Camilla Berglunde248fb62013-03-29 14:06:23 +01003892 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003893 * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003894 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01003895 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003896 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003897GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003898
Camilla Löwy1155c832019-02-11 19:10:20 +01003899/*! @brief Returns whether raw mouse motion is supported.
Nathan Poirier9e29f552018-12-14 03:08:25 +01003900 *
Camilla Löwy1155c832019-02-11 19:10:20 +01003901 * This function returns whether raw mouse motion is supported on the current
3902 * system. This status does not change after GLFW has been initialized so you
3903 * only need to check this once. If you attempt to enable raw motion on
3904 * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
Nathan Poirier9e29f552018-12-14 03:08:25 +01003905 *
Camilla Löwy1155c832019-02-11 19:10:20 +01003906 * Raw mouse motion is closer to the actual motion of the mouse across
3907 * a surface. It is not affected by the scaling and acceleration applied to
3908 * the motion of the desktop cursor. That processing is suitable for a cursor
3909 * while raw motion is better for controlling for example a 3D camera. Because
3910 * of this, raw mouse motion is only provided when the cursor is disabled.
Nathan Poirier9e29f552018-12-14 03:08:25 +01003911 *
Camilla Löwy1155c832019-02-11 19:10:20 +01003912 * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
3913 * or `GLFW_FALSE` otherwise.
Nathan Poirier9e29f552018-12-14 03:08:25 +01003914 *
3915 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3916 *
Camilla Löwy1155c832019-02-11 19:10:20 +01003917 * @thread_safety This function must only be called from the main thread.
Nathan Poirier9e29f552018-12-14 03:08:25 +01003918 *
Camilla Löwy1155c832019-02-11 19:10:20 +01003919 * @sa @ref raw_mouse_motion
Nathan Poirier9e29f552018-12-14 03:08:25 +01003920 * @sa @ref glfwSetInputMode
3921 *
3922 * @since Added in version 3.3.
3923 *
3924 * @ingroup input
3925 */
Camilla Löwy1155c832019-02-11 19:10:20 +01003926GLFWAPI int glfwRawMouseMotionSupported(void);
Nathan Poirier9e29f552018-12-14 03:08:25 +01003927
Camilla Löwy9558b852017-04-04 18:05:36 +02003928/*! @brief Returns the layout-specific name of the specified printable key.
Camilla Berglund9c315412015-07-02 14:24:50 +02003929 *
Camilla Löwy9558b852017-04-04 18:05:36 +02003930 * This function returns the name of the specified printable key, encoded as
3931 * UTF-8. This is typically the character that key would produce without any
3932 * modifier keys, intended for displaying key bindings to the user. For dead
3933 * keys, it is typically the diacritic it would add to a character.
Camilla Berglund9c315412015-07-02 14:24:50 +02003934 *
Camilla Löwy071a0492017-02-28 22:29:10 +01003935 * __Do not use this function__ for [text input](@ref input_char). You will
3936 * break text input for many languages even if it happens to work for yours.
Camilla Berglund70ffae72016-02-22 11:54:56 +01003937 *
Camilla Löwy071a0492017-02-28 22:29:10 +01003938 * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
3939 * otherwise the scancode is ignored. If you specify a non-printable key, or
3940 * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
3941 * function returns `NULL` but does not emit an error.
3942 *
3943 * This behavior allows you to always pass in the arguments in the
Camilla Berglund70ffae72016-02-22 11:54:56 +01003944 * [key callback](@ref input_key) without modification.
3945 *
3946 * The printable keys are:
3947 * - `GLFW_KEY_APOSTROPHE`
3948 * - `GLFW_KEY_COMMA`
3949 * - `GLFW_KEY_MINUS`
3950 * - `GLFW_KEY_PERIOD`
3951 * - `GLFW_KEY_SLASH`
3952 * - `GLFW_KEY_SEMICOLON`
3953 * - `GLFW_KEY_EQUAL`
3954 * - `GLFW_KEY_LEFT_BRACKET`
3955 * - `GLFW_KEY_RIGHT_BRACKET`
3956 * - `GLFW_KEY_BACKSLASH`
3957 * - `GLFW_KEY_WORLD_1`
3958 * - `GLFW_KEY_WORLD_2`
3959 * - `GLFW_KEY_0` to `GLFW_KEY_9`
3960 * - `GLFW_KEY_A` to `GLFW_KEY_Z`
3961 * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
3962 * - `GLFW_KEY_KP_DECIMAL`
3963 * - `GLFW_KEY_KP_DIVIDE`
3964 * - `GLFW_KEY_KP_MULTIPLY`
3965 * - `GLFW_KEY_KP_SUBTRACT`
3966 * - `GLFW_KEY_KP_ADD`
3967 * - `GLFW_KEY_KP_EQUAL`
Camilla Berglund9c315412015-07-02 14:24:50 +02003968 *
Camilla Löwy071a0492017-02-28 22:29:10 +01003969 * Names for printable keys depend on keyboard layout, while names for
3970 * non-printable keys are the same across layouts but depend on the application
3971 * language and should be localized along with other user interface text.
3972 *
Camilla Berglund9c315412015-07-02 14:24:50 +02003973 * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
3974 * @param[in] scancode The scancode of the key to query.
Camilla Löwy9558b852017-04-04 18:05:36 +02003975 * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
Camilla Berglund9c315412015-07-02 14:24:50 +02003976 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003977 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3978 * GLFW_PLATFORM_ERROR.
3979 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003980 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
3981 * should not free it yourself. It is valid until the next call to @ref
3982 * glfwGetKeyName, or until the library is terminated.
Camilla Berglund9c315412015-07-02 14:24:50 +02003983 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003984 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9c315412015-07-02 14:24:50 +02003985 *
3986 * @sa @ref input_key_name
3987 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003988 * @since Added in version 3.2.
Camilla Berglund9c315412015-07-02 14:24:50 +02003989 *
3990 * @ingroup input
3991 */
3992GLFWAPI const char* glfwGetKeyName(int key, int scancode);
3993
Camilla Löwy766a9dc2016-12-06 23:26:53 +01003994/*! @brief Returns the platform-specific scancode of the specified key.
Michael Stockere745b0d2016-08-11 19:11:40 +02003995 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01003996 * This function returns the platform-specific scancode of the specified key.
Michael Stockere745b0d2016-08-11 19:11:40 +02003997 *
3998 * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
3999 * method will return `-1`.
4000 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004001 * @param[in] key Any [named key](@ref keys).
4002 * @return The platform-specific scancode for the key, or `-1` if an
Camilla Berglundbb3cb8f2016-09-06 15:40:31 +02004003 * [error](@ref error_handling) occurred.
Michael Stockere745b0d2016-08-11 19:11:40 +02004004 *
Camilla Berglundbb3cb8f2016-09-06 15:40:31 +02004005 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4006 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
Michael Stockere745b0d2016-08-11 19:11:40 +02004007 *
4008 * @thread_safety This function may be called from any thread.
4009 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004010 * @sa @ref input_key
Michael Stockere745b0d2016-08-11 19:11:40 +02004011 *
4012 * @since Added in version 3.3.
4013 *
4014 * @ingroup input
4015 */
Camilla Berglundbb3cb8f2016-09-06 15:40:31 +02004016GLFWAPI int glfwGetKeyScancode(int key);
Michael Stockere745b0d2016-08-11 19:11:40 +02004017
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004018/*! @brief Returns the last reported state of a keyboard key for the specified
4019 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004020 *
4021 * This function returns the last state reported for the specified key to the
4022 * specified window. The returned state is one of `GLFW_PRESS` or
Camilla Berglund4591ad22014-09-18 15:03:29 +02004023 * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004024 * the key callback.
4025 *
Camilla Löwy46393072017-02-20 13:45:11 +01004026 * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
Camilla Berglund4591ad22014-09-18 15:03:29 +02004027 * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
4028 * that key has already been released.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004029 *
4030 * The key functions deal with physical keys, with [key tokens](@ref keys)
4031 * named after their use on the standard US keyboard layout. If you want to
4032 * input text, use the Unicode character callback instead.
4033 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004034 * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
4035 * used with this function.
4036 *
Camilla Berglund9c315412015-07-02 14:24:50 +02004037 * __Do not use this function__ to implement [text input](@ref input_char).
4038 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004039 * @param[in] window The desired window.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004040 * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
4041 * not a valid key for this function.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004042 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004043 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004044 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4045 * GLFW_INVALID_ENUM.
4046 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004047 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004048 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004049 * @sa @ref input_key
4050 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004051 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01004052 * @glfw3 Added window handle parameter.
Camilla Berglund11615fc2013-05-30 17:19:12 +02004053 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004054 * @ingroup input
4055 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004056GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004057
4058/*! @brief Returns the last reported state of a mouse button for the specified
4059 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004060 *
4061 * This function returns the last state reported for the specified mouse button
Camilla Berglund4591ad22014-09-18 15:03:29 +02004062 * to the specified window. The returned state is one of `GLFW_PRESS` or
Camilla Berglundce8f97c2015-01-11 23:33:14 +01004063 * `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004064 *
Camilla Löwy46393072017-02-20 13:45:11 +01004065 * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
Coşku Başf4764f72018-08-06 18:13:24 +03004066 * returns `GLFW_PRESS` the first time you call it for a mouse button that was
4067 * pressed, even if that mouse button has already been released.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004068 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004069 * @param[in] window The desired window.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004070 * @param[in] button The desired [mouse button](@ref buttons).
4071 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004072 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004073 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4074 * GLFW_INVALID_ENUM.
4075 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004076 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004077 *
4078 * @sa @ref input_mouse_button
4079 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004080 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01004081 * @glfw3 Added window handle parameter.
Camilla Berglund0e205772014-03-24 11:58:35 +01004082 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004083 * @ingroup input
4084 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004085GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004086
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004087/*! @brief Retrieves the position of the cursor relative to the content area of
Camilla Berglundd4591452014-02-11 18:24:01 +01004088 * the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004089 *
Camilla Berglundd4591452014-02-11 18:24:01 +01004090 * This function returns the position of the cursor, in screen coordinates,
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004091 * relative to the upper-left corner of the content area of the specified
Camilla Berglundd4591452014-02-11 18:24:01 +01004092 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004093 *
Camilla Berglund6df692b2013-04-26 17:20:31 +02004094 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
4095 * position is unbounded and limited only by the minimum and maximum values of
4096 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02004097 *
Camilla Berglund3ec29252013-04-25 18:03:15 +02004098 * The coordinate can be converted to their integer equivalents with the
4099 * `floor` function. Casting directly to an integer type works for positive
4100 * coordinates, but fails for negative ones.
4101 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004102 * Any or all of the position arguments may be `NULL`. If an error occurs, all
4103 * non-`NULL` position arguments will be set to zero.
4104 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004105 * @param[in] window The desired window.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004106 * @param[out] xpos Where to store the cursor x-coordinate, relative to the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004107 * left edge of the content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004108 * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004109 * top edge of the content area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004110 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004111 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4112 * GLFW_PLATFORM_ERROR.
4113 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004114 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004115 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004116 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004117 * @sa @ref glfwSetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004118 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004119 * @since Added in version 3.0. Replaces `glfwGetMousePos`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004120 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004121 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004122 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02004123GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004124
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004125/*! @brief Sets the position of the cursor, relative to the content area of the
Camilla Berglund6d9d8562013-09-28 22:12:50 +02004126 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004127 *
Camilla Berglund6d9d8562013-09-28 22:12:50 +02004128 * This function sets the position, in screen coordinates, of the cursor
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004129 * relative to the upper-left corner of the content area of the specified
Camilla Berglund4188c262015-01-18 01:55:25 +01004130 * window. The window must have input focus. If the window does not have
4131 * input focus when this function is called, it fails silently.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004132 *
Camilla Berglund20858762015-01-01 18:41:22 +01004133 * __Do not use this function__ to implement things like camera controls. GLFW
4134 * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
4135 * cursor, transparently re-centers it and provides unconstrained cursor
4136 * motion. See @ref glfwSetInputMode for more information.
4137 *
4138 * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
4139 * unconstrained and limited only by the minimum and maximum values of
Camilla Berglund6df692b2013-04-26 17:20:31 +02004140 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02004141 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004142 * @param[in] window The desired window.
4143 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004144 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004145 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004146 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004147 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004148 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4149 * GLFW_PLATFORM_ERROR.
4150 *
linkmauvebc8b0482016-10-16 15:52:39 +01004151 * @remark @wayland This function will only work when the cursor mode is
4152 * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
4153 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004154 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004155 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004156 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004157 * @sa @ref glfwGetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004158 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004159 * @since Added in version 3.0. Replaces `glfwSetMousePos`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004160 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004161 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004162 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02004163GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004164
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004165/*! @brief Creates a custom cursor.
urraka40c04a72013-12-04 10:19:22 -03004166 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004167 * Creates a new custom cursor image that can be set for a window with @ref
4168 * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
4169 * Any remaining cursors are destroyed by @ref glfwTerminate.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004170 *
Camilla Berglund85a01bf2015-08-17 21:04:19 +02004171 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02004172 * bits per channel with the red channel first. They are arranged canonically
4173 * as packed sequential rows, starting from the top-left corner.
Camilla Berglund4188c262015-01-18 01:55:25 +01004174 *
4175 * The cursor hotspot is specified in pixels, relative to the upper-left corner
4176 * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
4177 * points to the right and the Y-axis points down.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004178 *
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01004179 * @param[in] image The desired cursor image.
Camilla Berglund4188c262015-01-18 01:55:25 +01004180 * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
4181 * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
Camilla Berglund4188c262015-01-18 01:55:25 +01004182 * @return The handle of the created cursor, or `NULL` if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02004183 * [error](@ref error_handling) occurred.
urraka40c04a72013-12-04 10:19:22 -03004184 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004185 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4186 * GLFW_PLATFORM_ERROR.
4187 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004188 * @pointer_lifetime The specified image data is copied before this function
4189 * returns.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004190 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004191 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004192 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004193 * @sa @ref cursor_object
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004194 * @sa @ref glfwDestroyCursor
4195 * @sa @ref glfwCreateStandardCursor
Camilla Berglund4591ad22014-09-18 15:03:29 +02004196 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004197 * @since Added in version 3.1.
urraka40c04a72013-12-04 10:19:22 -03004198 *
4199 * @ingroup input
4200 */
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01004201GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
urraka40c04a72013-12-04 10:19:22 -03004202
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004203/*! @brief Creates a cursor with a standard shape.
4204 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004205 * Returns a cursor with a [standard shape](@ref shapes), that can be set for
4206 * a window with @ref glfwSetCursor.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004207 *
4208 * @param[in] shape One of the [standard shapes](@ref shapes).
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004209 * @return A new cursor ready to use or `NULL` if an
4210 * [error](@ref error_handling) occurred.
4211 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004212 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4213 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4214 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004215 * @thread_safety This function must only be called from the main thread.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004216 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004217 * @sa @ref cursor_object
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004218 * @sa @ref glfwCreateCursor
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004219 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004220 * @since Added in version 3.1.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004221 *
4222 * @ingroup input
4223 */
4224GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
4225
urraka40c04a72013-12-04 10:19:22 -03004226/*! @brief Destroys a cursor.
4227 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004228 * This function destroys a cursor previously created with @ref
4229 * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
4230 * glfwTerminate.
urraka40c04a72013-12-04 10:19:22 -03004231 *
Camilla Löwy46393072017-02-20 13:45:11 +01004232 * If the specified cursor is current for any window, that window will be
4233 * reverted to the default cursor. This does not affect the cursor mode.
4234 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004235 * @param[in] cursor The cursor object to destroy.
urraka40c04a72013-12-04 10:19:22 -03004236 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004237 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4238 * GLFW_PLATFORM_ERROR.
4239 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004240 * @reentrancy This function must not be called from a callback.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004241 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004242 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004243 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004244 * @sa @ref cursor_object
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004245 * @sa @ref glfwCreateCursor
Camilla Berglund4591ad22014-09-18 15:03:29 +02004246 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004247 * @since Added in version 3.1.
urraka40c04a72013-12-04 10:19:22 -03004248 *
4249 * @ingroup input
4250 */
4251GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
4252
Camilla Berglund4188c262015-01-18 01:55:25 +01004253/*! @brief Sets the cursor for the window.
urraka40c04a72013-12-04 10:19:22 -03004254 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004255 * This function sets the cursor image to be used when the cursor is over the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004256 * content area of the specified window. The set cursor will only be visible
Camilla Berglund4188c262015-01-18 01:55:25 +01004257 * when the [cursor mode](@ref cursor_mode) of the window is
4258 * `GLFW_CURSOR_NORMAL`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004259 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004260 * On some platforms, the set cursor may not be visible unless the window also
4261 * has input focus.
4262 *
4263 * @param[in] window The window to set the cursor for.
4264 * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
4265 * arrow cursor.
urraka40c04a72013-12-04 10:19:22 -03004266 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004267 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4268 * GLFW_PLATFORM_ERROR.
4269 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004270 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004271 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004272 * @sa @ref cursor_object
Camilla Berglund4591ad22014-09-18 15:03:29 +02004273 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004274 * @since Added in version 3.1.
Camilla Berglund0e205772014-03-24 11:58:35 +01004275 *
urraka40c04a72013-12-04 10:19:22 -03004276 * @ingroup input
4277 */
4278GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
4279
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004280/*! @brief Sets the key callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004281 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004282 * This function sets the key callback of the specified window, which is called
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004283 * when a key is pressed, repeated or released.
4284 *
Camilla Berglund948cc042013-04-16 02:02:22 +02004285 * The key functions deal with physical keys, with layout independent
4286 * [key tokens](@ref keys) named after their values in the standard US keyboard
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004287 * layout. If you want to input text, use the
4288 * [character callback](@ref glfwSetCharCallback) instead.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004289 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004290 * When a window loses input focus, it will generate synthetic key release
4291 * events for all pressed keys. You can tell these events from user-generated
4292 * events by the fact that the synthetic ones are generated after the focus
4293 * loss event has been processed, i.e. after the
4294 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
Camilla Berglund4538a522013-04-24 19:49:46 +02004295 *
Camilla Berglund11615fc2013-05-30 17:19:12 +02004296 * The scancode of a key is specific to that platform or sometimes even to that
4297 * machine. Scancodes are intended to allow users to bind keys that don't have
4298 * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
Camilla Berglund4591ad22014-09-18 15:03:29 +02004299 * state is not saved and so it cannot be queried with @ref glfwGetKey.
Camilla Berglund11615fc2013-05-30 17:19:12 +02004300 *
4301 * Sometimes GLFW needs to generate synthetic key events, in which case the
4302 * scancode may be zero.
4303 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01004304 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004305 * @param[in] cbfun The new key callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004306 * set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004307 * @return The previously set callback, or `NULL` if no callback was set or the
4308 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004309 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004310 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4311 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004312 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004313 *
4314 * @sa @ref input_key
4315 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004316 * @since Added in version 1.0.
4317 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01004318 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004319 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004320 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02004321GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004322
4323/*! @brief Sets the Unicode character callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004324 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004325 * This function sets the character callback of the specified window, which is
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004326 * called when a Unicode character is input.
4327 *
Camilla Berglund96b12ee2014-06-12 23:04:20 +02004328 * The character callback is intended for Unicode text input. As it deals with
4329 * characters, it is keyboard layout dependent, whereas the
4330 * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
4331 * to physical keys, as a key may produce zero, one or more characters. If you
4332 * want to know whether a specific physical key was pressed or released, see
4333 * the key callback instead.
4334 *
4335 * The character callback behaves as system text input normally does and will
4336 * not be called if modifier keys are held down that would prevent normal text
Camilla Berglund8d6f2652016-10-20 00:50:54 +02004337 * input on that platform, for example a Super (Command) key on macOS or Alt key
Camilla Löwy86e7bf42018-12-25 22:11:23 +01004338 * on Windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004339 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01004340 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004341 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01004342 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004343 * @return The previously set callback, or `NULL` if no callback was set or the
4344 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004345 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004346 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4347 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004348 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004349 *
4350 * @sa @ref input_char
4351 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004352 * @since Added in version 2.4.
4353 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01004354 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004355 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004356 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02004357GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004358
Camilla Berglund96b12ee2014-06-12 23:04:20 +02004359/*! @brief Sets the Unicode character with modifiers callback.
4360 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004361 * This function sets the character with modifiers callback of the specified
Camilla Berglund96b12ee2014-06-12 23:04:20 +02004362 * window, which is called when a Unicode character is input regardless of what
4363 * modifier keys are used.
4364 *
4365 * The character with modifiers callback is intended for implementing custom
4366 * Unicode character input. For regular Unicode text input, see the
4367 * [character callback](@ref glfwSetCharCallback). Like the character
4368 * callback, the character with modifiers callback deals with characters and is
4369 * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
4370 * a key may produce zero, one or more characters. If you want to know whether
4371 * a specific physical key was pressed or released, see the
4372 * [key callback](@ref glfwSetKeyCallback) instead.
4373 *
4374 * @param[in] window The window whose callback to set.
4375 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
4376 * callback.
4377 * @return The previously set callback, or `NULL` if no callback was set or an
Camilla Berglund999f3552016-08-17 16:48:22 +02004378 * [error](@ref error_handling) occurred.
Camilla Berglund96b12ee2014-06-12 23:04:20 +02004379 *
Camilla Löwyadebcc72017-11-14 23:28:12 +01004380 * @deprecated Scheduled for removal in version 4.0.
4381 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004382 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4383 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004384 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004385 *
4386 * @sa @ref input_char
4387 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004388 * @since Added in version 3.1.
Camilla Berglund96b12ee2014-06-12 23:04:20 +02004389 *
4390 * @ingroup input
4391 */
4392GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);
4393
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004394/*! @brief Sets the mouse button callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004395 *
4396 * This function sets the mouse button callback of the specified window, which
4397 * is called when a mouse button is pressed or released.
4398 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004399 * When a window loses input focus, it will generate synthetic mouse button
4400 * release events for all pressed mouse buttons. You can tell these events
4401 * from user-generated events by the fact that the synthetic ones are generated
4402 * after the focus loss event has been processed, i.e. after the
4403 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
Camilla Berglund4538a522013-04-24 19:49:46 +02004404 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01004405 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004406 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01004407 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004408 * @return The previously set callback, or `NULL` if no callback was set or the
4409 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004410 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004411 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4412 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004413 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004414 *
4415 * @sa @ref input_mouse_button
4416 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004417 * @since Added in version 1.0.
4418 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01004419 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004420 * @ingroup input
4421 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02004422GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004423
4424/*! @brief Sets the cursor position callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004425 *
4426 * This function sets the cursor position callback of the specified window,
4427 * which is called when the cursor is moved. The callback is provided with the
Camilla Berglund6d9d8562013-09-28 22:12:50 +02004428 * position, in screen coordinates, relative to the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004429 * content area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004430 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01004431 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004432 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01004433 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004434 * @return The previously set callback, or `NULL` if no callback was set or the
4435 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004436 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004437 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4438 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004439 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004440 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004441 * @sa @ref cursor_pos
Camilla Berglund4591ad22014-09-18 15:03:29 +02004442 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004443 * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
Camilla Berglund0e205772014-03-24 11:58:35 +01004444 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004445 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004446 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02004447GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004448
4449/*! @brief Sets the cursor enter/exit callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004450 *
4451 * This function sets the cursor boundary crossing callback of the specified
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004452 * window, which is called when the cursor enters or leaves the content area of
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004453 * the window.
4454 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01004455 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004456 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01004457 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004458 * @return The previously set callback, or `NULL` if no callback was set or the
4459 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004460 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004461 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4462 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004463 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004464 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004465 * @sa @ref cursor_enter
Camilla Berglund4591ad22014-09-18 15:03:29 +02004466 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004467 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004468 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004469 * @ingroup input
4470 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02004471GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004472
4473/*! @brief Sets the scroll callback.
Camilla Berglunde248fb62013-03-29 14:06:23 +01004474 *
4475 * This function sets the scroll callback of the specified window, which is
4476 * called when a scrolling device is used, such as a mouse wheel or scrolling
4477 * area of a touchpad.
4478 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004479 * The scroll callback receives all scrolling input, like that from a mouse
4480 * wheel or a touchpad scrolling area.
4481 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01004482 * @param[in] window The window whose callback to set.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004483 * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004484 * set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004485 * @return The previously set callback, or `NULL` if no callback was set or the
4486 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004487 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004488 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4489 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004490 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004491 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004492 * @sa @ref scrolling
Camilla Berglund4591ad22014-09-18 15:03:29 +02004493 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004494 * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
Camilla Berglund0e205772014-03-24 11:58:35 +01004495 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01004496 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004497 */
Camilla Berglund11a27de2013-04-08 21:21:21 +02004498GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
Camilla Berglund3249f812010-09-07 17:34:51 +02004499
Camilla Berglund5c8121e2014-03-29 21:35:21 +01004500/*! @brief Sets the file drop callback.
arturo89d07232013-07-10 11:42:14 +02004501 *
Camilla Berglund5c8121e2014-03-29 21:35:21 +01004502 * This function sets the file drop callback of the specified window, which is
4503 * called when one or more dragged files are dropped on the window.
arturo89d07232013-07-10 11:42:14 +02004504 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004505 * Because the path array and its strings may have been generated specifically
4506 * for that event, they are not guaranteed to be valid after the callback has
4507 * returned. If you wish to use them after the callback returns, you need to
4508 * make a deep copy.
arturo89d07232013-07-10 11:42:14 +02004509 *
4510 * @param[in] window The window whose callback to set.
Camilla Berglund5c8121e2014-03-29 21:35:21 +01004511 * @param[in] cbfun The new file drop callback, or `NULL` to remove the
4512 * currently set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004513 * @return The previously set callback, or `NULL` if no callback was set or the
4514 * library had not been [initialized](@ref intro_init).
arturo89d07232013-07-10 11:42:14 +02004515 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004516 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4517 *
linkmauvebc8b0482016-10-16 15:52:39 +01004518 * @remark @wayland File drop is currently unimplemented.
4519 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004520 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004521 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004522 * @sa @ref path_drop
Camilla Berglund4591ad22014-09-18 15:03:29 +02004523 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004524 * @since Added in version 3.1.
Camilla Berglund0e205772014-03-24 11:58:35 +01004525 *
arturo89d07232013-07-10 11:42:14 +02004526 * @ingroup input
4527 */
4528GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);
4529
Camilla Berglundfdd45182013-05-27 15:13:09 +02004530/*! @brief Returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004531 *
Camilla Berglundfdd45182013-05-27 15:13:09 +02004532 * This function returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004533 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004534 * There is no need to call this function before other functions that accept
4535 * a joystick ID, as they all check for presence before performing any other
4536 * work.
4537 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02004538 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund0eccf752015-08-23 19:30:04 +02004539 * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004540 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004541 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4542 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4543 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004544 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004545 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004546 * @sa @ref joystick
Camilla Berglund4591ad22014-09-18 15:03:29 +02004547 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004548 * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
Camilla Berglund0e205772014-03-24 11:58:35 +01004549 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004550 * @ingroup input
4551 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02004552GLFWAPI int glfwJoystickPresent(int jid);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004553
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02004554/*! @brief Returns the values of all axes of the specified joystick.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004555 *
4556 * This function returns the values of all axes of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004557 * Each element in the array is a value between -1.0 and 1.0.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004558 *
Camilla Löwy953106e2017-06-18 15:13:25 +02004559 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004560 * but will not generate an error. This can be used instead of first calling
4561 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01004562 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02004563 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004564 * @param[out] count Where to store the number of axis values in the returned
Camilla Berglund999f3552016-08-17 16:48:22 +02004565 * array. This is set to zero if the joystick is not present or an error
4566 * occurred.
4567 * @return An array of axis values, or `NULL` if the joystick is not present or
4568 * an [error](@ref error_handling) occurred.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02004569 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004570 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4571 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4572 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004573 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
4574 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01004575 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01004576 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004577 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02004578 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004579 * @sa @ref joystick_axis
Camilla Berglund4591ad22014-09-18 15:03:29 +02004580 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004581 * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004582 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004583 * @ingroup input
4584 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02004585GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004586
Camilla Berglunde93bade2013-06-16 02:33:33 +02004587/*! @brief Returns the state of all buttons of the specified joystick.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004588 *
Camilla Berglunde93bade2013-06-16 02:33:33 +02004589 * This function returns the state of all buttons of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004590 * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004591 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01004592 * For backward compatibility with earlier versions that did not have @ref
4593 * glfwGetJoystickHats, the button array also includes all hats, each
4594 * represented as four buttons. The hats are in the same order as returned by
4595 * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
4596 * _left_. To disable these extra buttons, set the @ref
4597 * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
4598 *
Camilla Löwy953106e2017-06-18 15:13:25 +02004599 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004600 * but will not generate an error. This can be used instead of first calling
4601 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01004602 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02004603 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004604 * @param[out] count Where to store the number of button states in the returned
Camilla Berglund999f3552016-08-17 16:48:22 +02004605 * array. This is set to zero if the joystick is not present or an error
4606 * occurred.
4607 * @return An array of button states, or `NULL` if the joystick is not present
4608 * or an [error](@ref error_handling) occurred.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02004609 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004610 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4611 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4612 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004613 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
4614 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01004615 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01004616 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004617 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02004618 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004619 * @sa @ref joystick_button
Camilla Berglund4591ad22014-09-18 15:03:29 +02004620 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004621 * @since Added in version 2.2.
Camilla Berglund951a9582016-01-31 21:32:14 +01004622 * @glfw3 Changed to return a dynamic array.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004623 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004624 * @ingroup input
4625 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02004626GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
Camilla Berglund3249f812010-09-07 17:34:51 +02004627
IntellectualKitty368dec72016-11-25 20:56:24 -07004628/*! @brief Returns the state of all hats of the specified joystick.
4629 *
4630 * This function returns the state of all hats of the specified joystick.
Camilla Löwy798d7c62017-03-01 23:27:20 +01004631 * Each element in the array is one of the following values:
IntellectualKitty368dec72016-11-25 20:56:24 -07004632 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01004633 * Name | Value
Camilla Löwybb2ca1d2018-11-27 21:49:19 +01004634 * ---- | -----
Camilla Löwy798d7c62017-03-01 23:27:20 +01004635 * `GLFW_HAT_CENTERED` | 0
4636 * `GLFW_HAT_UP` | 1
4637 * `GLFW_HAT_RIGHT` | 2
4638 * `GLFW_HAT_DOWN` | 4
4639 * `GLFW_HAT_LEFT` | 8
4640 * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
4641 * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
4642 * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
4643 * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
IntellectualKitty368dec72016-11-25 20:56:24 -07004644 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01004645 * The diagonal directions are bitwise combinations of the primary (up, right,
4646 * down and left) directions and you can test for these individually by ANDing
4647 * it with the corresponding direction.
IntellectualKitty368dec72016-11-25 20:56:24 -07004648 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01004649 * @code
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00004650 * if (hats[2] & GLFW_HAT_RIGHT)
4651 * {
4652 * // State of hat 2 could be right-up, right or right-down
4653 * }
Camilla Löwy798d7c62017-03-01 23:27:20 +01004654 * @endcode
IntellectualKitty368dec72016-11-25 20:56:24 -07004655 *
Camilla Löwy953106e2017-06-18 15:13:25 +02004656 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004657 * but will not generate an error. This can be used instead of first calling
4658 * @ref glfwJoystickPresent.
IntellectualKitty368dec72016-11-25 20:56:24 -07004659 *
4660 * @param[in] jid The [joystick](@ref joysticks) to query.
4661 * @param[out] count Where to store the number of hat states in the returned
4662 * array. This is set to zero if the joystick is not present or an error
4663 * occurred.
4664 * @return An array of hat states, or `NULL` if the joystick is not present
4665 * or an [error](@ref error_handling) occurred.
4666 *
4667 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4668 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4669 *
IntellectualKitty368dec72016-11-25 20:56:24 -07004670 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
4671 * should not free it yourself. It is valid until the specified joystick is
4672 * disconnected, this function is called again for that joystick or the library
4673 * is terminated.
4674 *
4675 * @thread_safety This function must only be called from the main thread.
4676 *
4677 * @sa @ref joystick_hat
4678 *
4679 * @since Added in version 3.3.
4680 *
4681 * @ingroup input
4682 */
4683GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
4684
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01004685/*! @brief Returns the name of the specified joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004686 *
4687 * This function returns the name, encoded as UTF-8, of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004688 * The returned string is allocated and freed by GLFW. You should not free it
4689 * yourself.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004690 *
Camilla Löwy953106e2017-06-18 15:13:25 +02004691 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004692 * but will not generate an error. This can be used instead of first calling
4693 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01004694 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02004695 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004696 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
Camilla Berglund999f3552016-08-17 16:48:22 +02004697 * is not present or an [error](@ref error_handling) occurred.
Camilla Berglundd4a08b12012-12-02 17:13:41 +01004698 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004699 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4700 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4701 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004702 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
4703 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01004704 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01004705 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004706 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02004707 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004708 * @sa @ref joystick_name
Camilla Berglund4591ad22014-09-18 15:03:29 +02004709 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004710 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004711 *
4712 * @ingroup input
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01004713 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02004714GLFWAPI const char* glfwGetJoystickName(int jid);
Camilla Berglund3249f812010-09-07 17:34:51 +02004715
Camilla Löwy5b7281b2017-07-23 16:34:11 +02004716/*! @brief Returns the SDL comaptible GUID of the specified joystick.
4717 *
4718 * This function returns the SDL compatible GUID, as a UTF-8 encoded
4719 * hexadecimal string, of the specified joystick. The returned string is
4720 * allocated and freed by GLFW. You should not free it yourself.
4721 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004722 * The GUID is what connects a joystick to a gamepad mapping. A connected
4723 * joystick will always have a GUID even if there is no gamepad mapping
4724 * assigned to it.
4725 *
Camilla Löwy5b7281b2017-07-23 16:34:11 +02004726 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004727 * but will not generate an error. This can be used instead of first calling
4728 * @ref glfwJoystickPresent.
Camilla Löwy5b7281b2017-07-23 16:34:11 +02004729 *
4730 * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
4731 * uniquely identify the make and model of a joystick but does not identify
4732 * a specific unit, e.g. all wired Xbox 360 controllers will have the same
4733 * GUID on that platform. The GUID for a unit may vary between platforms
4734 * depending on what hardware information the platform specific APIs provide.
4735 *
4736 * @param[in] jid The [joystick](@ref joysticks) to query.
4737 * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
4738 * is not present or an [error](@ref error_handling) occurred.
4739 *
4740 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4741 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4742 *
4743 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
4744 * should not free it yourself. It is valid until the specified joystick is
4745 * disconnected or the library is terminated.
4746 *
4747 * @thread_safety This function must only be called from the main thread.
4748 *
4749 * @sa @ref gamepad
4750 *
4751 * @since Added in version 3.3.
4752 *
4753 * @ingroup input
4754 */
4755GLFWAPI const char* glfwGetJoystickGUID(int jid);
4756
Camilla Löwy7c2c7852017-12-07 16:19:57 +01004757/*! @brief Sets the user pointer of the specified joystick.
4758 *
4759 * This function sets the user-defined pointer of the specified joystick. The
4760 * current value is retained until the joystick is disconnected. The initial
4761 * value is `NULL`.
4762 *
4763 * This function may be called from the joystick callback, even for a joystick
4764 * that is being disconnected.
4765 *
Camilla Löwyd222a402018-02-25 20:37:31 +01004766 * @param[in] jid The joystick whose pointer to set.
Camilla Löwy7c2c7852017-12-07 16:19:57 +01004767 * @param[in] pointer The new value.
4768 *
4769 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4770 *
4771 * @thread_safety This function may be called from any thread. Access is not
4772 * synchronized.
4773 *
4774 * @sa @ref joystick_userptr
4775 * @sa @ref glfwGetJoystickUserPointer
4776 *
4777 * @since Added in version 3.3.
4778 *
4779 * @ingroup input
4780 */
4781GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
4782
4783/*! @brief Returns the user pointer of the specified joystick.
4784 *
4785 * This function returns the current value of the user-defined pointer of the
4786 * specified joystick. The initial value is `NULL`.
4787 *
4788 * This function may be called from the joystick callback, even for a joystick
4789 * that is being disconnected.
4790 *
Camilla Löwyd222a402018-02-25 20:37:31 +01004791 * @param[in] jid The joystick whose pointer to return.
Camilla Löwy7c2c7852017-12-07 16:19:57 +01004792 *
4793 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4794 *
4795 * @thread_safety This function may be called from any thread. Access is not
4796 * synchronized.
4797 *
4798 * @sa @ref joystick_userptr
4799 * @sa @ref glfwSetJoystickUserPointer
4800 *
4801 * @since Added in version 3.3.
4802 *
4803 * @ingroup input
4804 */
4805GLFWAPI void* glfwGetJoystickUserPointer(int jid);
4806
Camilla Löwy953106e2017-06-18 15:13:25 +02004807/*! @brief Returns whether the specified joystick has a gamepad mapping.
4808 *
4809 * This function returns whether the specified joystick is both present and has
4810 * a gamepad mapping.
4811 *
4812 * If the specified joystick is present but does not have a gamepad mapping
4813 * this function will return `GLFW_FALSE` but will not generate an error. Call
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004814 * @ref glfwJoystickPresent to check if a joystick is present regardless of
4815 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02004816 *
4817 * @param[in] jid The [joystick](@ref joysticks) to query.
4818 * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
4819 * or `GLFW_FALSE` otherwise.
4820 *
4821 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4822 * GLFW_INVALID_ENUM.
4823 *
4824 * @thread_safety This function must only be called from the main thread.
4825 *
4826 * @sa @ref gamepad
4827 * @sa @ref glfwGetGamepadState
4828 *
4829 * @since Added in version 3.3.
4830 *
4831 * @ingroup input
4832 */
4833GLFWAPI int glfwJoystickIsGamepad(int jid);
4834
Camilla Berglund8a7fa302015-12-13 17:38:50 +01004835/*! @brief Sets the joystick configuration callback.
4836 *
4837 * This function sets the joystick configuration callback, or removes the
4838 * currently set callback. This is called when a joystick is connected to or
4839 * disconnected from the system.
4840 *
Camilla Löwya46c95c2017-02-01 04:55:46 +01004841 * For joystick connection and disconnection events to be delivered on all
4842 * platforms, you need to call one of the [event processing](@ref events)
4843 * functions. Joystick disconnection may also be detected and the callback
4844 * called by joystick functions. The function will then return whatever it
Camilla Löwy953106e2017-06-18 15:13:25 +02004845 * returns if the joystick is not present.
Camilla Löwya46c95c2017-02-01 04:55:46 +01004846 *
Camilla Berglund8a7fa302015-12-13 17:38:50 +01004847 * @param[in] cbfun The new callback, or `NULL` to remove the currently set
4848 * callback.
4849 * @return The previously set callback, or `NULL` if no callback was set or the
4850 * library had not been [initialized](@ref intro_init).
4851 *
4852 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4853 *
4854 * @thread_safety This function must only be called from the main thread.
4855 *
4856 * @sa @ref joystick_event
4857 *
4858 * @since Added in version 3.2.
4859 *
4860 * @ingroup input
4861 */
4862GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun);
4863
Camilla Löwy953106e2017-06-18 15:13:25 +02004864/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
4865 *
4866 * This function parses the specified ASCII encoded string and updates the
4867 * internal list with any gamepad mappings it finds. This string may
4868 * contain either a single gamepad mapping or many mappings separated by
4869 * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
4870 * source file including empty lines and comments.
4871 *
4872 * See @ref gamepad_mapping for a description of the format.
4873 *
4874 * If there is already a gamepad mapping for a given GUID in the internal list,
4875 * it will be replaced by the one passed to this function. If the library is
4876 * terminated and re-initialized the internal list will revert to the built-in
4877 * default.
4878 *
4879 * @param[in] string The string containing the gamepad mappings.
4880 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
4881 * [error](@ref error_handling) occurred.
4882 *
4883 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4884 * GLFW_INVALID_VALUE.
4885 *
4886 * @thread_safety This function must only be called from the main thread.
4887 *
4888 * @sa @ref gamepad
4889 * @sa @ref glfwJoystickIsGamepad
4890 * @sa @ref glfwGetGamepadName
4891 *
4892 * @since Added in version 3.3.
4893 *
4894 * @ingroup input
4895 */
4896GLFWAPI int glfwUpdateGamepadMappings(const char* string);
4897
4898/*! @brief Returns the human-readable gamepad name for the specified joystick.
4899 *
4900 * This function returns the human-readable name of the gamepad from the
4901 * gamepad mapping assigned to the specified joystick.
4902 *
4903 * If the specified joystick is not present or does not have a gamepad mapping
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004904 * this function will return `NULL` but will not generate an error. Call
4905 * @ref glfwJoystickPresent to check whether it is present regardless of
4906 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02004907 *
4908 * @param[in] jid The [joystick](@ref joysticks) to query.
4909 * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
4910 * joystick is not present, does not have a mapping or an
4911 * [error](@ref error_handling) occurred.
4912 *
4913 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
4914 * should not free it yourself. It is valid until the specified joystick is
4915 * disconnected, the gamepad mappings are updated or the library is terminated.
4916 *
4917 * @thread_safety This function must only be called from the main thread.
4918 *
4919 * @sa @ref gamepad
4920 * @sa @ref glfwJoystickIsGamepad
4921 *
4922 * @since Added in version 3.3.
4923 *
4924 * @ingroup input
4925 */
4926GLFWAPI const char* glfwGetGamepadName(int jid);
4927
4928/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
4929 *
4930 * This function retrives the state of the specified joystick remapped to
4931 * an Xbox-like gamepad.
4932 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02004933 * If the specified joystick is not present or does not have a gamepad mapping
4934 * this function will return `GLFW_FALSE` but will not generate an error. Call
4935 * @ref glfwJoystickPresent to check whether it is present regardless of
4936 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02004937 *
4938 * The Guide button may not be available for input as it is often hooked by the
4939 * system or the Steam client.
4940 *
4941 * Not all devices have all the buttons or axes provided by @ref
4942 * GLFWgamepadstate. Unavailable buttons and axes will always report
Camilla Löwy34d20b02018-03-03 22:24:26 +01004943 * `GLFW_RELEASE` and 0.0 respectively.
Camilla Löwy953106e2017-06-18 15:13:25 +02004944 *
4945 * @param[in] jid The [joystick](@ref joysticks) to query.
4946 * @param[out] state The gamepad input state of the joystick.
4947 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
4948 * connected, it has no gamepad mapping or an [error](@ref error_handling)
4949 * occurred.
4950 *
4951 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4952 * GLFW_INVALID_ENUM.
4953 *
Camilla Löwye1495c02018-08-09 13:57:10 +02004954 * @thread_safety This function must only be called from the main thread.
4955 *
Camilla Löwy953106e2017-06-18 15:13:25 +02004956 * @sa @ref gamepad
4957 * @sa @ref glfwUpdateGamepadMappings
4958 * @sa @ref glfwJoystickIsGamepad
4959 *
4960 * @since Added in version 3.3.
4961 *
4962 * @ingroup input
4963 */
4964GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
4965
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004966/*! @brief Sets the clipboard to the specified string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004967 *
4968 * This function sets the system clipboard to the specified, UTF-8 encoded
Camilla Berglund4591ad22014-09-18 15:03:29 +02004969 * string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004970 *
Camilla Löwy31cbb202017-11-04 21:11:58 +01004971 * @param[in] window Deprecated. Any valid window or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004972 * @param[in] string A UTF-8 encoded string.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004973 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004974 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4975 * GLFW_PLATFORM_ERROR.
4976 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004977 * @pointer_lifetime The specified string is copied before this function
4978 * returns.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01004979 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004980 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004981 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004982 * @sa @ref clipboard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004983 * @sa @ref glfwGetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004984 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004985 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004986 *
Camilla Berglund8d170c72014-09-09 16:26:57 +02004987 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004988 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004989GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004990
Camilla Berglund4591ad22014-09-18 15:03:29 +02004991/*! @brief Returns the contents of the clipboard as a string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004992 *
4993 * This function returns the contents of the system clipboard, if it contains
Camilla Berglundcf9079c2015-09-16 18:51:49 +02004994 * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
Camilla Berglund0b650532015-09-16 16:27:28 +02004995 * if its contents cannot be converted, `NULL` is returned and a @ref
4996 * GLFW_FORMAT_UNAVAILABLE error is generated.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004997 *
Camilla Löwy31cbb202017-11-04 21:11:58 +01004998 * @param[in] window Deprecated. Any valid window or `NULL`.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004999 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
Camilla Berglund4591ad22014-09-18 15:03:29 +02005000 * if an [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005001 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005002 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5003 * GLFW_PLATFORM_ERROR.
5004 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005005 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5006 * should not free it yourself. It is valid until the next call to @ref
Camilla Berglund6be821c2014-10-06 23:18:33 +02005007 * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
5008 * is terminated.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005009 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005010 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005011 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005012 * @sa @ref clipboard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005013 * @sa @ref glfwSetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005014 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005015 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005016 *
Camilla Berglund8d170c72014-09-09 16:26:57 +02005017 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005018 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005019GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
Ralph Eastwood31c91542011-09-21 10:09:47 +01005020
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005021/*! @brief Returns the value of the GLFW timer.
5022 *
5023 * This function returns the value of the GLFW timer. Unless the timer has
5024 * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
5025 * was initialized.
5026 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005027 * The resolution of the timer is system dependent, but is usually on the order
5028 * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
5029 * time source on each supported platform.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005030 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005031 * @return The current value, in seconds, or zero if an
5032 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005033 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005034 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5035 *
Camilla Berglund20bce152016-05-30 16:04:37 +02005036 * @thread_safety This function may be called from any thread. Reading and
5037 * writing of the internal timer offset is not atomic, so it needs to be
5038 * externally synchronized with calls to @ref glfwSetTime.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005039 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005040 * @sa @ref time
Camilla Berglund4591ad22014-09-18 15:03:29 +02005041 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005042 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005043 *
5044 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005045 */
Camilla Berglund9a716692010-09-08 16:40:43 +02005046GLFWAPI double glfwGetTime(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02005047
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005048/*! @brief Sets the GLFW timer.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005049 *
5050 * This function sets the value of the GLFW timer. It then continues to count
Camilla Berglund6e20cda2015-03-10 12:01:38 +01005051 * up from that value. The value must be a positive finite number less than
5052 * or equal to 18446744073.0, which is approximately 584.5 years.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005053 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005054 * @param[in] time The new value, in seconds.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005055 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005056 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5057 * GLFW_INVALID_VALUE.
5058 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005059 * @remark The upper limit of the timer is calculated as
Camilla Berglund6e20cda2015-03-10 12:01:38 +01005060 * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
5061 * storing nanoseconds in 64 bits. The limit may be increased in the future.
5062 *
Camilla Berglund20bce152016-05-30 16:04:37 +02005063 * @thread_safety This function may be called from any thread. Reading and
5064 * writing of the internal timer offset is not atomic, so it needs to be
5065 * externally synchronized with calls to @ref glfwGetTime.
Camilla Berglund0e205772014-03-24 11:58:35 +01005066 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005067 * @sa @ref time
Camilla Berglunde248fb62013-03-29 14:06:23 +01005068 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005069 * @since Added in version 2.2.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005070 *
5071 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005072 */
5073GLFWAPI void glfwSetTime(double time);
5074
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005075/*! @brief Returns the current value of the raw timer.
5076 *
Camilla Berglund337c77a2016-03-06 14:11:14 +01005077 * This function returns the current value of the raw timer, measured in
5078 * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
5079 * glfwGetTimerFrequency.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005080 *
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00005081 * @return The value of the timer, or zero if an
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005082 * [error](@ref error_handling) occurred.
5083 *
Camilla Berglund46fce402016-03-07 13:35:37 +01005084 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005085 *
5086 * @thread_safety This function may be called from any thread.
5087 *
5088 * @sa @ref time
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005089 * @sa @ref glfwGetTimerFrequency
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005090 *
5091 * @since Added in version 3.2.
5092 *
5093 * @ingroup input
5094 */
Camilla Berglund5661d032016-03-23 10:09:07 +01005095GLFWAPI uint64_t glfwGetTimerValue(void);
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005096
5097/*! @brief Returns the frequency, in Hz, of the raw timer.
5098 *
Camilla Berglunddefaea32016-03-07 13:36:54 +01005099 * This function returns the frequency, in Hz, of the raw timer.
5100 *
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005101 * @return The frequency of the timer, in Hz, or zero if an
5102 * [error](@ref error_handling) occurred.
5103 *
Camilla Berglund46fce402016-03-07 13:35:37 +01005104 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005105 *
5106 * @thread_safety This function may be called from any thread.
5107 *
5108 * @sa @ref time
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005109 * @sa @ref glfwGetTimerValue
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005110 *
5111 * @since Added in version 3.2.
5112 *
5113 * @ingroup input
5114 */
Camilla Berglund5661d032016-03-23 10:09:07 +01005115GLFWAPI uint64_t glfwGetTimerFrequency(void);
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005116
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005117/*! @brief Makes the context of the specified window current for the calling
5118 * thread.
5119 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005120 * This function makes the OpenGL or OpenGL ES context of the specified window
Camilla Löwyf2756d02017-11-02 19:30:12 +01005121 * current on the calling thread. A context must only be made current on
Camilla Berglund4591ad22014-09-18 15:03:29 +02005122 * a single thread at a time and each thread can have only a single current
5123 * context at a time.
5124 *
Camilla Löwyf2756d02017-11-02 19:30:12 +01005125 * When moving a context between threads, you must make it non-current on the
5126 * old thread before making it current on the new one.
5127 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005128 * By default, making a context non-current implicitly forces a pipeline flush.
5129 * On machines that support `GL_KHR_context_flush_control`, you can control
5130 * whether a context performs this flush by setting the
Camilla Löwyce161c22016-12-06 01:14:23 +01005131 * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
5132 * hint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005133 *
Camilla Berglund98b478f2015-11-05 13:44:15 +01005134 * The specified window must have an OpenGL or OpenGL ES context. Specifying
5135 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
5136 * error.
5137 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01005138 * @param[in] window The window whose context to make current, or `NULL` to
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005139 * detach the current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005140 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005141 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5142 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5143 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005144 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005145 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005146 * @sa @ref context_current
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005147 * @sa @ref glfwGetCurrentContext
Camilla Berglunde248fb62013-03-29 14:06:23 +01005148 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005149 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005150 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01005151 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005152 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005153GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005154
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005155/*! @brief Returns the window whose context is current on the calling thread.
5156 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005157 * This function returns the window whose OpenGL or OpenGL ES context is
5158 * current on the calling thread.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005159 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01005160 * @return The window whose context is current, or `NULL` if no window's
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005161 * context is current.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005162 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005163 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5164 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005165 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005166 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005167 * @sa @ref context_current
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005168 * @sa @ref glfwMakeContextCurrent
Camilla Berglunde248fb62013-03-29 14:06:23 +01005169 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005170 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005171 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01005172 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005173 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005174GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005175
5176/*! @brief Swaps the front and back buffers of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005177 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01005178 * This function swaps the front and back buffers of the specified window when
5179 * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
5180 * zero, the GPU driver waits the specified number of screen updates before
5181 * swapping the buffers.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005182 *
Camilla Berglund98b478f2015-11-05 13:44:15 +01005183 * The specified window must have an OpenGL or OpenGL ES context. Specifying
5184 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
5185 * error.
5186 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01005187 * This function does not apply to Vulkan. If you are rendering with Vulkan,
5188 * see `vkQueuePresentKHR` instead.
5189 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005190 * @param[in] window The window whose buffers to swap.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005191 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005192 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5193 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5194 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005195 * @remark __EGL:__ The context of the specified window must be current on the
Camilla Berglund276b1bc2016-01-31 19:17:18 +01005196 * calling thread.
5197 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005198 * @thread_safety This function may be called from any thread.
Camilla Berglund401033c2013-03-12 19:17:07 +01005199 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005200 * @sa @ref buffer_swap
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005201 * @sa @ref glfwSwapInterval
Camilla Berglunde248fb62013-03-29 14:06:23 +01005202 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005203 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01005204 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005205 *
5206 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005207 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005208GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005209
5210/*! @brief Sets the swap interval for the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005211 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01005212 * This function sets the swap interval for the current OpenGL or OpenGL ES
5213 * context, i.e. the number of screen updates to wait from the time @ref
5214 * glfwSwapBuffers was called before swapping the buffers and returning. This
5215 * is sometimes called _vertical synchronization_, _vertical retrace
5216 * synchronization_ or just _vsync_.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005217 *
Camilla Löwy8094a1c2017-11-27 15:53:59 +01005218 * A context that supports either of the `WGL_EXT_swap_control_tear` and
Camilla Löwybfe2d422017-11-27 01:18:51 +01005219 * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
5220 * intervals, which allows the driver to swap immediately even if a frame
5221 * arrives a little bit late. You can check for these extensions with @ref
5222 * glfwExtensionSupported.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02005223 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005224 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01005225 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005226 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01005227 * This function does not apply to Vulkan. If you are rendering with Vulkan,
5228 * see the present mode of your swapchain instead.
5229 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005230 * @param[in] interval The minimum number of screen updates to wait for
5231 * until the buffers are swapped by @ref glfwSwapBuffers.
5232 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005233 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5234 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5235 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005236 * @remark This function is not called during context creation, leaving the
Camilla Berglund11c22d62015-02-19 15:33:51 +01005237 * swap interval set to whatever is the default on that platform. This is done
Camilla Berglund3af1c412013-09-19 21:37:01 +02005238 * because some swap interval extensions used by GLFW do not allow the swap
5239 * interval to be reset to zero once it has been set to a non-zero value.
5240 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005241 * @remark Some GPU drivers do not honor the requested swap interval, either
Camilla Berglund11c22d62015-02-19 15:33:51 +01005242 * because of a user setting that overrides the application's request or due to
5243 * bugs in the driver.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02005244 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005245 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005246 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005247 * @sa @ref buffer_swap
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005248 * @sa @ref glfwSwapBuffers
Camilla Berglunde248fb62013-03-29 14:06:23 +01005249 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005250 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005251 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01005252 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005253 */
5254GLFWAPI void glfwSwapInterval(int interval);
5255
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005256/*! @brief Returns whether the specified extension is available.
5257 *
Camilla Berglund608109c2013-04-11 20:18:46 +02005258 * This function returns whether the specified
Camilla Berglund001c50c2016-02-19 09:13:56 +01005259 * [API extension](@ref context_glext) is supported by the current OpenGL or
5260 * OpenGL ES context. It searches both for client API extension and context
5261 * creation API extensions.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005262 *
5263 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01005264 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005265 *
5266 * As this functions retrieves and searches one or more extension strings each
5267 * call, it is recommended that you cache its results if it is going to be used
5268 * frequently. The extension strings will not change during the lifetime of
5269 * a context, so there is no danger in doing this.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005270 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01005271 * This function does not apply to Vulkan. If you are using Vulkan, see @ref
5272 * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
5273 * and `vkEnumerateDeviceExtensionProperties` instead.
5274 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005275 * @param[in] extension The ASCII encoded name of the extension.
Camilla Berglund0eccf752015-08-23 19:30:04 +02005276 * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
5277 * otherwise.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005278 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005279 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5280 * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
5281 * GLFW_PLATFORM_ERROR.
5282 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005283 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005284 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005285 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005286 * @sa @ref glfwGetProcAddress
Camilla Berglund4591ad22014-09-18 15:03:29 +02005287 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005288 * @since Added in version 1.0.
Camilla Berglunde248fb62013-03-29 14:06:23 +01005289 *
5290 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005291 */
5292GLFWAPI int glfwExtensionSupported(const char* extension);
5293
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005294/*! @brief Returns the address of the specified function for the current
5295 * context.
5296 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01005297 * This function returns the address of the specified OpenGL or OpenGL ES
Camilla Berglund11c22d62015-02-19 15:33:51 +01005298 * [core or extension function](@ref context_glext), if it is supported
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02005299 * by the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005300 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005301 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01005302 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005303 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01005304 * This function does not apply to Vulkan. If you are rendering with Vulkan,
5305 * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
5306 * `vkGetDeviceProcAddr` instead.
5307 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005308 * @param[in] procname The ASCII encoded name of the function.
Camilla Berglunda36e3a22015-11-05 17:14:26 +01005309 * @return The address of the function, or `NULL` if an
5310 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005311 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005312 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5313 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5314 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005315 * @remark The address of a given function is not guaranteed to be the same
Camilla Berglund4591ad22014-09-18 15:03:29 +02005316 * between contexts.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005317 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005318 * @remark This function may return a non-`NULL` address despite the
Camilla Berglund11c22d62015-02-19 15:33:51 +01005319 * associated version or extension not being available. Always check the
Camilla Berglundc8e06872015-08-27 21:40:22 +02005320 * context version or extension string first.
Camilla Berglund11c22d62015-02-19 15:33:51 +01005321 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005322 * @pointer_lifetime The returned function pointer is valid until the context
5323 * is destroyed or the library is terminated.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005324 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005325 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005326 *
5327 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005328 * @sa @ref glfwExtensionSupported
Camilla Berglund4591ad22014-09-18 15:03:29 +02005329 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005330 * @since Added in version 1.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005331 *
5332 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005333 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02005334GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
Camilla Berglund3249f812010-09-07 17:34:51 +02005335
Camilla Löwy98bdd362017-02-07 20:56:48 +01005336/*! @brief Returns whether the Vulkan loader and an ICD have been found.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005337 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01005338 * This function returns whether the Vulkan loader and any minimally functional
5339 * ICD have been found.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005340 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01005341 * The availability of a Vulkan loader and even an ICD does not by itself
5342 * guarantee that surface creation or even instance creation is possible.
5343 * For example, on Fermi systems Nvidia will install an ICD that provides no
5344 * actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
5345 * whether the extensions necessary for Vulkan surface creation are available
5346 * and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
5347 * family of a physical device supports image presentation.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005348 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01005349 * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
5350 * otherwise.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005351 *
5352 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5353 *
5354 * @thread_safety This function may be called from any thread.
5355 *
5356 * @sa @ref vulkan_support
5357 *
5358 * @since Added in version 3.2.
5359 *
5360 * @ingroup vulkan
5361 */
5362GLFWAPI int glfwVulkanSupported(void);
5363
5364/*! @brief Returns the Vulkan instance extensions required by GLFW.
5365 *
5366 * This function returns an array of names of Vulkan instance extensions required
5367 * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
5368 * list will always contains `VK_KHR_surface`, so if you don't require any
5369 * additional extensions you can pass this list directly to the
5370 * `VkInstanceCreateInfo` struct.
5371 *
5372 * If Vulkan is not available on the machine, this function returns `NULL` and
5373 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01005374 * to check whether Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005375 *
5376 * If Vulkan is available but no set of extensions allowing window surface
5377 * creation was found, this function returns `NULL`. You may still use Vulkan
5378 * for off-screen rendering and compute work.
5379 *
5380 * @param[out] count Where to store the number of extensions in the returned
5381 * array. This is set to zero if an error occurred.
5382 * @return An array of ASCII encoded extension names, or `NULL` if an
5383 * [error](@ref error_handling) occurred.
5384 *
5385 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5386 * GLFW_API_UNAVAILABLE.
5387 *
Camilla Berglund67931bd2016-10-26 16:58:56 +02005388 * @remark Additional extensions may be required by future versions of GLFW.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005389 * You should check if any extensions you wish to enable are already in the
5390 * returned array, as it is an error to specify an extension more than once in
5391 * the `VkInstanceCreateInfo` struct.
5392 *
Camilla Berglunde94d1662016-10-14 01:46:56 +02005393 * @remark @macos This function currently only supports the
5394 * `VK_MVK_macos_surface` extension from MoltenVK.
5395 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005396 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5397 * should not free it yourself. It is guaranteed to be valid only until the
5398 * library is terminated.
5399 *
5400 * @thread_safety This function may be called from any thread.
5401 *
5402 * @sa @ref vulkan_ext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005403 * @sa @ref glfwCreateWindowSurface
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005404 *
5405 * @since Added in version 3.2.
5406 *
5407 * @ingroup vulkan
5408 */
Camilla Berglund7ab7d8b2016-03-23 10:24:01 +01005409GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005410
5411#if defined(VK_VERSION_1_0)
5412
5413/*! @brief Returns the address of the specified Vulkan instance function.
5414 *
5415 * This function returns the address of the specified Vulkan core or extension
5416 * function for the specified instance. If instance is set to `NULL` it can
5417 * return any function exported from the Vulkan loader, including at least the
5418 * following functions:
5419 *
5420 * - `vkEnumerateInstanceExtensionProperties`
5421 * - `vkEnumerateInstanceLayerProperties`
5422 * - `vkCreateInstance`
5423 * - `vkGetInstanceProcAddr`
5424 *
5425 * If Vulkan is not available on the machine, this function returns `NULL` and
5426 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01005427 * to check whether Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005428 *
5429 * This function is equivalent to calling `vkGetInstanceProcAddr` with
5430 * a platform-specific query of the Vulkan loader as a fallback.
5431 *
5432 * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
5433 * functions related to instance creation.
5434 * @param[in] procname The ASCII encoded name of the function.
5435 * @return The address of the function, or `NULL` if an
5436 * [error](@ref error_handling) occurred.
5437 *
5438 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5439 * GLFW_API_UNAVAILABLE.
5440 *
5441 * @pointer_lifetime The returned function pointer is valid until the library
5442 * is terminated.
5443 *
5444 * @thread_safety This function may be called from any thread.
5445 *
5446 * @sa @ref vulkan_proc
5447 *
5448 * @since Added in version 3.2.
5449 *
5450 * @ingroup vulkan
5451 */
5452GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
5453
5454/*! @brief Returns whether the specified queue family can present images.
5455 *
5456 * This function returns whether the specified queue family of the specified
5457 * physical device supports presentation to the platform GLFW was built for.
5458 *
5459 * If Vulkan or the required window surface creation instance extensions are
5460 * not available on the machine, or if the specified instance was not created
5461 * with the required extensions, this function returns `GLFW_FALSE` and
5462 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01005463 * to check whether Vulkan is at least minimally available and @ref
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005464 * glfwGetRequiredInstanceExtensions to check what instance extensions are
5465 * required.
5466 *
5467 * @param[in] instance The instance that the physical device belongs to.
5468 * @param[in] device The physical device that the queue family belongs to.
5469 * @param[in] queuefamily The index of the queue family to query.
5470 * @return `GLFW_TRUE` if the queue family supports presentation, or
5471 * `GLFW_FALSE` otherwise.
5472 *
5473 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5474 * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
5475 *
Camilla Berglunde94d1662016-10-14 01:46:56 +02005476 * @remark @macos This function currently always returns `GLFW_TRUE`, as the
5477 * `VK_MVK_macos_surface` extension does not provide
5478 * a `vkGetPhysicalDevice*PresentationSupport` type function.
5479 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005480 * @thread_safety This function may be called from any thread. For
5481 * synchronization details of Vulkan objects, see the Vulkan specification.
5482 *
5483 * @sa @ref vulkan_present
5484 *
5485 * @since Added in version 3.2.
5486 *
5487 * @ingroup vulkan
5488 */
5489GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
5490
5491/*! @brief Creates a Vulkan surface for the specified window.
5492 *
5493 * This function creates a Vulkan surface for the specified window.
5494 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01005495 * If the Vulkan loader or at least one minimally functional ICD were not found,
5496 * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
5497 * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
5498 * Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005499 *
5500 * If the required window surface creation instance extensions are not
5501 * available or if the specified instance was not created with these extensions
5502 * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
5503 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
5504 * glfwGetRequiredInstanceExtensions to check what instance extensions are
5505 * required.
5506 *
Corentin Wallez8a8eefa2018-01-30 13:25:17 -05005507 * The window surface cannot be shared with another API so the window must
5508 * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
5509 * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
5510 * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
5511 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005512 * The window surface must be destroyed before the specified Vulkan instance.
5513 * It is the responsibility of the caller to destroy the window surface. GLFW
5514 * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
5515 * surface.
5516 *
5517 * @param[in] instance The Vulkan instance to create the surface in.
5518 * @param[in] window The window to create the surface for.
5519 * @param[in] allocator The allocator to use, or `NULL` to use the default
5520 * allocator.
5521 * @param[out] surface Where to store the handle of the surface. This is set
5522 * to `VK_NULL_HANDLE` if an error occurred.
5523 * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
5524 * [error](@ref error_handling) occurred.
5525 *
5526 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Corentin Wallez8a8eefa2018-01-30 13:25:17 -05005527 * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005528 *
Camilla Berglund67931bd2016-10-26 16:58:56 +02005529 * @remark If an error occurs before the creation call is made, GLFW returns
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005530 * the Vulkan error code most appropriate for the error. Appropriate use of
5531 * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
Camilla Berglundee33dcd2016-03-07 14:42:51 +01005532 * eliminate almost all occurrences of these errors.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005533 *
Camilla Berglunde94d1662016-10-14 01:46:56 +02005534 * @remark @macos This function currently only supports the
5535 * `VK_MVK_macos_surface` extension from MoltenVK.
5536 *
5537 * @remark @macos This function creates and sets a `CAMetalLayer` instance for
5538 * the window content view, which is required for MoltenVK to function.
5539 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005540 * @thread_safety This function may be called from any thread. For
5541 * synchronization details of Vulkan objects, see the Vulkan specification.
5542 *
5543 * @sa @ref vulkan_surface
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005544 * @sa @ref glfwGetRequiredInstanceExtensions
Camilla Berglund9b75bff2015-08-10 20:19:04 +02005545 *
5546 * @since Added in version 3.2.
5547 *
5548 * @ingroup vulkan
5549 */
5550GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
5551
5552#endif /*VK_VERSION_1_0*/
5553
Camilla Berglund3249f812010-09-07 17:34:51 +02005554
Camilla Berglund4afc67c2011-07-27 17:09:17 +02005555/*************************************************************************
5556 * Global definition cleanup
5557 *************************************************************************/
5558
5559/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
5560
Camilla Berglund4afc67c2011-07-27 17:09:17 +02005561#ifdef GLFW_WINGDIAPI_DEFINED
5562 #undef WINGDIAPI
5563 #undef GLFW_WINGDIAPI_DEFINED
5564#endif
5565
5566#ifdef GLFW_CALLBACK_DEFINED
5567 #undef CALLBACK
5568 #undef GLFW_CALLBACK_DEFINED
5569#endif
5570
Camilla Löwybe51c202017-07-03 14:25:47 +02005571/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
5572 * defined by some gl.h variants (OpenBSD) so define it after if needed.
5573 */
5574#ifndef GLAPIENTRY
5575 #define GLAPIENTRY APIENTRY
5576#endif
5577
Camilla Berglund4afc67c2011-07-27 17:09:17 +02005578/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
5579
5580
Camilla Berglund3249f812010-09-07 17:34:51 +02005581#ifdef __cplusplus
5582}
5583#endif
5584
Camilla Berglundf8df91d2013-01-15 01:59:56 +01005585#endif /* _glfw3_h_ */
Camilla Berglund3249f812010-09-07 17:34:51 +02005586