blob: 9ca3036d64d0abecd91b8deec38c6f2eb5ebc80f [file] [log] [blame]
Camilla Berglund2955cd32010-11-17 15:42:55 +01001/*************************************************************************
Camilla Löwya337c562019-04-16 14:43:29 +02002 * GLFW 3.4 - 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öwyab118b22019-04-15 20:50:00 +02006 * Copyright (c) 2006-2019 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 Löwy41a19ed2020-05-04 23:18:48 +020055/*! @defgroup vulkan Vulkan support 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 Löwy773f4492019-07-12 14:23:12 +020099/* Include because most Windows GLU headers need wchar_t and
100 * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
101 * Include it unconditionally to avoid surprising side-effects.
102 */
103#include <stddef.h>
104
105/* Include because it is needed by Vulkan and related functions.
106 * Include it unconditionally to avoid surprising side-effects.
107 */
108#include <stdint.h>
109
110#if defined(GLFW_INCLUDE_VULKAN)
111 #include <vulkan/vulkan.h>
112#endif /* Vulkan header */
113
114/* The Vulkan header may have indirectly included windows.h (because of
115 * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it.
116 */
117
Camilla Berglund8d910d72015-02-22 18:35:10 +0100118/* It is customary to use APIENTRY for OpenGL function pointer declarations on
119 * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
Camilla Berglund3249f812010-09-07 17:34:51 +0200120 */
Camilla Löwy62b7fe82019-07-12 14:33:05 +0200121#if !defined(APIENTRY)
122 #if defined(_WIN32)
Camilla Berglund3249f812010-09-07 17:34:51 +0200123 #define APIENTRY __stdcall
124 #else
125 #define APIENTRY
126 #endif
Camilla Löwyc23fca62017-08-21 14:37:38 +0200127 #define GLFW_APIENTRY_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200128#endif /* APIENTRY */
129
Camilla Berglund8d910d72015-02-22 18:35:10 +0100130/* Some Windows OpenGL headers need this.
Camilla Berglund3249f812010-09-07 17:34:51 +0200131 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200132#if !defined(WINGDIAPI) && defined(_WIN32)
Camilla Berglundc5353642015-02-22 18:14:30 +0100133 #define WINGDIAPI __declspec(dllimport)
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200134 #define GLFW_WINGDIAPI_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200135#endif /* WINGDIAPI */
136
Camilla Berglund8d910d72015-02-22 18:35:10 +0100137/* Some Windows GLU headers need this.
138 */
Camilla Berglund3249f812010-09-07 17:34:51 +0200139#if !defined(CALLBACK) && defined(_WIN32)
Camilla Berglundd586fe62015-02-22 18:17:34 +0100140 #define CALLBACK __stdcall
Camilla Berglund4afc67c2011-07-27 17:09:17 +0200141 #define GLFW_CALLBACK_DEFINED
Camilla Berglund3249f812010-09-07 17:34:51 +0200142#endif /* CALLBACK */
143
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200144/* Include the chosen OpenGL or OpenGL ES headers.
Camilla Berglundc93b1202013-09-08 16:07:34 +0200145 */
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200146#if defined(GLFW_INCLUDE_ES1)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200147
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200148 #include <GLES/gl.h>
149 #if defined(GLFW_INCLUDE_GLEXT)
150 #include <GLES/glext.h>
151 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200152
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200153#elif defined(GLFW_INCLUDE_ES2)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200154
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200155 #include <GLES2/gl2.h>
156 #if defined(GLFW_INCLUDE_GLEXT)
157 #include <GLES2/gl2ext.h>
158 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200159
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200160#elif defined(GLFW_INCLUDE_ES3)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200161
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200162 #include <GLES3/gl3.h>
163 #if defined(GLFW_INCLUDE_GLEXT)
164 #include <GLES2/gl2ext.h>
165 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200166
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200167#elif defined(GLFW_INCLUDE_ES31)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200168
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200169 #include <GLES3/gl31.h>
170 #if defined(GLFW_INCLUDE_GLEXT)
171 #include <GLES2/gl2ext.h>
172 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200173
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200174#elif defined(GLFW_INCLUDE_ES32)
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200175
Konstantin Käfer244d6d72017-05-16 15:42:51 +0200176 #include <GLES3/gl32.h>
177 #if defined(GLFW_INCLUDE_GLEXT)
178 #include <GLES2/gl2ext.h>
179 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200180
181#elif defined(GLFW_INCLUDE_GLCOREARB)
182
183 #if defined(__APPLE__)
184
Camilla Berglund1591caa2015-01-08 06:56:17 +0100185 #include <OpenGL/gl3.h>
186 #if defined(GLFW_INCLUDE_GLEXT)
187 #include <OpenGL/gl3ext.h>
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200188 #endif /*GLFW_INCLUDE_GLEXT*/
189
190 #else /*__APPLE__*/
191
192 #include <GL/glcorearb.h>
Camilla Löwy309d7932021-09-26 16:28:04 +0200193 #if defined(GLFW_INCLUDE_GLEXT)
194 #include <GL/glext.h>
195 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200196
197 #endif /*__APPLE__*/
198
Tatsuya Yatagawa81f475b2020-06-05 12:57:43 +0900199#elif defined(GLFW_INCLUDE_GLU)
200
201 #if defined(__APPLE__)
202
203 #if defined(GLFW_INCLUDE_GLU)
204 #include <OpenGL/glu.h>
205 #endif
206
207 #else /*__APPLE__*/
208
209 #if defined(GLFW_INCLUDE_GLU)
210 #include <GL/glu.h>
211 #endif
212
213 #endif /*__APPLE__*/
214
Camilla Löwy105cf322020-05-26 23:35:40 +0200215#elif !defined(GLFW_INCLUDE_NONE) && \
216 !defined(__gl_h_) && \
217 !defined(__gles1_gl_h_) && \
218 !defined(__gles2_gl2_h_) && \
219 !defined(__gles2_gl3_h_) && \
220 !defined(__gles2_gl31_h_) && \
221 !defined(__gles2_gl32_h_) && \
222 !defined(__gl_glcorearb_h_) && \
223 !defined(__gl2_h_) /*legacy*/ && \
224 !defined(__gl3_h_) /*legacy*/ && \
225 !defined(__gl31_h_) /*legacy*/ && \
226 !defined(__gl32_h_) /*legacy*/ && \
227 !defined(__glcorearb_h_) /*legacy*/ && \
228 !defined(__GL_H__) /*non-standard*/ && \
229 !defined(__gltypes_h_) /*non-standard*/ && \
230 !defined(__glee_h_) /*non-standard*/
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200231
232 #if defined(__APPLE__)
233
Camilla Berglund1591caa2015-01-08 06:56:17 +0100234 #if !defined(GLFW_INCLUDE_GLEXT)
235 #define GL_GLEXT_LEGACY
Camilla Berglundc93b1202013-09-08 16:07:34 +0200236 #endif
Camilla Berglund1591caa2015-01-08 06:56:17 +0100237 #include <OpenGL/gl.h>
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200238
239 #else /*__APPLE__*/
240
Camilla Berglund1591caa2015-01-08 06:56:17 +0100241 #include <GL/gl.h>
242 #if defined(GLFW_INCLUDE_GLEXT)
243 #include <GL/glext.h>
244 #endif
Camilla Löwyfa0b5e12017-05-16 14:54:17 +0200245
246 #endif /*__APPLE__*/
247
248#endif /* OpenGL and OpenGL ES headers */
249
Camilla Berglundcc5d7cd2012-03-25 17:43:02 +0200250#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
Camilla Berglunde8e05d42014-04-23 13:30:11 +0200251 /* GLFW_DLL must be defined by applications that are linking against the DLL
252 * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
253 * configuration header when compiling the DLL version of the library.
Camilla Berglundbd2d5712013-07-23 01:59:27 +0200254 */
Camilla Berglund0df4e062015-12-13 14:07:27 +0100255 #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
Camilla Berglundcc5d7cd2012-03-25 17:43:02 +0200256#endif
257
Camilla Berglund1591caa2015-01-08 06:56:17 +0100258/* GLFWAPI is used to declare public API functions for export
259 * from the DLL / shared library / dynamic library.
260 */
Camilla Berglund2588c9b2012-03-25 17:40:30 +0200261#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
Camilla Berglund3afa8312014-10-13 14:13:08 +0200262 /* We are building GLFW as a Win32 DLL */
Camilla Berglund2955cd32010-11-17 15:42:55 +0100263 #define GLFWAPI __declspec(dllexport)
Camilla Berglund3249f812010-09-07 17:34:51 +0200264#elif defined(_WIN32) && defined(GLFW_DLL)
Camilla Löwy685de902022-04-21 17:35:50 +0200265 /* We are calling a GLFW Win32 DLL */
Camilla Berglund1247fc02015-02-22 18:10:20 +0100266 #define GLFWAPI __declspec(dllimport)
John Bartholomew93f4eff2013-05-01 13:08:09 +0100267#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
Camilla Löwy685de902022-04-21 17:35:50 +0200268 /* We are building GLFW as a Unix shared library */
John Bartholomew93f4eff2013-05-01 13:08:09 +0100269 #define GLFWAPI __attribute__((visibility("default")))
Camilla Berglund3249f812010-09-07 17:34:51 +0200270#else
Camilla Berglund3249f812010-09-07 17:34:51 +0200271 #define GLFWAPI
Camilla Berglund3249f812010-09-07 17:34:51 +0200272#endif
273
Camilla Berglund3249f812010-09-07 17:34:51 +0200274
275/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100276 * GLFW API tokens
Camilla Berglund3249f812010-09-07 17:34:51 +0200277 *************************************************************************/
278
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100279/*! @name GLFW version macros
280 * @{ */
Camilla Löwye17ffcd2021-05-12 18:49:35 +0200281/*! @brief The major version number of the GLFW header.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100282 *
Camilla Löwye17ffcd2021-05-12 18:49:35 +0200283 * The major version number of the GLFW header. This is incremented when the
284 * API is changed in non-compatible ways.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100285 * @ingroup init
286 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100287#define GLFW_VERSION_MAJOR 3
Camilla Löwye17ffcd2021-05-12 18:49:35 +0200288/*! @brief The minor version number of the GLFW header.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100289 *
Camilla Löwye17ffcd2021-05-12 18:49:35 +0200290 * The minor version number of the GLFW header. This is incremented when
291 * features are added to the API but it remains backward-compatible.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100292 * @ingroup init
293 */
Camilla Löwya337c562019-04-16 14:43:29 +0200294#define GLFW_VERSION_MINOR 4
Camilla Löwye17ffcd2021-05-12 18:49:35 +0200295/*! @brief The revision number of the GLFW header.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100296 *
Camilla Löwye17ffcd2021-05-12 18:49:35 +0200297 * The revision number of the GLFW header. This is incremented when a bug fix
298 * release is made that does not contain any API changes.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100299 * @ingroup init
300 */
Camilla Berglund53fafad2016-08-18 23:42:15 +0200301#define GLFW_VERSION_REVISION 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100302/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200303
Camilla Berglund0eccf752015-08-23 19:30:04 +0200304/*! @brief One.
305 *
Camilla Löwy04116782018-11-05 17:37:49 +0100306 * This is only semantic sugar for the number 1. You can instead use `1` or
Camilla Löwy422bf792019-04-01 18:36:30 +0200307 * `true` or `_True` or `GL_TRUE` or `VK_TRUE` or anything else that is equal
308 * to one.
Camilla Löwy04116782018-11-05 17:37:49 +0100309 *
310 * @ingroup init
Camilla Berglund0eccf752015-08-23 19:30:04 +0200311 */
312#define GLFW_TRUE 1
313/*! @brief Zero.
314 *
Camilla Löwy04116782018-11-05 17:37:49 +0100315 * This is only semantic sugar for the number 0. You can instead use `0` or
Camilla Löwy422bf792019-04-01 18:36:30 +0200316 * `false` or `_False` or `GL_FALSE` or `VK_FALSE` or anything else that is
317 * equal to zero.
Camilla Löwy04116782018-11-05 17:37:49 +0100318 *
319 * @ingroup init
Camilla Berglund0eccf752015-08-23 19:30:04 +0200320 */
321#define GLFW_FALSE 0
Camilla Berglund0eccf752015-08-23 19:30:04 +0200322
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100323/*! @name Key and button actions
324 * @{ */
Camilla Berglund4591ad22014-09-18 15:03:29 +0200325/*! @brief The key or mouse button was released.
326 *
327 * The key or mouse button was released.
328 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100329 * @ingroup input
330 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100331#define GLFW_RELEASE 0
Camilla Berglund4591ad22014-09-18 15:03:29 +0200332/*! @brief The key or mouse button was pressed.
333 *
334 * The key or mouse button was pressed.
335 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100336 * @ingroup input
337 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100338#define GLFW_PRESS 1
Camilla Berglund253e0d62013-01-12 17:06:35 +0100339/*! @brief The key was held down until it repeated.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200340 *
341 * The key was held down until it repeated.
342 *
Camilla Berglund253e0d62013-01-12 17:06:35 +0100343 * @ingroup input
344 */
345#define GLFW_REPEAT 2
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100346/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200347
Camilla Löwy798d7c62017-03-01 23:27:20 +0100348/*! @defgroup hat_state Joystick hat states
Camilla Löwy04116782018-11-05 17:37:49 +0100349 * @brief Joystick hat states.
IntellectualKitty368dec72016-11-25 20:56:24 -0700350 *
351 * See [joystick hat input](@ref joystick_hat) for how these are used.
352 *
353 * @ingroup input
354 * @{ */
355#define GLFW_HAT_CENTERED 0
356#define GLFW_HAT_UP 1
357#define GLFW_HAT_RIGHT 2
358#define GLFW_HAT_DOWN 4
359#define GLFW_HAT_LEFT 8
360#define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP)
361#define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
362#define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
363#define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
364/*! @} */
365
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200366/*! @defgroup keys Keyboard keys
Camilla Löwy21eabd32017-02-06 17:31:25 +0100367 * @brief Keyboard key IDs.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200368 *
Camilla Berglund4188c262015-01-18 01:55:25 +0100369 * See [key input](@ref input_key) for how these are used.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200370 *
Camilla Berglund4188c262015-01-18 01:55:25 +0100371 * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
372 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
373 * put in the 256+ range).
374 *
375 * The naming of the key codes follow these rules:
376 * - The US keyboard layout is used
luz paz0fe96ec2021-09-15 08:20:56 -0400377 * - Names of printable alphanumeric characters are used (e.g. "A", "R",
Camilla Berglund4188c262015-01-18 01:55:25 +0100378 * "3", etc.)
379 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
380 * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
381 * correspond to the Unicode standard (usually for brevity)
382 * - Keys that lack a clear US mapping are named "WORLD_x"
383 * - For non-printable keys, custom names are used (e.g. "F4",
384 * "BACKSPACE", etc.)
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200385 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100386 * @ingroup input
387 * @{
388 */
389
Camilla Berglund11615fc2013-05-30 17:19:12 +0200390/* The unknown key */
391#define GLFW_KEY_UNKNOWN -1
392
Marcusc0cb4c22011-01-02 11:18:14 +0100393/* Printable keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100394#define GLFW_KEY_SPACE 32
395#define GLFW_KEY_APOSTROPHE 39 /* ' */
396#define GLFW_KEY_COMMA 44 /* , */
397#define GLFW_KEY_MINUS 45 /* - */
398#define GLFW_KEY_PERIOD 46 /* . */
399#define GLFW_KEY_SLASH 47 /* / */
400#define GLFW_KEY_0 48
401#define GLFW_KEY_1 49
402#define GLFW_KEY_2 50
403#define GLFW_KEY_3 51
404#define GLFW_KEY_4 52
405#define GLFW_KEY_5 53
406#define GLFW_KEY_6 54
407#define GLFW_KEY_7 55
408#define GLFW_KEY_8 56
409#define GLFW_KEY_9 57
410#define GLFW_KEY_SEMICOLON 59 /* ; */
411#define GLFW_KEY_EQUAL 61 /* = */
412#define GLFW_KEY_A 65
413#define GLFW_KEY_B 66
414#define GLFW_KEY_C 67
415#define GLFW_KEY_D 68
416#define GLFW_KEY_E 69
417#define GLFW_KEY_F 70
418#define GLFW_KEY_G 71
419#define GLFW_KEY_H 72
420#define GLFW_KEY_I 73
421#define GLFW_KEY_J 74
422#define GLFW_KEY_K 75
423#define GLFW_KEY_L 76
424#define GLFW_KEY_M 77
425#define GLFW_KEY_N 78
426#define GLFW_KEY_O 79
427#define GLFW_KEY_P 80
428#define GLFW_KEY_Q 81
429#define GLFW_KEY_R 82
430#define GLFW_KEY_S 83
431#define GLFW_KEY_T 84
432#define GLFW_KEY_U 85
433#define GLFW_KEY_V 86
434#define GLFW_KEY_W 87
435#define GLFW_KEY_X 88
436#define GLFW_KEY_Y 89
437#define GLFW_KEY_Z 90
438#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
439#define GLFW_KEY_BACKSLASH 92 /* \ */
440#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
441#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
442#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
443#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
Marcusc0cb4c22011-01-02 11:18:14 +0100444
445/* Function keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100446#define GLFW_KEY_ESCAPE 256
447#define GLFW_KEY_ENTER 257
448#define GLFW_KEY_TAB 258
449#define GLFW_KEY_BACKSPACE 259
450#define GLFW_KEY_INSERT 260
451#define GLFW_KEY_DELETE 261
452#define GLFW_KEY_RIGHT 262
453#define GLFW_KEY_LEFT 263
454#define GLFW_KEY_DOWN 264
455#define GLFW_KEY_UP 265
456#define GLFW_KEY_PAGE_UP 266
457#define GLFW_KEY_PAGE_DOWN 267
458#define GLFW_KEY_HOME 268
459#define GLFW_KEY_END 269
460#define GLFW_KEY_CAPS_LOCK 280
461#define GLFW_KEY_SCROLL_LOCK 281
462#define GLFW_KEY_NUM_LOCK 282
463#define GLFW_KEY_PRINT_SCREEN 283
464#define GLFW_KEY_PAUSE 284
465#define GLFW_KEY_F1 290
466#define GLFW_KEY_F2 291
467#define GLFW_KEY_F3 292
468#define GLFW_KEY_F4 293
469#define GLFW_KEY_F5 294
470#define GLFW_KEY_F6 295
471#define GLFW_KEY_F7 296
472#define GLFW_KEY_F8 297
473#define GLFW_KEY_F9 298
474#define GLFW_KEY_F10 299
475#define GLFW_KEY_F11 300
476#define GLFW_KEY_F12 301
477#define GLFW_KEY_F13 302
478#define GLFW_KEY_F14 303
479#define GLFW_KEY_F15 304
480#define GLFW_KEY_F16 305
481#define GLFW_KEY_F17 306
482#define GLFW_KEY_F18 307
483#define GLFW_KEY_F19 308
484#define GLFW_KEY_F20 309
485#define GLFW_KEY_F21 310
486#define GLFW_KEY_F22 311
487#define GLFW_KEY_F23 312
488#define GLFW_KEY_F24 313
489#define GLFW_KEY_F25 314
490#define GLFW_KEY_KP_0 320
491#define GLFW_KEY_KP_1 321
492#define GLFW_KEY_KP_2 322
493#define GLFW_KEY_KP_3 323
494#define GLFW_KEY_KP_4 324
495#define GLFW_KEY_KP_5 325
496#define GLFW_KEY_KP_6 326
497#define GLFW_KEY_KP_7 327
498#define GLFW_KEY_KP_8 328
499#define GLFW_KEY_KP_9 329
500#define GLFW_KEY_KP_DECIMAL 330
501#define GLFW_KEY_KP_DIVIDE 331
502#define GLFW_KEY_KP_MULTIPLY 332
503#define GLFW_KEY_KP_SUBTRACT 333
504#define GLFW_KEY_KP_ADD 334
505#define GLFW_KEY_KP_ENTER 335
506#define GLFW_KEY_KP_EQUAL 336
507#define GLFW_KEY_LEFT_SHIFT 340
508#define GLFW_KEY_LEFT_CONTROL 341
509#define GLFW_KEY_LEFT_ALT 342
510#define GLFW_KEY_LEFT_SUPER 343
511#define GLFW_KEY_RIGHT_SHIFT 344
512#define GLFW_KEY_RIGHT_CONTROL 345
513#define GLFW_KEY_RIGHT_ALT 346
514#define GLFW_KEY_RIGHT_SUPER 347
515#define GLFW_KEY_MENU 348
Camilla Berglund9c315412015-07-02 14:24:50 +0200516
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100517#define GLFW_KEY_LAST GLFW_KEY_MENU
Marcusc0cb4c22011-01-02 11:18:14 +0100518
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100519/*! @} */
520
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200521/*! @defgroup mods Modifier key flags
Camilla Löwy21eabd32017-02-06 17:31:25 +0100522 * @brief Modifier key flags.
Camilla Berglund4188c262015-01-18 01:55:25 +0100523 *
524 * See [key input](@ref input_key) for how these are used.
525 *
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200526 * @ingroup input
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100527 * @{ */
528
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200529/*! @brief If this bit is set one or more Shift keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100530 *
531 * If this bit is set one or more Shift keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100532 */
533#define GLFW_MOD_SHIFT 0x0001
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200534/*! @brief If this bit is set one or more Control keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100535 *
536 * If this bit is set one or more Control keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100537 */
Camilla Berglund3bcffba2013-05-23 14:11:05 +0200538#define GLFW_MOD_CONTROL 0x0002
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200539/*! @brief If this bit is set one or more Alt keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100540 *
541 * If this bit is set one or more Alt keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100542 */
543#define GLFW_MOD_ALT 0x0004
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200544/*! @brief If this bit is set one or more Super keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100545 *
546 * If this bit is set one or more Super keys were held down.
Noel Cowereff85f92013-05-23 13:22:27 +0200547 */
548#define GLFW_MOD_SUPER 0x0008
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100549/*! @brief If this bit is set the Caps Lock key is enabled.
550 *
551 * If this bit is set the Caps Lock key is enabled and the @ref
552 * GLFW_LOCK_KEY_MODS input mode is set.
553 */
554#define GLFW_MOD_CAPS_LOCK 0x0010
555/*! @brief If this bit is set the Num Lock key is enabled.
556 *
557 * If this bit is set the Num Lock key is enabled and the @ref
558 * GLFW_LOCK_KEY_MODS input mode is set.
559 */
560#define GLFW_MOD_NUM_LOCK 0x0020
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100561
562/*! @} */
563
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100564/*! @defgroup buttons Mouse buttons
Camilla Löwy21eabd32017-02-06 17:31:25 +0100565 * @brief Mouse button IDs.
Camilla Berglund4188c262015-01-18 01:55:25 +0100566 *
567 * See [mouse button input](@ref input_mouse_button) for how these are used.
568 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100569 * @ingroup input
570 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100571#define GLFW_MOUSE_BUTTON_1 0
572#define GLFW_MOUSE_BUTTON_2 1
573#define GLFW_MOUSE_BUTTON_3 2
574#define GLFW_MOUSE_BUTTON_4 3
575#define GLFW_MOUSE_BUTTON_5 4
576#define GLFW_MOUSE_BUTTON_6 5
577#define GLFW_MOUSE_BUTTON_7 6
578#define GLFW_MOUSE_BUTTON_8 7
579#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
580#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
581#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
582#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100583/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200584
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100585/*! @defgroup joysticks Joysticks
Camilla Löwy21eabd32017-02-06 17:31:25 +0100586 * @brief Joystick IDs.
Camilla Berglund4188c262015-01-18 01:55:25 +0100587 *
588 * See [joystick input](@ref joystick) for how these are used.
589 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100590 * @ingroup input
591 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100592#define GLFW_JOYSTICK_1 0
593#define GLFW_JOYSTICK_2 1
594#define GLFW_JOYSTICK_3 2
595#define GLFW_JOYSTICK_4 3
596#define GLFW_JOYSTICK_5 4
597#define GLFW_JOYSTICK_6 5
598#define GLFW_JOYSTICK_7 6
599#define GLFW_JOYSTICK_8 7
600#define GLFW_JOYSTICK_9 8
601#define GLFW_JOYSTICK_10 9
602#define GLFW_JOYSTICK_11 10
603#define GLFW_JOYSTICK_12 11
604#define GLFW_JOYSTICK_13 12
605#define GLFW_JOYSTICK_14 13
606#define GLFW_JOYSTICK_15 14
607#define GLFW_JOYSTICK_16 15
608#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100609/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200610
Camilla Löwy953106e2017-06-18 15:13:25 +0200611/*! @defgroup gamepad_buttons Gamepad buttons
612 * @brief Gamepad buttons.
613 *
614 * See @ref gamepad for how these are used.
615 *
616 * @ingroup input
617 * @{ */
618#define GLFW_GAMEPAD_BUTTON_A 0
619#define GLFW_GAMEPAD_BUTTON_B 1
620#define GLFW_GAMEPAD_BUTTON_X 2
621#define GLFW_GAMEPAD_BUTTON_Y 3
622#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
623#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
624#define GLFW_GAMEPAD_BUTTON_BACK 6
625#define GLFW_GAMEPAD_BUTTON_START 7
626#define GLFW_GAMEPAD_BUTTON_GUIDE 8
627#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
628#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
629#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
630#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
631#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
632#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
633#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
634
635#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
636#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
637#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
638#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
639/*! @} */
640
641/*! @defgroup gamepad_axes Gamepad axes
642 * @brief Gamepad axes.
643 *
644 * See @ref gamepad for how these are used.
645 *
646 * @ingroup input
647 * @{ */
648#define GLFW_GAMEPAD_AXIS_LEFT_X 0
649#define GLFW_GAMEPAD_AXIS_LEFT_Y 1
650#define GLFW_GAMEPAD_AXIS_RIGHT_X 2
651#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
652#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
653#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
654#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
655/*! @} */
656
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100657/*! @defgroup errors Error codes
Camilla Löwy21eabd32017-02-06 17:31:25 +0100658 * @brief Error codes.
Camilla Berglund4188c262015-01-18 01:55:25 +0100659 *
660 * See [error handling](@ref error_handling) for how these are used.
661 *
Camilla Berglund4591ad22014-09-18 15:03:29 +0200662 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100663 * @{ */
Camilla Löwy63506412017-05-01 19:20:57 +0200664/*! @brief No error has occurred.
665 *
666 * No error has occurred.
667 *
668 * @analysis Yay.
669 */
670#define GLFW_NO_ERROR 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100671/*! @brief GLFW has not been initialized.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200672 *
Camilla Berglund0df4e062015-12-13 14:07:27 +0100673 * This occurs if a GLFW function was called that must not be called unless the
Camilla Berglund4591ad22014-09-18 15:03:29 +0200674 * library is [initialized](@ref intro_init).
675 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100676 * @analysis Application programmer error. Initialize GLFW before calling any
677 * function that requires initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100678 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200679#define GLFW_NOT_INITIALIZED 0x00010001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100680/*! @brief No context is current for this thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200681 *
682 * This occurs if a GLFW function was called that needs and operates on the
683 * current OpenGL or OpenGL ES context but no context is current on the calling
684 * thread. One such function is @ref glfwSwapInterval.
685 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100686 * @analysis Application programmer error. Ensure a context is current before
687 * calling functions that require a current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100688 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200689#define GLFW_NO_CURRENT_CONTEXT 0x00010002
Camilla Berglund4591ad22014-09-18 15:03:29 +0200690/*! @brief One of the arguments to the function was an invalid enum value.
691 *
692 * One of the arguments to the function was an invalid enum value, for example
Camilla Löwyce161c22016-12-06 01:14:23 +0100693 * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200694 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100695 * @analysis Application programmer error. Fix the offending call.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100696 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200697#define GLFW_INVALID_ENUM 0x00010003
Camilla Berglund4591ad22014-09-18 15:03:29 +0200698/*! @brief One of the arguments to the function was an invalid value.
699 *
700 * One of the arguments to the function was an invalid value, for example
701 * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
702 *
703 * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
704 * result in a @ref GLFW_VERSION_UNAVAILABLE error.
705 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100706 * @analysis Application programmer error. Fix the offending call.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100707 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200708#define GLFW_INVALID_VALUE 0x00010004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100709/*! @brief A memory allocation failed.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200710 *
711 * A memory allocation failed.
712 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100713 * @analysis A bug in GLFW or the underlying operating system. Report the bug
714 * to our [issue tracker](https://github.com/glfw/glfw/issues).
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100715 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200716#define GLFW_OUT_OF_MEMORY 0x00010005
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200717/*! @brief GLFW could not find support for the requested API on the system.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200718 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200719 * GLFW could not find support for the requested API on the system.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200720 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100721 * @analysis The installed graphics driver does not support the requested
Camilla Löwy56a4cb02021-07-13 21:50:09 +0200722 * API, or does not support it via the chosen context creation API.
Camilla Berglund951a9582016-01-31 21:32:14 +0100723 * Below are a few examples.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200724 *
725 * @par
726 * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
Camilla Berglundd95b79f2015-03-30 23:20:49 +0200727 * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
Camilla Berglund8d6f2652016-10-20 00:50:54 +0200728 * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
Camilla Berglund138feb82015-01-05 16:46:04 +0100729 * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200730 * driver. Older graphics drivers do not support Vulkan.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100731 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200732#define GLFW_API_UNAVAILABLE 0x00010006
Camilla Berglund4591ad22014-09-18 15:03:29 +0200733/*! @brief The requested OpenGL or OpenGL ES version is not available.
734 *
Camilla Berglundd493a822015-03-10 19:51:14 +0100735 * The requested OpenGL or OpenGL ES version (including any requested context
736 * or framebuffer hints) is not available on this machine.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200737 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100738 * @analysis The machine does not support your requirements. If your
739 * application is sufficiently flexible, downgrade your requirements and try
740 * again. Otherwise, inform the user that their machine does not match your
Camilla Berglund4591ad22014-09-18 15:03:29 +0200741 * requirements.
742 *
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200743 * @par
744 * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
745 * comes out before the 4.x series gets that far, also fail with this error and
746 * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
747 * will exist.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100748 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200749#define GLFW_VERSION_UNAVAILABLE 0x00010007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100750/*! @brief A platform-specific error occurred that does not match any of the
751 * more specific categories.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200752 *
753 * A platform-specific error occurred that does not match any of the more
754 * specific categories.
755 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100756 * @analysis A bug or configuration error in GLFW, the underlying operating
757 * system or its drivers, or a lack of required resources. Report the issue to
758 * our [issue tracker](https://github.com/glfw/glfw/issues).
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100759 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200760#define GLFW_PLATFORM_ERROR 0x00010008
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200761/*! @brief The requested format is not supported or available.
762 *
763 * If emitted during window creation, the requested pixel format is not
764 * supported.
765 *
766 * If emitted when querying the clipboard, the contents of the clipboard could
767 * not be converted to the requested format.
768 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100769 * @analysis If emitted during window creation, one or more
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200770 * [hard constraints](@ref window_hints_hard) did not match any of the
771 * available pixel formats. If your application is sufficiently flexible,
772 * downgrade your requirements and try again. Otherwise, inform the user that
773 * their machine does not match your requirements.
774 *
775 * @par
776 * If emitted when querying the clipboard, ignore the error or report it to
777 * the user, as appropriate.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100778 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200779#define GLFW_FORMAT_UNAVAILABLE 0x00010009
Camilla Berglund496f5592015-06-18 14:03:02 +0200780/*! @brief The specified window does not have an OpenGL or OpenGL ES context.
781 *
782 * A window that does not have an OpenGL or OpenGL ES context was passed to
783 * a function that requires it to have one.
784 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100785 * @analysis Application programmer error. Fix the offending call.
Camilla Berglund496f5592015-06-18 14:03:02 +0200786 */
787#define GLFW_NO_WINDOW_CONTEXT 0x0001000A
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +0200788/*! @brief The specified cursor shape is not available.
789 *
790 * The specified standard cursor shape is not available, either because the
Camilla Löwy56a4cb02021-07-13 21:50:09 +0200791 * current platform cursor theme does not provide it or because it is not
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +0200792 * available on the platform.
793 *
794 * @analysis Platform or system settings limitation. Pick another
795 * [standard cursor shape](@ref shapes) or create a
796 * [custom cursor](@ref cursor_custom).
797 */
798#define GLFW_CURSOR_UNAVAILABLE 0x0001000B
Luflosib66f1052020-06-23 16:20:27 +0200799/*! @brief The requested feature is not provided by the platform.
Camilla Löwy9a87c2a2020-05-20 18:02:58 +0200800 *
801 * The requested feature is not provided by the platform, so GLFW is unable to
802 * implement it. The documentation for each function notes if it could emit
803 * this error.
804 *
805 * @analysis Platform or platform version limitation. The error can be ignored
806 * unless the feature is critical to the application.
807 *
808 * @par
809 * A function call that emits this error has no effect other than the error and
810 * updating any existing out parameters.
811 */
812#define GLFW_FEATURE_UNAVAILABLE 0x0001000C
813/*! @brief The requested feature is not implemented for the platform.
814 *
815 * The requested feature has not yet been implemented in GLFW for this platform.
816 *
817 * @analysis An incomplete implementation of GLFW for this platform, hopefully
818 * fixed in a future release. The error can be ignored unless the feature is
819 * critical to the application.
820 *
821 * @par
822 * A function call that emits this error has no effect other than the error and
823 * updating any existing out parameters.
824 */
825#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
Camilla Löwy56a4cb02021-07-13 21:50:09 +0200826/*! @brief Platform unavailable or no matching platform was found.
827 *
828 * If emitted during initialization, no matching platform was found. If @ref
829 * GLFW_PLATFORM is set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of the
830 * platforms supported by this library binary, except for the Null platform. If set to
831 * a specific platform, it is either not supported by this library binary or GLFW was not
832 * able to detect it.
833 *
834 * If emitted by a native access function, GLFW was initialized for a different platform
835 * than the function is for.
836 *
837 * @analysis Failure to detect any platform usually only happens on non-macOS Unix
838 * systems, either when no window system is running or the program was run from
839 * a terminal that does not have the necessary environment variables. Fall back to
840 * a different platform if possible or notify the user that no usable platform was
841 * detected.
842 *
843 * Failure to detect a specific platform may have the same cause as above or be because
844 * support for that platform was not compiled in. Call @ref glfwPlatformSupported to
845 * check whether a specific platform is supported by a library binary.
846 */
847#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100848/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200849
Camilla Löwyce161c22016-12-06 01:14:23 +0100850/*! @addtogroup window
851 * @{ */
852/*! @brief Input focus window hint and attribute
853 *
854 * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
855 * [window attribute](@ref GLFW_FOCUSED_attrib).
856 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100857#define GLFW_FOCUSED 0x00020001
Camilla Löwyce161c22016-12-06 01:14:23 +0100858/*! @brief Window iconification window attribute
859 *
860 * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
861 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100862#define GLFW_ICONIFIED 0x00020002
Camilla Löwyce161c22016-12-06 01:14:23 +0100863/*! @brief Window resize-ability window hint and attribute
864 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100865 * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100866 * [window attribute](@ref GLFW_RESIZABLE_attrib).
867 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200868#define GLFW_RESIZABLE 0x00020003
Camilla Löwyce161c22016-12-06 01:14:23 +0100869/*! @brief Window visibility window hint and attribute
870 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100871 * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100872 * [window attribute](@ref GLFW_VISIBLE_attrib).
873 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200874#define GLFW_VISIBLE 0x00020004
Camilla Löwyce161c22016-12-06 01:14:23 +0100875/*! @brief Window decoration window hint and attribute
876 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100877 * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100878 * [window attribute](@ref GLFW_DECORATED_attrib).
879 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200880#define GLFW_DECORATED 0x00020005
Camilla Löwy9e560992016-09-30 01:52:22 +0200881/*! @brief Window auto-iconification window hint and attribute
Camilla Löwyce161c22016-12-06 01:14:23 +0100882 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100883 * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
Camilla Löwy9e560992016-09-30 01:52:22 +0200884 * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
Camilla Löwyce161c22016-12-06 01:14:23 +0100885 */
Camilla Berglund25e7ff12014-04-08 15:32:34 +0200886#define GLFW_AUTO_ICONIFY 0x00020006
Camilla Löwyce161c22016-12-06 01:14:23 +0100887/*! @brief Window decoration window hint and attribute
888 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100889 * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100890 * [window attribute](@ref GLFW_FLOATING_attrib).
891 */
Camilla Berglund3ce7bfe2014-05-23 14:01:02 +0200892#define GLFW_FLOATING 0x00020007
Camilla Löwyce161c22016-12-06 01:14:23 +0100893/*! @brief Window maximization window hint and attribute
894 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100895 * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100896 * [window attribute](@ref GLFW_MAXIMIZED_attrib).
897 */
Camilla Berglunda10caa42015-10-13 12:50:59 +0200898#define GLFW_MAXIMIZED 0x00020008
Camilla Löwy5a74b502017-02-06 15:03:50 +0100899/*! @brief Cursor centering window hint
900 *
901 * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
902 */
Liam Middlebrook72ac5ba2016-08-18 11:47:54 -0400903#define GLFW_CENTER_CURSOR 0x00020009
Camilla Löwy32e78ae2017-09-18 18:10:57 +0200904/*! @brief Window framebuffer transparency hint and attribute
905 *
Camilla Löwy49130ab2017-11-07 22:50:01 +0100906 * Window framebuffer transparency
907 * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
908 * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
Camilla Löwy32e78ae2017-09-18 18:10:57 +0200909 */
Camilla Löwy49130ab2017-11-07 22:50:01 +0100910#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
Camilla Löwyd6b3a602018-01-11 14:13:54 +0100911/*! @brief Mouse cursor hover window attribute.
912 *
913 * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
914 */
Camilla Löwyee9dffc2018-01-04 13:50:58 +0100915#define GLFW_HOVERED 0x0002000B
Doug Binks0be4f3f2018-05-29 14:51:36 +0100916/*! @brief Input focus on calling show window hint and attribute
917 *
918 * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
919 * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
920 */
921#define GLFW_FOCUS_ON_SHOW 0x0002000C
Camilla Berglund2c091572010-09-09 21:09:11 +0200922
Camilla Löwya122d912020-07-08 23:21:28 +0200923/*! @brief Mouse input transparency window hint and attribute
Rokas Kupstysd285a9f2019-09-30 15:44:43 +0300924 *
Camilla Löwya122d912020-07-08 23:21:28 +0200925 * Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or
Rokas Kupstysd285a9f2019-09-30 15:44:43 +0300926 * [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
927 */
928#define GLFW_MOUSE_PASSTHROUGH 0x0002000D
929
Camilla Löwy0f9a9572021-10-26 14:25:03 +0200930/*! @brief Initial position x-coordinate window hint.
931 *
932 * Initial position x-coordinate [window hint](@ref GLFW_POSITION_X).
933 */
934#define GLFW_POSITION_X 0x0002000E
935
936/*! @brief Initial position y-coordinate window hint.
937 *
938 * Initial position y-coordinate [window hint](@ref GLFW_POSITION_Y).
939 */
940#define GLFW_POSITION_Y 0x0002000F
941
Camilla Löwyce161c22016-12-06 01:14:23 +0100942/*! @brief Framebuffer bit depth hint.
943 *
944 * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
945 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200946#define GLFW_RED_BITS 0x00021001
Camilla Löwyce161c22016-12-06 01:14:23 +0100947/*! @brief Framebuffer bit depth hint.
948 *
949 * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
950 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200951#define GLFW_GREEN_BITS 0x00021002
Camilla Löwyce161c22016-12-06 01:14:23 +0100952/*! @brief Framebuffer bit depth hint.
953 *
954 * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
955 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200956#define GLFW_BLUE_BITS 0x00021003
Camilla Löwyce161c22016-12-06 01:14:23 +0100957/*! @brief Framebuffer bit depth hint.
958 *
959 * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
960 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200961#define GLFW_ALPHA_BITS 0x00021004
Camilla Löwyce161c22016-12-06 01:14:23 +0100962/*! @brief Framebuffer bit depth hint.
963 *
964 * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
965 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200966#define GLFW_DEPTH_BITS 0x00021005
Camilla Löwyce161c22016-12-06 01:14:23 +0100967/*! @brief Framebuffer bit depth hint.
968 *
969 * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
970 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200971#define GLFW_STENCIL_BITS 0x00021006
Camilla Löwyce161c22016-12-06 01:14:23 +0100972/*! @brief Framebuffer bit depth hint.
973 *
974 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
975 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200976#define GLFW_ACCUM_RED_BITS 0x00021007
Camilla Löwyce161c22016-12-06 01:14:23 +0100977/*! @brief Framebuffer bit depth hint.
978 *
979 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
980 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200981#define GLFW_ACCUM_GREEN_BITS 0x00021008
Camilla Löwyce161c22016-12-06 01:14:23 +0100982/*! @brief Framebuffer bit depth hint.
983 *
984 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
985 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200986#define GLFW_ACCUM_BLUE_BITS 0x00021009
Camilla Löwyce161c22016-12-06 01:14:23 +0100987/*! @brief Framebuffer bit depth hint.
988 *
989 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
990 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200991#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
Camilla Löwyce161c22016-12-06 01:14:23 +0100992/*! @brief Framebuffer auxiliary buffer hint.
993 *
994 * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
995 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200996#define GLFW_AUX_BUFFERS 0x0002100B
Camilla Löwyce161c22016-12-06 01:14:23 +0100997/*! @brief OpenGL stereoscopic rendering hint.
998 *
999 * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
1000 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001001#define GLFW_STEREO 0x0002100C
Camilla Löwyce161c22016-12-06 01:14:23 +01001002/*! @brief Framebuffer MSAA samples hint.
1003 *
1004 * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
1005 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001006#define GLFW_SAMPLES 0x0002100D
Camilla Löwyce161c22016-12-06 01:14:23 +01001007/*! @brief Framebuffer sRGB hint.
1008 *
1009 * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
1010 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001011#define GLFW_SRGB_CAPABLE 0x0002100E
Camilla Löwyce161c22016-12-06 01:14:23 +01001012/*! @brief Monitor refresh rate hint.
1013 *
1014 * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
1015 */
Camilla Berglund2cd34382013-05-30 20:42:50 +02001016#define GLFW_REFRESH_RATE 0x0002100F
Camilla Löwy04f21ab2021-05-13 21:38:46 +02001017/*! @brief Framebuffer double buffering hint and attribute.
Camilla Löwyce161c22016-12-06 01:14:23 +01001018 *
Camilla Löwy04f21ab2021-05-13 21:38:46 +02001019 * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
1020 * [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
Camilla Löwyce161c22016-12-06 01:14:23 +01001021 */
Camilla Berglundc9808582014-04-24 19:21:10 +02001022#define GLFW_DOUBLEBUFFER 0x00021010
Bailey Cosier93e66662017-09-19 18:27:45 +02001023
Camilla Löwy831426c2016-12-08 17:08:36 +01001024/*! @brief Context client API hint and attribute.
1025 *
1026 * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
1027 * [attribute](@ref GLFW_CLIENT_API_attrib).
1028 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001029#define GLFW_CLIENT_API 0x00022001
Camilla Löwy831426c2016-12-08 17:08:36 +01001030/*! @brief Context client API major version hint and attribute.
1031 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001032 * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint)
1033 * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001034 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001035#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
Camilla Löwy831426c2016-12-08 17:08:36 +01001036/*! @brief Context client API minor version hint and attribute.
1037 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001038 * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint)
1039 * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001040 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001041#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
Stephen Gutekanst37fc28b2021-11-15 15:50:37 -07001042/*! @brief Context client API revision number attribute.
Camilla Löwy831426c2016-12-08 17:08:36 +01001043 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001044 * Context client API revision number
1045 * [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001046 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001047#define GLFW_CONTEXT_REVISION 0x00022004
Camilla Löwy831426c2016-12-08 17:08:36 +01001048/*! @brief Context robustness hint and attribute.
1049 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001050 * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint)
1051 * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001052 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001053#define GLFW_CONTEXT_ROBUSTNESS 0x00022005
Camilla Löwy831426c2016-12-08 17:08:36 +01001054/*! @brief OpenGL forward-compatibility hint and attribute.
1055 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001056 * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
1057 * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001058 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001059#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
Camilla Löwy4e3b4332020-06-28 19:21:36 +02001060/*! @brief Debug mode context hint and attribute.
Camilla Löwy831426c2016-12-08 17:08:36 +01001061 *
Camilla Löwyb420ca72020-06-26 18:35:48 +02001062 * Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and
1063 * [attribute](@ref GLFW_CONTEXT_DEBUG_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001064 */
Camilla Löwyb420ca72020-06-26 18:35:48 +02001065#define GLFW_CONTEXT_DEBUG 0x00022007
1066/*! @brief Legacy name for compatibility.
1067 *
1068 * This is an alias for compatibility with earlier versions.
1069 */
1070#define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG
Camilla Löwy831426c2016-12-08 17:08:36 +01001071/*! @brief OpenGL profile hint and attribute.
1072 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001073 * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
1074 * [attribute](@ref GLFW_OPENGL_PROFILE_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001075 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001076#define GLFW_OPENGL_PROFILE 0x00022008
Camilla Löwy831426c2016-12-08 17:08:36 +01001077/*! @brief Context flush-on-release hint and attribute.
1078 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001079 * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and
1080 * [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001081 */
Camilla Berglund44c899c2014-08-21 19:21:45 +02001082#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
Camilla Löwy831426c2016-12-08 17:08:36 +01001083/*! @brief Context error suppression hint and attribute.
1084 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001085 * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and
1086 * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001087 */
Camilla Berglund7be82092015-08-10 12:46:14 +02001088#define GLFW_CONTEXT_NO_ERROR 0x0002200A
Camilla Löwy831426c2016-12-08 17:08:36 +01001089/*! @brief Context creation API hint and attribute.
1090 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001091 * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and
1092 * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001093 */
Camilla Berglundef80bea2016-03-28 13:19:31 +02001094#define GLFW_CONTEXT_CREATION_API 0x0002200B
Camilla Löwy089ea9a2018-08-31 13:33:48 +02001095/*! @brief Window content area scaling window
1096 * [window hint](@ref GLFW_SCALE_TO_MONITOR).
1097 */
1098#define GLFW_SCALE_TO_MONITOR 0x0002200C
Camilla Löwy422bf792019-04-01 18:36:30 +02001099/*! @brief macOS specific
1100 * [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint).
1101 */
Camilla Löwy58ceab52016-12-07 00:41:54 +01001102#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
Camilla Löwy422bf792019-04-01 18:36:30 +02001103/*! @brief macOS specific
1104 * [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
1105 */
Camilla Löwy9da22852017-12-12 16:45:38 +01001106#define GLFW_COCOA_FRAME_NAME 0x00023002
Camilla Löwy422bf792019-04-01 18:36:30 +02001107/*! @brief macOS specific
1108 * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint).
1109 */
Camilla Löwy77a8f102017-01-27 12:02:09 +01001110#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
Camilla Löwy422bf792019-04-01 18:36:30 +02001111/*! @brief X11 specific
1112 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1113 */
Camilla Löwy61588012017-12-12 10:54:18 +01001114#define GLFW_X11_CLASS_NAME 0x00024001
Camilla Löwy422bf792019-04-01 18:36:30 +02001115/*! @brief X11 specific
1116 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1117 */
Camilla Löwy61588012017-12-12 10:54:18 +01001118#define GLFW_X11_INSTANCE_NAME 0x00024002
Camilla Löwy8e288dc2019-08-20 19:00:59 +02001119#define GLFW_WIN32_KEYBOARD_MENU 0x00025001
Michael Penningtonb9ed25d2022-05-26 20:33:28 -04001120/*! @brief Wayland specific
1121 * [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
1122 *
1123 * Allows specification of the Wayland app_id.
1124 */
1125#define GLFW_WAYLAND_APP_ID 0x00026001
Camilla Löwy831426c2016-12-08 17:08:36 +01001126/*! @} */
Camilla Löwy58ceab52016-12-07 00:41:54 +01001127
Camilla Berglund496f5592015-06-18 14:03:02 +02001128#define GLFW_NO_API 0
Camilla Berglund393e4392013-05-27 22:16:59 +02001129#define GLFW_OPENGL_API 0x00030001
1130#define GLFW_OPENGL_ES_API 0x00030002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001131
Camilla Berglund393e4392013-05-27 22:16:59 +02001132#define GLFW_NO_ROBUSTNESS 0
1133#define GLFW_NO_RESET_NOTIFICATION 0x00031001
1134#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001135
Camilla Berglund44e84012013-06-05 16:13:30 +02001136#define GLFW_OPENGL_ANY_PROFILE 0
Camilla Berglund393e4392013-05-27 22:16:59 +02001137#define GLFW_OPENGL_CORE_PROFILE 0x00032001
1138#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001139
Camilla Berglund393e4392013-05-27 22:16:59 +02001140#define GLFW_CURSOR 0x00033001
1141#define GLFW_STICKY_KEYS 0x00033002
1142#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01001143#define GLFW_LOCK_KEY_MODS 0x00033004
Camilla Löwy1155c832019-02-11 19:10:20 +01001144#define GLFW_RAW_MOUSE_MOTION 0x00033005
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001145
Camilla Berglund393e4392013-05-27 22:16:59 +02001146#define GLFW_CURSOR_NORMAL 0x00034001
1147#define GLFW_CURSOR_HIDDEN 0x00034002
1148#define GLFW_CURSOR_DISABLED 0x00034003
Camilla Löwy488008e2019-12-03 17:58:20 +01001149#define GLFW_CURSOR_CAPTURED 0x00034004
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001150
Camilla Berglund44c899c2014-08-21 19:21:45 +02001151#define GLFW_ANY_RELEASE_BEHAVIOR 0
1152#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
1153#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
1154
Camilla Berglundef80bea2016-03-28 13:19:31 +02001155#define GLFW_NATIVE_CONTEXT_API 0x00036001
1156#define GLFW_EGL_CONTEXT_API 0x00036002
Camilla Löwye9560ef2017-02-28 19:23:25 +01001157#define GLFW_OSMESA_CONTEXT_API 0x00036003
Camilla Berglundef80bea2016-03-28 13:19:31 +02001158
Camilla Löwy0dea8a42020-06-25 18:22:08 +02001159#define GLFW_ANGLE_PLATFORM_TYPE_NONE 0x00037001
1160#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL 0x00037002
1161#define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
1162#define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004
1163#define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005
1164#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007
1165#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008
1166
Camilla Löwy0f9a9572021-10-26 14:25:03 +02001167#define GLFW_ANY_POSITION 0x80000000
1168
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001169/*! @defgroup shapes Standard cursor shapes
Camilla Löwy21eabd32017-02-06 17:31:25 +01001170 * @brief Standard system cursor shapes.
Camilla Berglund4188c262015-01-18 01:55:25 +01001171 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001172 * These are the [standard cursor shapes](@ref cursor_standard) that can be
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001173 * requested from the platform (window system).
Camilla Berglund4188c262015-01-18 01:55:25 +01001174 *
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001175 * @ingroup input
1176 * @{ */
1177
1178/*! @brief The regular arrow cursor shape.
1179 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001180 * The regular arrow cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001181 */
1182#define GLFW_ARROW_CURSOR 0x00036001
1183/*! @brief The text input I-beam cursor shape.
1184 *
1185 * The text input I-beam cursor shape.
1186 */
1187#define GLFW_IBEAM_CURSOR 0x00036002
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001188/*! @brief The crosshair cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001189 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001190 * The crosshair cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001191 */
1192#define GLFW_CROSSHAIR_CURSOR 0x00036003
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001193/*! @brief The pointing hand cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001194 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001195 * The pointing hand cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001196 */
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001197#define GLFW_POINTING_HAND_CURSOR 0x00036004
1198/*! @brief The horizontal resize/move arrow shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001199 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001200 * The horizontal resize/move arrow shape. This is usually a horizontal
1201 * double-headed arrow.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001202 */
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001203#define GLFW_RESIZE_EW_CURSOR 0x00036005
1204/*! @brief The vertical resize/move arrow shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001205 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001206 * The vertical resize/move shape. This is usually a vertical double-headed
1207 * arrow.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001208 */
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001209#define GLFW_RESIZE_NS_CURSOR 0x00036006
1210/*! @brief The top-left to bottom-right diagonal resize/move arrow shape.
1211 *
1212 * The top-left to bottom-right diagonal resize/move shape. This is usually
1213 * a diagonal double-headed arrow.
1214 *
1215 * @note @macos This shape is provided by a private system API and may fail
1216 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1217 *
1218 * @note @x11 This shape is provided by a newer standard not supported by all
1219 * cursor themes.
1220 *
1221 * @note @wayland This shape is provided by a newer standard not supported by
1222 * all cursor themes.
1223 */
1224#define GLFW_RESIZE_NWSE_CURSOR 0x00036007
1225/*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
1226 *
1227 * The top-right to bottom-left diagonal resize/move shape. This is usually
1228 * a diagonal double-headed arrow.
1229 *
1230 * @note @macos This shape is provided by a private system API and may fail
1231 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1232 *
1233 * @note @x11 This shape is provided by a newer standard not supported by all
1234 * cursor themes.
1235 *
1236 * @note @wayland This shape is provided by a newer standard not supported by
1237 * all cursor themes.
1238 */
1239#define GLFW_RESIZE_NESW_CURSOR 0x00036008
1240/*! @brief The omni-directional resize/move cursor shape.
1241 *
1242 * The omni-directional resize cursor/move shape. This is usually either
1243 * a combined horizontal and vertical double-headed arrow or a grabbing hand.
1244 */
1245#define GLFW_RESIZE_ALL_CURSOR 0x00036009
1246/*! @brief The operation-not-allowed shape.
1247 *
1248 * The operation-not-allowed shape. This is usually a circle with a diagonal
1249 * line through it.
1250 *
1251 * @note @x11 This shape is provided by a newer standard not supported by all
1252 * cursor themes.
1253 *
1254 * @note @wayland This shape is provided by a newer standard not supported by
1255 * all cursor themes.
1256 */
1257#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
1258/*! @brief Legacy name for compatibility.
1259 *
1260 * This is an alias for compatibility with earlier versions.
1261 */
1262#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR
1263/*! @brief Legacy name for compatibility.
1264 *
1265 * This is an alias for compatibility with earlier versions.
1266 */
1267#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR
1268/*! @brief Legacy name for compatibility.
1269 *
1270 * This is an alias for compatibility with earlier versions.
1271 */
1272#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001273/*! @} */
1274
Camilla Berglund393e4392013-05-27 22:16:59 +02001275#define GLFW_CONNECTED 0x00040001
1276#define GLFW_DISCONNECTED 0x00040002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001277
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001278/*! @addtogroup init
1279 * @{ */
Camilla Löwy04116782018-11-05 17:37:49 +01001280/*! @brief Joystick hat buttons init hint.
1281 *
Camilla Löwy422bf792019-04-01 18:36:30 +02001282 * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
Camilla Löwy04116782018-11-05 17:37:49 +01001283 */
Camilla Löwy798d7c62017-03-01 23:27:20 +01001284#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
Camilla Löwy0dea8a42020-06-25 18:22:08 +02001285/*! @brief ANGLE rendering backend init hint.
1286 *
1287 * ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
1288 */
1289#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001290/*! @brief Platform selection init hint.
1291 *
1292 * Platform selection [init hint](@ref GLFW_PLATFORM).
1293 */
1294#define GLFW_PLATFORM 0x00050003
Camilla Löwy04116782018-11-05 17:37:49 +01001295/*! @brief macOS specific init hint.
1296 *
Camilla Löwy422bf792019-04-01 18:36:30 +02001297 * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
Camilla Löwy04116782018-11-05 17:37:49 +01001298 */
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001299#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
Camilla Löwy04116782018-11-05 17:37:49 +01001300/*! @brief macOS specific init hint.
1301 *
Camilla Löwy422bf792019-04-01 18:36:30 +02001302 * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
Camilla Löwy04116782018-11-05 17:37:49 +01001303 */
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001304#define GLFW_COCOA_MENUBAR 0x00051002
Nicolas Caramelli84f95a72020-10-23 18:55:37 +02001305/*! @brief X11 specific init hint.
1306 *
1307 * X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
1308 */
1309#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001310/*! @} */
1311
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001312/*! @addtogroup init
1313 * @{ */
1314/*! @brief Hint value that enables automatic platform selection.
1315 *
1316 * Hint value for @ref GLFW_PLATFORM that enables automatic platform selection.
1317 */
1318#define GLFW_ANY_PLATFORM 0x00060000
1319#define GLFW_PLATFORM_WIN32 0x00060001
1320#define GLFW_PLATFORM_COCOA 0x00060002
1321#define GLFW_PLATFORM_WAYLAND 0x00060003
1322#define GLFW_PLATFORM_X11 0x00060004
1323#define GLFW_PLATFORM_NULL 0x00060005
1324/*! @} */
1325
Camilla Berglund28101302014-04-08 18:57:43 +02001326#define GLFW_DONT_CARE -1
1327
Camilla Berglund97387282011-10-06 23:28:56 +02001328
Camilla Berglund3249f812010-09-07 17:34:51 +02001329/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001330 * GLFW API types
Camilla Berglund3249f812010-09-07 17:34:51 +02001331 *************************************************************************/
1332
Camilla Berglund3f5843f2012-12-13 02:22:39 +01001333/*! @brief Client API function pointer type.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001334 *
1335 * Generic function pointer used for returning client API function pointers
1336 * without forcing a cast from a regular pointer.
1337 *
Camilla Berglundbce20c32015-11-05 13:58:52 +01001338 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001339 * @sa @ref glfwGetProcAddress
Camilla Berglundbce20c32015-11-05 13:58:52 +01001340 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001341 * @since Added in version 3.0.
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00001342 *
Camilla Berglund3f5843f2012-12-13 02:22:39 +01001343 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001344 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02001345typedef void (*GLFWglproc)(void);
1346
Camilla Berglund9b75bff2015-08-10 20:19:04 +02001347/*! @brief Vulkan API function pointer type.
1348 *
1349 * Generic function pointer used for returning Vulkan API function pointers
1350 * without forcing a cast from a regular pointer.
1351 *
1352 * @sa @ref vulkan_proc
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001353 * @sa @ref glfwGetInstanceProcAddress
Camilla Berglund9b75bff2015-08-10 20:19:04 +02001354 *
1355 * @since Added in version 3.2.
1356 *
1357 * @ingroup vulkan
1358 */
1359typedef void (*GLFWvkproc)(void);
1360
Camilla Berglunddba2d802013-01-17 23:06:56 +01001361/*! @brief Opaque monitor object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001362 *
1363 * Opaque monitor object.
1364 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001365 * @see @ref monitor_object
1366 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001367 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001368 *
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001369 * @ingroup monitor
1370 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001371typedef struct GLFWmonitor GLFWmonitor;
Camilla Berglunde0ce9202012-08-29 20:39:05 +02001372
Camilla Berglunddba2d802013-01-17 23:06:56 +01001373/*! @brief Opaque window object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001374 *
1375 * Opaque window object.
1376 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001377 * @see @ref window_object
1378 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001379 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001380 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001381 * @ingroup window
1382 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001383typedef struct GLFWwindow GLFWwindow;
Camilla Berglund135194a2010-09-09 18:15:32 +02001384
urraka40c04a72013-12-04 10:19:22 -03001385/*! @brief Opaque cursor object.
1386 *
1387 * Opaque cursor object.
1388 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001389 * @see @ref cursor_object
1390 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001391 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001392 *
Camilla Löwy04116782018-11-05 17:37:49 +01001393 * @ingroup input
urraka40c04a72013-12-04 10:19:22 -03001394 */
1395typedef struct GLFWcursor GLFWcursor;
1396
Camilla Löwy22b586b2021-08-03 20:53:48 +02001397/*! @brief The function pointer type for memory allocation callbacks.
1398 *
1399 * This is the function pointer type for memory allocation callbacks. A memory
1400 * allocation callback function has the following signature:
1401 * @code
1402 * void* function_name(size_t size, void* user)
1403 * @endcode
1404 *
1405 * This function must return either a memory block at least `size` bytes long,
1406 * or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
1407 * failures gracefully yet.
1408 *
1409 * This function may be called during @ref glfwInit but before the library is
1410 * flagged as initialized, as well as during @ref glfwTerminate after the
1411 * library is no longer flagged as initialized.
1412 *
1413 * Any memory allocated by this function will be deallocated during library
1414 * termination or earlier.
1415 *
1416 * The size will always be greater than zero. Allocations of size zero are filtered out
1417 * before reaching the custom allocator.
1418 *
1419 * @param[in] size The minimum size, in bytes, of the memory block.
1420 * @param[in] user The user-defined pointer from the allocator.
1421 * @return The address of the newly allocated memory block, or `NULL` if an
1422 * error occurred.
1423 *
1424 * @pointer_lifetime The returned memory block must be valid at least until it
1425 * is deallocated.
1426 *
1427 * @reentrancy This function should not call any GLFW function.
1428 *
1429 * @thread_safety This function may be called from any thread that calls GLFW functions.
1430 *
1431 * @sa @ref init_allocator
1432 * @sa @ref GLFWallocator
1433 *
1434 * @since Added in version 3.4.
1435 *
1436 * @ingroup init
1437 */
1438typedef void* (* GLFWallocatefun)(size_t size, void* user);
1439
1440/*! @brief The function pointer type for memory reallocation callbacks.
1441 *
1442 * This is the function pointer type for memory reallocation callbacks.
1443 * A memory reallocation callback function has the following signature:
1444 * @code
1445 * void* function_name(void* block, size_t size, void* user)
1446 * @endcode
1447 *
1448 * This function must return a memory block at least `size` bytes long, or
1449 * `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
1450 * failures gracefully yet.
1451 *
1452 * This function may be called during @ref glfwInit but before the library is
1453 * flagged as initialized, as well as during @ref glfwTerminate after the
1454 * library is no longer flagged as initialized.
1455 *
1456 * Any memory allocated by this function will be deallocated during library
1457 * termination or earlier.
1458 *
1459 * The block address will never be `NULL` and the size will always be greater than zero.
1460 * Reallocations of a block to size zero are converted into deallocations. Reallocations
1461 * of `NULL` to a non-zero size are converted into regular allocations.
1462 *
1463 * @param[in] block The address of the memory block to reallocate.
1464 * @param[in] size The new minimum size, in bytes, of the memory block.
1465 * @param[in] user The user-defined pointer from the allocator.
1466 * @return The address of the newly allocated or resized memory block, or
1467 * `NULL` if an error occurred.
1468 *
1469 * @pointer_lifetime The returned memory block must be valid at least until it
1470 * is deallocated.
1471 *
1472 * @reentrancy This function should not call any GLFW function.
1473 *
1474 * @thread_safety This function may be called from any thread that calls GLFW functions.
1475 *
1476 * @sa @ref init_allocator
1477 * @sa @ref GLFWallocator
1478 *
1479 * @since Added in version 3.4.
1480 *
1481 * @ingroup init
1482 */
1483typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
1484
1485/*! @brief The function pointer type for memory deallocation callbacks.
1486 *
1487 * This is the function pointer type for memory deallocation callbacks.
1488 * A memory deallocation callback function has the following signature:
1489 * @code
1490 * void function_name(void* block, void* user)
1491 * @endcode
1492 *
1493 * This function may deallocate the specified memory block. This memory block
1494 * will have been allocated with the same allocator.
1495 *
1496 * This function may be called during @ref glfwInit but before the library is
1497 * flagged as initialized, as well as during @ref glfwTerminate after the
1498 * library is no longer flagged as initialized.
1499 *
1500 * The block address will never be `NULL`. Deallocations of `NULL` are filtered out
1501 * before reaching the custom allocator.
1502 *
1503 * @param[in] block The address of the memory block to deallocate.
1504 * @param[in] user The user-defined pointer from the allocator.
1505 *
1506 * @pointer_lifetime The specified memory block will not be accessed by GLFW
1507 * after this function is called.
1508 *
1509 * @reentrancy This function should not call any GLFW function.
1510 *
1511 * @thread_safety This function may be called from any thread that calls GLFW functions.
1512 *
1513 * @sa @ref init_allocator
1514 * @sa @ref GLFWallocator
1515 *
1516 * @since Added in version 3.4.
1517 *
1518 * @ingroup init
1519 */
1520typedef void (* GLFWdeallocatefun)(void* block, void* user);
1521
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001522/*! @brief The function pointer type for error callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001523 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001524 * This is the function pointer type for error callbacks. An error callback
1525 * function has the following signature:
1526 * @code
1527 * void callback_name(int error_code, const char* description)
1528 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001529 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001530 * @param[in] error_code An [error code](@ref errors). Future releases may add
1531 * more error codes.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001532 * @param[in] description A UTF-8 encoded string describing the error.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001533 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001534 * @pointer_lifetime The error description string is valid until the callback
1535 * function returns.
1536 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001537 * @sa @ref error_handling
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001538 * @sa @ref glfwSetErrorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001539 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001540 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001541 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001542 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001543 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001544typedef void (* GLFWerrorfun)(int error_code, const char* description);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001545
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001546/*! @brief The function pointer type for window position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001547 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001548 * This is the function pointer type for window position callbacks. A window
1549 * position callback function has the following signature:
1550 * @code
1551 * void callback_name(GLFWwindow* window, int xpos, int ypos)
1552 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001553 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001554 * @param[in] window The window that was moved.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001555 * @param[in] xpos The new x-coordinate, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001556 * upper-left corner of the content area of the window.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001557 * @param[in] ypos The new y-coordinate, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001558 * upper-left corner of the content area of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001559 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001560 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001561 * @sa @ref glfwSetWindowPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001562 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001563 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001564 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001565 * @ingroup window
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001566 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001567typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001568
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001569/*! @brief The function pointer type for window size callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001570 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001571 * This is the function pointer type for window size callbacks. A window size
1572 * callback function has the following signature:
1573 * @code
1574 * void callback_name(GLFWwindow* window, int width, int height)
1575 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001576 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001577 * @param[in] window The window that was resized.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001578 * @param[in] width The new width, in screen coordinates, of the window.
1579 * @param[in] height The new height, in screen coordinates, of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001580 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001581 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001582 * @sa @ref glfwSetWindowSizeCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001583 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001584 * @since Added in version 1.0.
1585 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001586 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001587 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001588 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001589typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001590
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001591/*! @brief The function pointer type for window close callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001592 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001593 * This is the function pointer type for window close callbacks. A window
1594 * close callback function has the following signature:
1595 * @code
1596 * void function_name(GLFWwindow* window)
1597 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001598 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001599 * @param[in] window The window that the user attempted to close.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001600 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001601 * @sa @ref window_close
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001602 * @sa @ref glfwSetWindowCloseCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001603 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001604 * @since Added in version 2.5.
1605 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001606 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001607 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001608 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001609typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001610
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001611/*! @brief The function pointer type for window content refresh callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001612 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001613 * This is the function pointer type for window content refresh callbacks.
1614 * A window content refresh callback function has the following signature:
1615 * @code
1616 * void function_name(GLFWwindow* window);
1617 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001618 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001619 * @param[in] window The window whose content needs to be refreshed.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001620 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001621 * @sa @ref window_refresh
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001622 * @sa @ref glfwSetWindowRefreshCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001623 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001624 * @since Added in version 2.5.
1625 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001626 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001627 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001628 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001629typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001630
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001631/*! @brief The function pointer type for window focus callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001632 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001633 * This is the function pointer type for window focus callbacks. A window
1634 * focus callback function has the following signature:
1635 * @code
1636 * void function_name(GLFWwindow* window, int focused)
1637 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001638 *
Camilla Berglund4188c262015-01-18 01:55:25 +01001639 * @param[in] window The window that gained or lost input focus.
Camilla Berglund0eccf752015-08-23 19:30:04 +02001640 * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
1641 * `GLFW_FALSE` if it lost it.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001642 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001643 * @sa @ref window_focus
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001644 * @sa @ref glfwSetWindowFocusCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001645 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001646 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001647 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001648 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001649 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001650typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001651
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001652/*! @brief The function pointer type for window iconify callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001653 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001654 * This is the function pointer type for window iconify callbacks. A window
1655 * iconify callback function has the following signature:
1656 * @code
1657 * void function_name(GLFWwindow* window, int iconified)
1658 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001659 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001660 * @param[in] window The window that was iconified or restored.
Camilla Berglund0eccf752015-08-23 19:30:04 +02001661 * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
1662 * `GLFW_FALSE` if it was restored.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001663 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001664 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001665 * @sa @ref glfwSetWindowIconifyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001666 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001667 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001668 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001669 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001670 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001671typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001672
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001673/*! @brief The function pointer type for window maximize callbacks.
Camilla Berglundc156b502016-06-16 13:09:28 +02001674 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001675 * This is the function pointer type for window maximize callbacks. A window
1676 * maximize callback function has the following signature:
1677 * @code
1678 * void function_name(GLFWwindow* window, int maximized)
1679 * @endcode
Camilla Berglundc156b502016-06-16 13:09:28 +02001680 *
1681 * @param[in] window The window that was maximized or restored.
Emmanuel Gil Peyrot1ed14892020-09-07 20:19:51 +02001682 * @param[in] maximized `GLFW_TRUE` if the window was maximized, or
Camilla Berglundc156b502016-06-16 13:09:28 +02001683 * `GLFW_FALSE` if it was restored.
1684 *
1685 * @sa @ref window_maximize
1686 * @sa glfwSetWindowMaximizeCallback
1687 *
1688 * @since Added in version 3.3.
1689 *
1690 * @ingroup window
1691 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001692typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized);
Camilla Berglundc156b502016-06-16 13:09:28 +02001693
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001694/*! @brief The function pointer type for framebuffer size callbacks.
Camilla Berglund34981632013-06-03 12:51:57 +02001695 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001696 * This is the function pointer type for framebuffer size callbacks.
1697 * A framebuffer size callback function has the following signature:
1698 * @code
1699 * void function_name(GLFWwindow* window, int width, int height)
1700 * @endcode
Camilla Berglund34981632013-06-03 12:51:57 +02001701 *
1702 * @param[in] window The window whose framebuffer was resized.
1703 * @param[in] width The new width, in pixels, of the framebuffer.
1704 * @param[in] height The new height, in pixels, of the framebuffer.
1705 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001706 * @sa @ref window_fbsize
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001707 * @sa @ref glfwSetFramebufferSizeCallback
Camilla Berglund34981632013-06-03 12:51:57 +02001708 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001709 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001710 *
Camilla Berglund34981632013-06-03 12:51:57 +02001711 * @ingroup window
1712 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001713typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height);
Camilla Berglund34981632013-06-03 12:51:57 +02001714
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001715/*! @brief The function pointer type for window content scale callbacks.
Camilla Löwy370eac32017-12-11 21:26:40 +01001716 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001717 * This is the function pointer type for window content scale callbacks.
1718 * A window content scale callback function has the following signature:
1719 * @code
1720 * void function_name(GLFWwindow* window, float xscale, float yscale)
1721 * @endcode
Camilla Löwy370eac32017-12-11 21:26:40 +01001722 *
1723 * @param[in] window The window whose content scale changed.
1724 * @param[in] xscale The new x-axis content scale of the window.
1725 * @param[in] yscale The new y-axis content scale of the window.
1726 *
1727 * @sa @ref window_scale
1728 * @sa @ref glfwSetWindowContentScaleCallback
1729 *
1730 * @since Added in version 3.3.
1731 *
1732 * @ingroup window
1733 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001734typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale);
Camilla Löwy370eac32017-12-11 21:26:40 +01001735
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001736/*! @brief The function pointer type for mouse button callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001737 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001738 * This is the function pointer type for mouse button callback functions.
1739 * A mouse button callback function has the following signature:
1740 * @code
1741 * void function_name(GLFWwindow* window, int button, int action, int mods)
1742 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001743 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001744 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001745 * @param[in] button The [mouse button](@ref buttons) that was pressed or
1746 * released.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001747 * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases
1748 * may add more actions.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +02001749 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1750 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001751 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001752 * @sa @ref input_mouse_button
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001753 * @sa @ref glfwSetMouseButtonCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001754 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001755 * @since Added in version 1.0.
1756 * @glfw3 Added window handle and modifier mask parameters.
Camilla Berglund810bab72015-12-13 17:38:14 +01001757 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001758 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001759 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001760typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001761
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001762/*! @brief The function pointer type for cursor position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001763 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001764 * This is the function pointer type for cursor position callbacks. A cursor
1765 * position callback function has the following signature:
1766 * @code
1767 * void function_name(GLFWwindow* window, double xpos, double ypos);
1768 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001769 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001770 * @param[in] window The window that received the event.
Camilla Berglund95c44ab2016-02-17 14:52:01 +01001771 * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001772 * the content area.
Camilla Berglund95c44ab2016-02-17 14:52:01 +01001773 * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001774 * content area.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001775 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001776 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001777 * @sa @ref glfwSetCursorPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001778 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001779 * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
Camilla Berglund810bab72015-12-13 17:38:14 +01001780 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001781 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001782 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001783typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001784
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001785/*! @brief The function pointer type for cursor enter/leave callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001786 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001787 * This is the function pointer type for cursor enter/leave callbacks.
1788 * A cursor enter/leave callback function has the following signature:
1789 * @code
1790 * void function_name(GLFWwindow* window, int entered)
1791 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001792 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001793 * @param[in] window The window that received the event.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001794 * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
Camilla Berglund0eccf752015-08-23 19:30:04 +02001795 * area, or `GLFW_FALSE` if it left it.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001796 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001797 * @sa @ref cursor_enter
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001798 * @sa @ref glfwSetCursorEnterCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001799 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001800 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001801 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001802 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001803 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001804typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001805
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001806/*! @brief The function pointer type for scroll callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001807 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001808 * This is the function pointer type for scroll callbacks. A scroll callback
1809 * function has the following signature:
1810 * @code
1811 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
1812 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001813 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001814 * @param[in] window The window that received the event.
mewmewcf2d2602013-06-06 19:49:23 +02001815 * @param[in] xoffset The scroll offset along the x-axis.
1816 * @param[in] yoffset The scroll offset along the y-axis.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001817 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001818 * @sa @ref scrolling
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001819 * @sa @ref glfwSetScrollCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001820 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001821 * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
Camilla Berglund810bab72015-12-13 17:38:14 +01001822 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001823 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001824 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001825typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001826
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001827/*! @brief The function pointer type for keyboard key callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001828 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001829 * This is the function pointer type for keyboard key callbacks. A keyboard
1830 * key callback function has the following signature:
1831 * @code
1832 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
1833 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001834 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001835 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001836 * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001837 * @param[in] scancode The platform-specific scancode of the key.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001838 * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
1839 * releases may add more actions.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +02001840 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1841 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001842 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001843 * @sa @ref input_key
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001844 * @sa @ref glfwSetKeyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001845 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001846 * @since Added in version 1.0.
1847 * @glfw3 Added window handle, scancode and modifier mask parameters.
Camilla Berglund810bab72015-12-13 17:38:14 +01001848 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001849 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001850 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001851typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001852
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001853/*! @brief The function pointer type for Unicode character callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001854 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001855 * This is the function pointer type for Unicode character callbacks.
1856 * A Unicode character callback function has the following signature:
1857 * @code
1858 * void function_name(GLFWwindow* window, unsigned int codepoint)
1859 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001860 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001861 * @param[in] window The window that received the event.
Camilla Berglund2c920fb2013-10-10 19:41:56 +02001862 * @param[in] codepoint The Unicode code point of the character.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001863 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001864 * @sa @ref input_char
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001865 * @sa @ref glfwSetCharCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001866 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001867 * @since Added in version 2.4.
1868 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001869 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001870 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001871 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001872typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
Camilla Berglund5f68e122012-11-27 17:07:28 +01001873
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001874/*! @brief The function pointer type for Unicode character with modifiers
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001875 * callbacks.
1876 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001877 * This is the function pointer type for Unicode character with modifiers
1878 * callbacks. It is called for each input character, regardless of what
1879 * modifier keys are held down. A Unicode character with modifiers callback
1880 * function has the following signature:
1881 * @code
1882 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
1883 * @endcode
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001884 *
1885 * @param[in] window The window that received the event.
1886 * @param[in] codepoint The Unicode code point of the character.
1887 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1888 * held down.
1889 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001890 * @sa @ref input_char
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001891 * @sa @ref glfwSetCharModsCallback
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001892 *
Camilla Löwyadebcc72017-11-14 23:28:12 +01001893 * @deprecated Scheduled for removal in version 4.0.
1894 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001895 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001896 *
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001897 * @ingroup input
1898 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001899typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001900
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001901/*! @brief The function pointer type for path drop callbacks.
arturo89d07232013-07-10 11:42:14 +02001902 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001903 * This is the function pointer type for path drop callbacks. A path drop
1904 * callback function has the following signature:
1905 * @code
1906 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
1907 * @endcode
arturo89d07232013-07-10 11:42:14 +02001908 *
1909 * @param[in] window The window that received the event.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001910 * @param[in] path_count The number of dropped paths.
Camilla Berglund93855ae2015-01-27 23:04:22 +01001911 * @param[in] paths The UTF-8 encoded file and/or directory path names.
arturo89d07232013-07-10 11:42:14 +02001912 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001913 * @pointer_lifetime The path array and its strings are valid until the
1914 * callback function returns.
1915 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001916 * @sa @ref path_drop
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001917 * @sa @ref glfwSetDropCallback
arturo89d07232013-07-10 11:42:14 +02001918 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001919 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001920 *
arturo89d07232013-07-10 11:42:14 +02001921 * @ingroup input
1922 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001923typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
arturo89d07232013-07-10 11:42:14 +02001924
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001925/*! @brief The function pointer type for monitor configuration callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001926 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001927 * This is the function pointer type for monitor configuration callbacks.
1928 * A monitor callback function has the following signature:
1929 * @code
1930 * void function_name(GLFWmonitor* monitor, int event)
1931 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001932 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001933 * @param[in] monitor The monitor that was connected or disconnected.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001934 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
1935 * releases may add more events.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001936 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001937 * @sa @ref monitor_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001938 * @sa @ref glfwSetMonitorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001939 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001940 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001941 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001942 * @ingroup monitor
Camilla Berglund5f68e122012-11-27 17:07:28 +01001943 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001944typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event);
Camilla Berglund897558f2011-03-07 13:34:58 +01001945
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001946/*! @brief The function pointer type for joystick configuration callbacks.
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001947 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001948 * This is the function pointer type for joystick configuration callbacks.
1949 * A joystick configuration callback function has the following signature:
1950 * @code
1951 * void function_name(int jid, int event)
1952 * @endcode
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001953 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02001954 * @param[in] jid The joystick that was connected or disconnected.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001955 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
1956 * releases may add more events.
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001957 *
1958 * @sa @ref joystick_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001959 * @sa @ref glfwSetJoystickCallback
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001960 *
1961 * @since Added in version 3.2.
1962 *
1963 * @ingroup input
1964 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001965typedef void (* GLFWjoystickfun)(int jid, int event);
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001966
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001967/*! @brief Video mode type.
1968 *
1969 * This describes a single video mode.
1970 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001971 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001972 * @sa @ref glfwGetVideoMode
1973 * @sa @ref glfwGetVideoModes
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001974 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001975 * @since Added in version 1.0.
1976 * @glfw3 Added refresh rate member.
Camilla Berglund810bab72015-12-13 17:38:14 +01001977 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001978 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001979 */
Systemclusterd0a0e372013-08-29 06:15:55 +02001980typedef struct GLFWvidmode
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001981{
Camilla Berglund95835af2013-05-30 13:53:25 +02001982 /*! The width, in screen coordinates, of the video mode.
Camilla Berglundc1594112013-05-27 22:29:06 +02001983 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001984 int width;
Camilla Berglund95835af2013-05-30 13:53:25 +02001985 /*! The height, in screen coordinates, of the video mode.
Camilla Berglundc1594112013-05-27 22:29:06 +02001986 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001987 int height;
Camilla Berglundc1594112013-05-27 22:29:06 +02001988 /*! The bit depth of the red channel of the video mode.
1989 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001990 int redBits;
Camilla Berglundc1594112013-05-27 22:29:06 +02001991 /*! The bit depth of the green channel of the video mode.
1992 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02001993 int greenBits;
Camilla Berglundc1594112013-05-27 22:29:06 +02001994 /*! The bit depth of the blue channel of the video mode.
1995 */
Camilla Berglund2e8446f2013-04-11 01:31:00 +02001996 int blueBits;
Camilla Berglund731812c2013-05-30 15:52:42 +02001997 /*! The refresh rate, in Hz, of the video mode.
1998 */
1999 int refreshRate;
Camilla Berglund3249f812010-09-07 17:34:51 +02002000} GLFWvidmode;
2001
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002002/*! @brief Gamma ramp.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002003 *
2004 * This describes the gamma ramp for a monitor.
2005 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002006 * @sa @ref monitor_gamma
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002007 * @sa @ref glfwGetGammaRamp
2008 * @sa @ref glfwSetGammaRamp
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002009 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002010 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01002011 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002012 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002013 */
Systemclusterd0a0e372013-08-29 06:15:55 +02002014typedef struct GLFWgammaramp
Camilla Berglund2630d492010-10-13 04:04:43 +02002015{
Camilla Berglundc1594112013-05-27 22:29:06 +02002016 /*! An array of value describing the response of the red channel.
2017 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002018 unsigned short* red;
Camilla Berglundc1594112013-05-27 22:29:06 +02002019 /*! An array of value describing the response of the green channel.
2020 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002021 unsigned short* green;
Camilla Berglundc1594112013-05-27 22:29:06 +02002022 /*! An array of value describing the response of the blue channel.
2023 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002024 unsigned short* blue;
Camilla Berglundc1594112013-05-27 22:29:06 +02002025 /*! The number of elements in each array.
2026 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002027 unsigned int size;
Camilla Berglund2630d492010-10-13 04:04:43 +02002028} GLFWgammaramp;
2029
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01002030/*! @brief Image data.
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002031 *
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02002032 * This describes a single 2D image. See the documentation for each related
2033 * function what the expected pixel format is.
2034 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002035 * @sa @ref cursor_custom
Camilla Berglundfe0317a2016-08-01 11:51:30 +02002036 * @sa @ref window_icon
Camilla Berglund810bab72015-12-13 17:38:14 +01002037 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002038 * @since Added in version 2.1.
2039 * @glfw3 Removed format and bytes-per-pixel members.
Camilla Löwy04116782018-11-05 17:37:49 +01002040 *
2041 * @ingroup window
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01002042 */
2043typedef struct GLFWimage
2044{
2045 /*! The width, in pixels, of this image.
2046 */
2047 int width;
2048 /*! The height, in pixels, of this image.
2049 */
2050 int height;
2051 /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
2052 */
2053 unsigned char* pixels;
2054} GLFWimage;
2055
Camilla Löwy953106e2017-06-18 15:13:25 +02002056/*! @brief Gamepad input state
2057 *
2058 * This describes the input state of a gamepad.
2059 *
2060 * @sa @ref gamepad
2061 * @sa @ref glfwGetGamepadState
2062 *
2063 * @since Added in version 3.3.
Camilla Löwy04116782018-11-05 17:37:49 +01002064 *
2065 * @ingroup input
Camilla Löwy953106e2017-06-18 15:13:25 +02002066 */
2067typedef struct GLFWgamepadstate
2068{
2069 /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
2070 * or `GLFW_RELEASE`.
2071 */
Camilla Löwy2d8d8f52017-07-17 21:18:15 +02002072 unsigned char buttons[15];
Camilla Löwy953106e2017-06-18 15:13:25 +02002073 /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
2074 * to 1.0 inclusive.
2075 */
2076 float axes[6];
2077} GLFWgamepadstate;
2078
Camilla Löwy22b586b2021-08-03 20:53:48 +02002079/*! @brief
2080 *
2081 * @sa @ref init_allocator
2082 * @sa @ref glfwInitAllocator
2083 *
2084 * @since Added in version 3.4.
2085 *
2086 * @ingroup init
2087 */
2088typedef struct GLFWallocator
2089{
2090 GLFWallocatefun allocate;
2091 GLFWreallocatefun reallocate;
2092 GLFWdeallocatefun deallocate;
2093 void* user;
2094} GLFWallocator;
2095
Camilla Berglund3249f812010-09-07 17:34:51 +02002096
2097/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +01002098 * GLFW API functions
Camilla Berglund3249f812010-09-07 17:34:51 +02002099 *************************************************************************/
2100
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002101/*! @brief Initializes the GLFW library.
2102 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002103 * This function initializes the GLFW library. Before most GLFW functions can
Camilla Berglund4591ad22014-09-18 15:03:29 +02002104 * be used, GLFW must be initialized, and before an application terminates GLFW
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002105 * should be terminated in order to free any resources allocated during or
2106 * after initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002107 *
Camilla Berglund23f61762013-03-12 19:53:29 +01002108 * If this function fails, it calls @ref glfwTerminate before returning. If it
Camilla Berglund4591ad22014-09-18 15:03:29 +02002109 * succeeds, you should call @ref glfwTerminate before the application exits.
Camilla Berglund23f61762013-03-12 19:53:29 +01002110 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002111 * Additional calls to this function after successful initialization but before
Camilla Berglund0eccf752015-08-23 19:30:04 +02002112 * termination will return `GLFW_TRUE` immediately.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002113 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002114 * The @ref GLFW_PLATFORM init hint controls which platforms are considered during
2115 * initialization. This also depends on which platforms the library was compiled to
2116 * support.
2117 *
Camilla Berglund0eccf752015-08-23 19:30:04 +02002118 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02002119 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002120 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002121 * @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref
2122 * GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01002123 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02002124 * @remark @macos This function will change the current directory of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01002125 * application to the `Contents/Resources` subdirectory of the application's
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002126 * bundle, if present. This can be disabled with the @ref
2127 * GLFW_COCOA_CHDIR_RESOURCES init hint.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002128 *
Camilla Löwy72366ac2020-03-05 20:32:19 +01002129 * @remark @macos This function will create the main menu and dock icon for the
2130 * application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to
2131 * contain a menu bar. Otherwise a minimal menu bar is created manually with
2132 * common commands like Hide, Quit and About. The About entry opens a minimal
2133 * about dialog with information from the application's bundle. The menu bar
2134 * and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
2135 * hint.
2136 *
Camilla Löwy4381b862020-02-06 15:46:37 +01002137 * @remark @x11 This function will set the `LC_CTYPE` category of the
2138 * application locale according to the current environment if that category is
2139 * still "C". This is because the "C" locale breaks Unicode text input.
2140 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002141 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002142 *
2143 * @sa @ref intro_init
Camilla Löwy22b586b2021-08-03 20:53:48 +02002144 * @sa @ref glfwInitHint
2145 * @sa @ref glfwInitAllocator
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002146 * @sa @ref glfwTerminate
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002147 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002148 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002149 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002150 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002151 */
2152GLFWAPI int glfwInit(void);
2153
2154/*! @brief Terminates the GLFW library.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002155 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002156 * This function destroys all remaining windows and cursors, restores any
2157 * modified gamma ramps and frees any other allocated resources. Once this
2158 * function is called, you must again call @ref glfwInit successfully before
2159 * you will be able to use most GLFW functions.
Camilla Berglund23f61762013-03-12 19:53:29 +01002160 *
2161 * If GLFW has been successfully initialized, this function should be called
Camilla Berglund4591ad22014-09-18 15:03:29 +02002162 * before the application exits. If initialization fails, there is no need to
2163 * call this function, as it is called by @ref glfwInit before it returns
2164 * failure.
Camilla Berglund23f61762013-03-12 19:53:29 +01002165 *
A. Tombs7486e122020-05-22 14:37:58 +01002166 * This function has no effect if GLFW is not initialized.
2167 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002168 * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
2169 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002170 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002171 *
Camilla Berglund0df4e062015-12-13 14:07:27 +01002172 * @warning The contexts of any remaining windows must not be current on any
2173 * other thread when this function is called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002174 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002175 * @reentrancy This function must not be called from a callback.
Camilla Berglund20858762015-01-01 18:41:22 +01002176 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002177 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002178 *
2179 * @sa @ref intro_init
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002180 * @sa @ref glfwInit
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002181 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002182 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002183 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002184 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002185 */
Camilla Berglund9a716692010-09-08 16:40:43 +02002186GLFWAPI void glfwTerminate(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002187
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002188/*! @brief Sets the specified init hint to the desired value.
2189 *
Camilla Löwy61588012017-12-12 10:54:18 +01002190 * This function sets hints for the next initialization of GLFW.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002191 *
Camilla Löwy213dd2d2017-07-25 01:55:08 +02002192 * The values you set hints to are never reset by GLFW, but they only take
2193 * effect during initialization. Once GLFW has been initialized, any values
2194 * you set will be ignored until the library is terminated and initialized
2195 * again.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002196 *
Camilla Löwy213dd2d2017-07-25 01:55:08 +02002197 * Some hints are platform specific. These may be set on any platform but they
Camilla Löwy1be81a12017-10-22 16:27:17 +02002198 * will only affect their specific platform. Other platforms will ignore them.
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00002199 * Setting these hints requires no platform specific headers or functions.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002200 *
2201 * @param[in] hint The [init hint](@ref init_hints) to set.
2202 * @param[in] value The new value of the init hint.
2203 *
2204 * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
2205 * GLFW_INVALID_VALUE.
2206 *
2207 * @remarks This function may be called before @ref glfwInit.
2208 *
2209 * @thread_safety This function must only be called from the main thread.
2210 *
2211 * @sa init_hints
2212 * @sa glfwInit
2213 *
2214 * @since Added in version 3.3.
2215 *
2216 * @ingroup init
2217 */
2218GLFWAPI void glfwInitHint(int hint, int value);
2219
Camilla Löwy22b586b2021-08-03 20:53:48 +02002220/*! @brief Sets the init allocator to the desired value.
2221 *
2222 * To use the default allocator, call this function with a `NULL` argument.
2223 *
2224 * If you specify an allocator struct, every member must be a valid function
2225 * pointer. If any member is `NULL`, this function emits @ref
2226 * GLFW_INVALID_VALUE and the init allocator is unchanged.
2227 *
2228 * @param[in] allocator The allocator to use at the next initialization, or
2229 * `NULL` to use the default one.
2230 *
2231 * @errors Possible errors include @ref GLFW_INVALID_VALUE.
2232 *
2233 * @pointer_lifetime The specified allocator is copied before this function
2234 * returns.
2235 *
2236 * @thread_safety This function must only be called from the main thread.
2237 *
2238 * @sa @ref init_allocator
2239 * @sa @ref glfwInit
2240 *
2241 * @since Added in version 3.4.
2242 *
2243 * @ingroup init
2244 */
2245GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator);
2246
Camilla Löwy76a5f782021-10-21 20:45:44 +02002247#if defined(VK_VERSION_1_0)
2248
2249/*! @brief Sets the desired Vulkan `vkGetInstanceProcAddr` function.
2250 *
2251 * This function sets the `vkGetInstanceProcAddr` function that GLFW will use for all
2252 * Vulkan related entry point queries.
2253 *
2254 * This feature is mostly useful on macOS, if your copy of the Vulkan loader is in
2255 * a location where GLFW cannot find it through dynamic loading, or if you are still
2256 * using the static library version of the loader.
2257 *
2258 * If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its standard
2259 * name and get this function from there. This is the default behavior.
2260 *
2261 * The standard name of the loader is `vulkan-1.dll` on Windows, `libvulkan.so.1` on
2262 * Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. If your code is
2263 * also loading it via these names then you probably don't need to use this function.
2264 *
2265 * The function address you set is never reset by GLFW, but it only takes effect during
2266 * initialization. Once GLFW has been initialized, any updates will be ignored until the
2267 * library is terminated and initialized again.
2268 *
2269 * @param[in] loader The address of the function to use, or `NULL`.
2270 *
2271 * @par Loader function signature
2272 * @code
2273 * PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* name)
2274 * @endcode
2275 * For more information about this function, see the
2276 * [Vulkan Registry](https://www.khronos.org/registry/vulkan/).
2277 *
2278 * @errors None.
2279 *
2280 * @remark This function may be called before @ref glfwInit.
2281 *
2282 * @thread_safety This function must only be called from the main thread.
2283 *
2284 * @sa @ref vulkan_loader
2285 * @sa @ref glfwInit
2286 *
2287 * @since Added in version 3.4.
2288 *
2289 * @ingroup init
2290 */
2291GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader);
2292
2293#endif /*VK_VERSION_1_0*/
2294
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002295/*! @brief Retrieves the version of the GLFW library.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002296 *
2297 * This function retrieves the major, minor and revision numbers of the GLFW
2298 * library. It is intended for when you are using GLFW as a shared library and
2299 * want to ensure that you are using the minimum required version.
2300 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002301 * Any or all of the version arguments may be `NULL`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002302 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01002303 * @param[out] major Where to store the major version number, or `NULL`.
2304 * @param[out] minor Where to store the minor version number, or `NULL`.
2305 * @param[out] rev Where to store the revision number, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002306 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002307 * @errors None.
2308 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002309 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002310 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002311 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002312 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002313 * @sa @ref intro_version
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002314 * @sa @ref glfwGetVersionString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002315 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002316 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002317 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002318 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002319 */
Camilla Berglund9a716692010-09-08 16:40:43 +02002320GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002321
Camilla Berglund6f8084f2013-02-14 13:14:17 +01002322/*! @brief Returns a string describing the compile-time configuration.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002323 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002324 * This function returns the compile-time generated
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002325 * [version string](@ref intro_version_string) of the GLFW library binary. It describes
2326 * the version, platforms, compiler and any platform or operating system specific
2327 * compile-time options. It should not be confused with the OpenGL or OpenGL ES version
2328 * string, queried with `glGetString`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002329 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002330 * __Do not use the version string__ to parse the GLFW library version. The
Camilla Berglund386b6032016-02-10 13:48:49 +01002331 * @ref glfwGetVersion function provides the version of the running library
2332 * binary in numerical format.
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002333 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002334 * __Do not use the version string__ to parse what platforms are supported. The @ref
2335 * glfwPlatformSupported function lets you query platform support.
2336 *
Camilla Berglund386b6032016-02-10 13:48:49 +01002337 * @return The ASCII encoded GLFW version string.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002338 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002339 * @errors None.
2340 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002341 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002342 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002343 * @pointer_lifetime The returned string is static and compile-time generated.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002344 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002345 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002346 *
2347 * @sa @ref intro_version
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002348 * @sa @ref glfwGetVersion
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002349 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002350 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002351 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002352 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002353 */
Camilla Berglundd6fe4472010-09-13 18:05:59 +02002354GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02002355
Camilla Löwy63506412017-05-01 19:20:57 +02002356/*! @brief Returns and clears the last error for the calling thread.
2357 *
Camilla Löwy2e9aff72017-07-09 14:46:39 +02002358 * This function returns and clears the [error code](@ref errors) of the last
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002359 * error that occurred on the calling thread, and optionally a UTF-8 encoded
2360 * human-readable description of it. If no error has occurred since the last
Camilla Löwy539a7282017-06-11 18:04:17 +02002361 * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
2362 * set to `NULL`.
Camilla Löwy63506412017-05-01 19:20:57 +02002363 *
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002364 * @param[in] description Where to store the error description pointer, or `NULL`.
Camilla Löwy539a7282017-06-11 18:04:17 +02002365 * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
2366 * (zero).
Camilla Löwy63506412017-05-01 19:20:57 +02002367 *
2368 * @errors None.
2369 *
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002370 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2371 * should not free it yourself. It is guaranteed to be valid only until the
2372 * next error occurs or the library is terminated.
2373 *
Camilla Löwy63506412017-05-01 19:20:57 +02002374 * @remark This function may be called before @ref glfwInit.
2375 *
2376 * @thread_safety This function may be called from any thread.
2377 *
2378 * @sa @ref error_handling
2379 * @sa @ref glfwSetErrorCallback
2380 *
2381 * @since Added in version 3.3.
2382 *
2383 * @ingroup init
2384 */
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002385GLFWAPI int glfwGetError(const char** description);
Camilla Löwy63506412017-05-01 19:20:57 +02002386
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002387/*! @brief Sets the error callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002388 *
2389 * This function sets the error callback, which is called with an error code
2390 * and a human-readable description each time a GLFW error occurs.
2391 *
Camilla Löwy63506412017-05-01 19:20:57 +02002392 * The error code is set before the callback is called. Calling @ref
2393 * glfwGetError from the error callback will return the same value as the error
2394 * code argument.
2395 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002396 * The error callback is called on the thread where the error occurred. If you
2397 * are using GLFW from multiple threads, your error callback needs to be
2398 * written accordingly.
2399 *
2400 * Because the description string may have been generated specifically for that
2401 * error, it is not guaranteed to be valid after the callback has returned. If
2402 * you wish to use it after the callback returns, you need to make a copy.
2403 *
Camilla Berglund20858762015-01-01 18:41:22 +01002404 * Once set, the error callback remains set even after the library has been
2405 * terminated.
2406 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002407 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002408 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002409 * @return The previously set callback, or `NULL` if no callback was set.
2410 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002411 * @callback_signature
2412 * @code
2413 * void callback_name(int error_code, const char* description)
2414 * @endcode
2415 * For more information about the callback parameters, see the
2416 * [callback pointer type](@ref GLFWerrorfun).
2417 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002418 * @errors None.
2419 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002420 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002421 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002422 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01002423 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002424 * @sa @ref error_handling
Camilla Löwy63506412017-05-01 19:20:57 +02002425 * @sa @ref glfwGetError
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002426 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002427 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002428 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002429 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002430 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002431GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
Camilla Berglundf5d74c42010-09-09 21:06:59 +02002432
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002433/*! @brief Returns the currently selected platform.
2434 *
2435 * This function returns the platform that was selected during initialization. The
2436 * returned value will be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
2437 * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
2438 *
2439 * @return The currently selected platform, or zero if an error occurred.
2440 *
2441 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2442 *
2443 * @thread_safety This function may be called from any thread.
2444 *
2445 * @sa @ref platform
2446 * @sa @ref glfwPlatformSupported
2447 *
2448 * @since Added in version 3.4.
2449 *
2450 * @ingroup init
2451 */
2452GLFWAPI int glfwGetPlatform(void);
2453
2454/*! @brief Returns whether the library includes support for the specified platform.
2455 *
2456 * This function returns whether the library was compiled with support for the specified
2457 * platform. The platform must be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
2458 * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
2459 *
2460 * @param[in] platform The platform to query.
2461 * @return `GLFW_TRUE` if the platform is supported, or `GLFW_FALSE` otherwise.
2462 *
2463 * @errors Possible errors include @ref GLFW_INVALID_ENUM.
2464 *
2465 * @remark This function may be called before @ref glfwInit.
2466 *
2467 * @thread_safety This function may be called from any thread.
2468 *
2469 * @sa @ref platform
2470 * @sa @ref glfwGetPlatform
2471 *
2472 * @since Added in version 3.4.
2473 *
2474 * @ingroup init
2475 */
2476GLFWAPI int glfwPlatformSupported(int platform);
2477
Camilla Berglund5f68e122012-11-27 17:07:28 +01002478/*! @brief Returns the currently connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002479 *
2480 * This function returns an array of handles for all currently connected
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002481 * monitors. The primary monitor is always first in the returned array. If no
2482 * monitors were found, this function returns `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002483 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002484 * @param[out] count Where to store the number of monitors in the returned
2485 * array. This is set to zero if an error occurred.
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002486 * @return An array of monitor handles, or `NULL` if no monitors were found or
2487 * if an [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002488 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002489 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2490 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002491 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2492 * should not free it yourself. It is guaranteed to be valid only until the
2493 * monitor configuration changes or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002494 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002495 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002496 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002497 * @sa @ref monitor_monitors
2498 * @sa @ref monitor_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002499 * @sa @ref glfwGetPrimaryMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002500 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002501 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002502 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002503 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002504 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002505GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002506
Camilla Berglund5f68e122012-11-27 17:07:28 +01002507/*! @brief Returns the primary monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002508 *
2509 * This function returns the primary monitor. This is usually the monitor
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002510 * where elements like the task bar or global menu bar are located.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002511 *
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002512 * @return The primary monitor, or `NULL` if no monitors were found or if an
2513 * [error](@ref error_handling) occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002514 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002515 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2516 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002517 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01002518 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002519 * @remark The primary monitor is always first in the array returned by @ref
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002520 * glfwGetMonitors.
2521 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002522 * @sa @ref monitor_monitors
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002523 * @sa @ref glfwGetMonitors
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002524 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002525 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002526 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002527 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002528 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002529GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002530
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002531/*! @brief Returns the position of the monitor's viewport on the virtual screen.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002532 *
2533 * This function returns the position, in screen coordinates, of the upper-left
2534 * corner of the specified monitor.
2535 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002536 * Any or all of the position arguments may be `NULL`. If an error occurs, all
2537 * non-`NULL` position arguments will be set to zero.
2538 *
Camilla Berglunddba2d802013-01-17 23:06:56 +01002539 * @param[in] monitor The monitor to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002540 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2541 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002542 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002543 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2544 * GLFW_PLATFORM_ERROR.
2545 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002546 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002547 *
2548 * @sa @ref monitor_properties
2549 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002550 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01002551 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002552 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002553 */
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002554GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
2555
luz.paz7105ff22019-08-12 06:52:31 -04002556/*! @brief Retrieves the work area of the monitor.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002557 *
2558 * This function returns the position, in screen coordinates, of the upper-left
Camilla Löwy01187432019-02-25 14:01:08 +01002559 * corner of the work area of the specified monitor along with the work area
2560 * size in screen coordinates. The work area is defined as the area of the
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002561 * monitor not occluded by the window system task bar where present. If no
Camilla Löwy01187432019-02-25 14:01:08 +01002562 * task bar exists then the work area is the monitor resolution in screen
2563 * coordinates.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002564 *
Camilla Löwy01187432019-02-25 14:01:08 +01002565 * Any or all of the position and size arguments may be `NULL`. If an error
2566 * occurs, all non-`NULL` position and size arguments will be set to zero.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002567 *
2568 * @param[in] monitor The monitor to query.
2569 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2570 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
Doug Binks3fd70cc2018-09-08 17:16:07 +02002571 * @param[out] width Where to store the monitor width, or `NULL`.
2572 * @param[out] height Where to store the monitor height, or `NULL`.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002573 *
2574 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2575 * GLFW_PLATFORM_ERROR.
2576 *
2577 * @thread_safety This function must only be called from the main thread.
2578 *
Camilla Löwya43d1a42019-02-25 14:46:48 +01002579 * @sa @ref monitor_workarea
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002580 *
Doug Binks69076292018-09-08 17:24:20 +02002581 * @since Added in version 3.3.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002582 *
2583 * @ingroup monitor
2584 */
Camilla Löwy01187432019-02-25 14:01:08 +01002585GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002586
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002587/*! @brief Returns the physical size of the monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002588 *
2589 * This function returns the size, in millimetres, of the display area of the
2590 * specified monitor.
2591 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002592 * Some platforms do not provide accurate monitor size information, either
Camilla Berglund4188c262015-01-18 01:55:25 +01002593 * because the monitor
2594 * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
2595 * data is incorrect or because the driver does not report it accurately.
2596 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002597 * Any or all of the size arguments may be `NULL`. If an error occurs, all
2598 * non-`NULL` size arguments will be set to zero.
2599 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002600 * @param[in] monitor The monitor to query.
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002601 * @param[out] widthMM Where to store the width, in millimetres, of the
2602 * monitor's display area, or `NULL`.
2603 * @param[out] heightMM Where to store the height, in millimetres, of the
2604 * monitor's display area, or `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002605 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002606 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2607 *
Camilla Löwy6a200532021-10-12 00:23:37 +02002608 * @remark @win32 On Windows 8 and earlier the physical size is calculated from
2609 * the current resolution and system DPI instead of querying the monitor EDID data.
Camilla Berglund0e205772014-03-24 11:58:35 +01002610 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002611 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002612 *
2613 * @sa @ref monitor_properties
2614 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002615 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002616 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002617 * @ingroup monitor
2618 */
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002619GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002620
Camilla Löwy16bf8722017-08-29 19:19:00 +02002621/*! @brief Retrieves the content scale for the specified monitor.
2622 *
2623 * This function retrieves the content scale for the specified monitor. The
2624 * content scale is the ratio between the current DPI and the platform's
Camilla Löwy422bf792019-04-01 18:36:30 +02002625 * default DPI. This is especially important for text and any UI elements. If
2626 * the pixel dimensions of your UI scaled by this look appropriate on your
2627 * machine then it should appear at a reasonable size on other machines
2628 * regardless of their DPI and scaling settings. This relies on the system DPI
2629 * and scaling settings being somewhat correct.
Camilla Löwy16bf8722017-08-29 19:19:00 +02002630 *
2631 * The content scale may depend on both the monitor resolution and pixel
2632 * density and on user settings. It may be very different from the raw DPI
2633 * calculated from the physical size and current resolution.
2634 *
2635 * @param[in] monitor The monitor to query.
2636 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
2637 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
2638 *
2639 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2640 * GLFW_PLATFORM_ERROR.
2641 *
2642 * @thread_safety This function must only be called from the main thread.
2643 *
2644 * @sa @ref monitor_scale
2645 * @sa @ref glfwGetWindowContentScale
2646 *
2647 * @since Added in version 3.3.
2648 *
2649 * @ingroup monitor
2650 */
2651GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
2652
Camilla Berglund5f68e122012-11-27 17:07:28 +01002653/*! @brief Returns the name of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002654 *
2655 * This function returns a human-readable name, encoded as UTF-8, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02002656 * specified monitor. The name typically reflects the make and model of the
2657 * monitor and is not guaranteed to be unique among the connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002658 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002659 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002660 * @return The UTF-8 encoded name of the monitor, or `NULL` if an
2661 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002662 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002663 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2664 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002665 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2666 * should not free it yourself. It is valid until the specified monitor is
2667 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002668 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002669 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002670 *
2671 * @sa @ref monitor_properties
2672 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002673 * @since Added in version 3.0.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002674 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002675 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002676 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002677GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002678
Camilla Löwy7c2c7852017-12-07 16:19:57 +01002679/*! @brief Sets the user pointer of the specified monitor.
2680 *
2681 * This function sets the user-defined pointer of the specified monitor. The
2682 * current value is retained until the monitor is disconnected. The initial
2683 * value is `NULL`.
2684 *
2685 * This function may be called from the monitor callback, even for a monitor
2686 * that is being disconnected.
2687 *
2688 * @param[in] monitor The monitor whose pointer to set.
2689 * @param[in] pointer The new value.
2690 *
2691 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2692 *
2693 * @thread_safety This function may be called from any thread. Access is not
2694 * synchronized.
2695 *
2696 * @sa @ref monitor_userptr
2697 * @sa @ref glfwGetMonitorUserPointer
2698 *
2699 * @since Added in version 3.3.
2700 *
2701 * @ingroup monitor
2702 */
2703GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
2704
2705/*! @brief Returns the user pointer of the specified monitor.
2706 *
2707 * This function returns the current value of the user-defined pointer of the
2708 * specified monitor. The initial value is `NULL`.
2709 *
2710 * This function may be called from the monitor callback, even for a monitor
2711 * that is being disconnected.
2712 *
2713 * @param[in] monitor The monitor whose pointer to return.
2714 *
2715 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2716 *
2717 * @thread_safety This function may be called from any thread. Access is not
2718 * synchronized.
2719 *
2720 * @sa @ref monitor_userptr
2721 * @sa @ref glfwSetMonitorUserPointer
2722 *
2723 * @since Added in version 3.3.
2724 *
2725 * @ingroup monitor
2726 */
2727GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
2728
Camilla Berglund5f68e122012-11-27 17:07:28 +01002729/*! @brief Sets the monitor configuration callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002730 *
2731 * This function sets the monitor configuration callback, or removes the
2732 * currently set callback. This is called when a monitor is connected to or
2733 * disconnected from the system.
2734 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002735 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01002736 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002737 * @return The previously set callback, or `NULL` if no callback was set or the
2738 * library had not been [initialized](@ref intro_init).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002739 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002740 * @callback_signature
2741 * @code
2742 * void function_name(GLFWmonitor* monitor, int event)
2743 * @endcode
2744 * For more information about the callback parameters, see the
2745 * [function pointer type](@ref GLFWmonitorfun).
2746 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002747 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2748 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002749 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002750 *
2751 * @sa @ref monitor_event
2752 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002753 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002754 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002755 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002756 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002757GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
Marcel Metzbeacbb32011-05-07 10:53:50 +02002758
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002759/*! @brief Returns the available video modes for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002760 *
2761 * This function returns an array of all video modes supported by the specified
Camilla Berglund948cc042013-04-16 02:02:22 +02002762 * monitor. The returned array is sorted in ascending order, first by color
Camilla Löwy0e9ec772021-04-22 23:07:50 +02002763 * bit depth (the sum of all channel depths), then by resolution area (the
2764 * product of width and height), then resolution width and finally by refresh
2765 * rate.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002766 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002767 * @param[in] monitor The monitor to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002768 * @param[out] count Where to store the number of video modes in the returned
2769 * array. This is set to zero if an error occurred.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002770 * @return An array of video modes, or `NULL` if an
2771 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002772 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002773 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2774 * GLFW_PLATFORM_ERROR.
2775 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002776 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2777 * should not free it yourself. It is valid until the specified monitor is
2778 * disconnected, this function is called again for that monitor or the library
2779 * is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002780 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002781 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002782 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002783 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002784 * @sa @ref glfwGetVideoMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002785 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002786 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01002787 * @glfw3 Changed to return an array of modes for a specific monitor.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002788 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002789 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002790 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002791GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002792
Camilla Berglund5f68e122012-11-27 17:07:28 +01002793/*! @brief Returns the current mode of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002794 *
Camilla Berglund948cc042013-04-16 02:02:22 +02002795 * This function returns the current video mode of the specified monitor. If
Camilla Berglund4591ad22014-09-18 15:03:29 +02002796 * you have created a full screen window for that monitor, the return value
2797 * will depend on whether that window is iconified.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002798 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002799 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002800 * @return The current mode of the monitor, or `NULL` if an
2801 * [error](@ref error_handling) occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002802 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002803 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2804 * GLFW_PLATFORM_ERROR.
2805 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002806 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2807 * should not free it yourself. It is valid until the specified monitor is
2808 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002809 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002810 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002811 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002812 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002813 * @sa @ref glfwGetVideoModes
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002814 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002815 * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002816 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002817 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002818 */
Camilla Berglundce1e84d2013-05-22 22:16:43 +02002819GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
Camilla Berglund3249f812010-09-07 17:34:51 +02002820
Camilla Berglund92a71e02013-02-12 13:50:41 +01002821/*! @brief Generates a gamma ramp and sets it for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002822 *
Camilla Löwy3531c322018-12-17 17:40:18 +01002823 * This function generates an appropriately sized gamma ramp from the specified
2824 * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
2825 * a finite number greater than zero.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002826 *
Camilla Löwyce161c22016-12-06 01:14:23 +01002827 * The software controlled gamma ramp is applied _in addition_ to the hardware
2828 * gamma correction, which today is usually an approximation of sRGB gamma.
2829 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2830 * the default (usually sRGB-like) behavior.
2831 *
2832 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2833 * GLFW_SRGB_CAPABLE hint.
2834 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002835 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01002836 * @param[in] gamma The desired exponent.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002837 *
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002838 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
2839 * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01002840 *
luz.paz7105ff22019-08-12 06:52:31 -04002841 * @remark @wayland Gamma handling is a privileged protocol, this function
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002842 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01002843 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002844 * @thread_safety This function must only be called from the main thread.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002845 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002846 * @sa @ref monitor_gamma
2847 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002848 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01002849 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002850 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002851 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01002852GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002853
Camilla Berglund4591ad22014-09-18 15:03:29 +02002854/*! @brief Returns the current gamma ramp for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002855 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002856 * This function returns the current gamma ramp of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002857 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002858 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002859 * @return The current gamma ramp, or `NULL` if an
2860 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002861 *
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002862 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
2863 * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01002864 *
luz.paz7105ff22019-08-12 06:52:31 -04002865 * @remark @wayland Gamma handling is a privileged protocol, this function
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002866 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
Emmanuel Gil Peyrot9c513342017-11-17 12:17:43 +00002867 * returning `NULL`.
linkmauvebc8b0482016-10-16 15:52:39 +01002868 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002869 * @pointer_lifetime The returned structure and its arrays are allocated and
2870 * freed by GLFW. You should not free them yourself. They are valid until the
2871 * specified monitor is disconnected, this function is called again for that
2872 * monitor or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002873 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002874 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002875 *
2876 * @sa @ref monitor_gamma
2877 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002878 * @since Added in version 3.0.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002879 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002880 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002881 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002882GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002883
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002884/*! @brief Sets the current gamma ramp for the specified monitor.
2885 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002886 * This function sets the current gamma ramp for the specified monitor. The
2887 * original gamma ramp for that monitor is saved by GLFW the first time this
2888 * function is called and is restored by @ref glfwTerminate.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002889 *
Camilla Löwyce161c22016-12-06 01:14:23 +01002890 * The software controlled gamma ramp is applied _in addition_ to the hardware
2891 * gamma correction, which today is usually an approximation of sRGB gamma.
2892 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2893 * the default (usually sRGB-like) behavior.
2894 *
2895 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2896 * GLFW_SRGB_CAPABLE hint.
2897 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002898 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002899 * @param[in] ramp The gamma ramp to use.
Camilla Berglund8954af62013-02-20 19:44:52 +01002900 *
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002901 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
2902 * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01002903 *
Camilla Löwy3531c322018-12-17 17:40:18 +01002904 * @remark The size of the specified gamma ramp should match the size of the
2905 * current ramp for that monitor.
Camilla Berglund76fff4d2015-03-10 19:02:28 +01002906 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002907 * @remark @win32 The gamma ramp size must be 256.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002908 *
luz.paz7105ff22019-08-12 06:52:31 -04002909 * @remark @wayland Gamma handling is a privileged protocol, this function
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002910 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01002911 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002912 * @pointer_lifetime The specified gamma ramp is copied before this function
2913 * returns.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002914 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002915 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002916 *
2917 * @sa @ref monitor_gamma
2918 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002919 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002920 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002921 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002922 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01002923GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
Camilla Berglund2630d492010-10-13 04:04:43 +02002924
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002925/*! @brief Resets all window hints to their default values.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002926 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002927 * This function resets all window hints to their
Camilla Berglunde248fb62013-03-29 14:06:23 +01002928 * [default values](@ref window_hints_values).
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002929 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002930 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2931 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002932 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01002933 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002934 * @sa @ref window_hints
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002935 * @sa @ref glfwWindowHint
Camilla Löwy61588012017-12-12 10:54:18 +01002936 * @sa @ref glfwWindowHintString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002937 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002938 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002939 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002940 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002941 */
Camilla Berglund5df4df62012-10-22 02:59:05 +02002942GLFWAPI void glfwDefaultWindowHints(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002943
2944/*! @brief Sets the specified window hint to the desired value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002945 *
Camilla Berglunded9e4032012-12-23 15:59:09 +01002946 * This function sets hints for the next call to @ref glfwCreateWindow. The
Camilla Löwy61588012017-12-12 10:54:18 +01002947 * hints, once set, retain their values until changed by a call to this
2948 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
2949 *
2950 * Only integer value hints can be set with this function. String value hints
2951 * are set with @ref glfwWindowHintString.
Camilla Berglunded9e4032012-12-23 15:59:09 +01002952 *
Camilla Berglundd6e0a432016-02-09 07:41:48 +01002953 * This function does not check whether the specified hint values are valid.
2954 * If you set hints to invalid values this will instead be reported by the next
2955 * call to @ref glfwCreateWindow.
2956 *
Camilla Löwy61588012017-12-12 10:54:18 +01002957 * Some hints are platform specific. These may be set on any platform but they
2958 * will only affect their specific platform. Other platforms will ignore them.
2959 * Setting these hints requires no platform specific headers or functions.
2960 *
Camilla Berglundd0649e62016-01-27 03:25:21 +01002961 * @param[in] hint The [window hint](@ref window_hints) to set.
2962 * @param[in] value The new value of the window hint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002963 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002964 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2965 * GLFW_INVALID_ENUM.
2966 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002967 * @thread_safety This function must only be called from the main thread.
Camilla Berglund401033c2013-03-12 19:17:07 +01002968 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002969 * @sa @ref window_hints
Camilla Löwy61588012017-12-12 10:54:18 +01002970 * @sa @ref glfwWindowHintString
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002971 * @sa @ref glfwDefaultWindowHints
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002972 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002973 * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002974 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002975 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002976 */
Camilla Berglundd0649e62016-01-27 03:25:21 +01002977GLFWAPI void glfwWindowHint(int hint, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002978
Camilla Löwy61588012017-12-12 10:54:18 +01002979/*! @brief Sets the specified window hint to the desired value.
2980 *
2981 * This function sets hints for the next call to @ref glfwCreateWindow. The
2982 * hints, once set, retain their values until changed by a call to this
2983 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
2984 *
2985 * Only string type hints can be set with this function. Integer value hints
2986 * are set with @ref glfwWindowHint.
2987 *
2988 * This function does not check whether the specified hint values are valid.
2989 * If you set hints to invalid values this will instead be reported by the next
2990 * call to @ref glfwCreateWindow.
2991 *
2992 * Some hints are platform specific. These may be set on any platform but they
2993 * will only affect their specific platform. Other platforms will ignore them.
2994 * Setting these hints requires no platform specific headers or functions.
2995 *
2996 * @param[in] hint The [window hint](@ref window_hints) to set.
2997 * @param[in] value The new value of the window hint.
2998 *
2999 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3000 * GLFW_INVALID_ENUM.
3001 *
3002 * @pointer_lifetime The specified string is copied before this function
3003 * returns.
3004 *
3005 * @thread_safety This function must only be called from the main thread.
3006 *
3007 * @sa @ref window_hints
3008 * @sa @ref glfwWindowHint
3009 * @sa @ref glfwDefaultWindowHints
3010 *
3011 * @since Added in version 3.3.
3012 *
3013 * @ingroup window
3014 */
3015GLFWAPI void glfwWindowHintString(int hint, const char* value);
3016
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003017/*! @brief Creates a window and its associated context.
3018 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003019 * This function creates a window and its associated OpenGL or OpenGL ES
3020 * context. Most of the options controlling how the window and its context
3021 * should be created are specified with [window hints](@ref window_hints).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003022 *
3023 * Successful creation does not change which context is current. Before you
Camilla Berglund4591ad22014-09-18 15:03:29 +02003024 * can use the newly created context, you need to
3025 * [make it current](@ref context_current). For information about the `share`
3026 * parameter, see @ref context_sharing.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003027 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003028 * The created window, framebuffer and context may differ from what you
3029 * requested, as not all parameters and hints are
Camilla Berglundfa0cbd92013-04-11 01:07:07 +02003030 * [hard constraints](@ref window_hints_hard). This includes the size of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003031 * window, especially for full screen windows. To query the actual attributes
Camilla Berglunde8bceaa2015-04-07 14:37:42 +02003032 * of the created window, framebuffer and context, see @ref
3033 * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003034 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003035 * To create a full screen window, you need to specify the monitor the window
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003036 * will cover. If no monitor is specified, the window will be windowed mode.
3037 * Unless you have a way for the user to choose a specific monitor, it is
3038 * recommended that you pick the primary monitor. For more information on how
3039 * to query connected monitors, see @ref monitor_monitors.
Camilla Berglund4b7ae492013-07-07 12:06:59 +02003040 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02003041 * For full screen windows, the specified size becomes the resolution of the
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003042 * window's _desired video mode_. As long as a full screen window is not
3043 * iconified, the supported video mode most closely matching the desired video
3044 * mode is set for the specified monitor. For more information about full
3045 * screen windows, including the creation of so called _windowed full screen_
3046 * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
Camilla Berglund95654cf2014-10-02 17:35:10 +02003047 *
Camilla Berglund999f3552016-08-17 16:48:22 +02003048 * Once you have created the window, you can switch it between windowed and
Camilla Berglunde83be1d2016-11-08 12:19:06 +01003049 * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
3050 * OpenGL or OpenGL ES context.
Camilla Berglund999f3552016-08-17 16:48:22 +02003051 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003052 * By default, newly created windows use the placement recommended by the
Camilla Löwy0f9a9572021-10-26 14:25:03 +02003053 * window system. To create the window at a specific position, set the @ref
3054 * GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints before creation. To
3055 * restore the default behavior, set either or both hints back to
3056 * `GLFW_ANY_POSITION`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003057 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003058 * As long as at least one full screen window is not iconified, the screensaver
3059 * is prohibited from starting.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003060 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003061 * Window systems put limits on window sizes. Very large or very small window
3062 * dimensions may be overridden by the window system on creation. Check the
Camilla Berglund95654cf2014-10-02 17:35:10 +02003063 * actual [size](@ref window_size) after creation.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003064 *
Camilla Berglund4188c262015-01-18 01:55:25 +01003065 * The [swap interval](@ref buffer_swap) is not set during window creation and
Camilla Berglund4591ad22014-09-18 15:03:29 +02003066 * the initial value may vary depending on driver settings and defaults.
3067 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003068 * @param[in] width The desired width, in screen coordinates, of the window.
3069 * This must be greater than zero.
3070 * @param[in] height The desired height, in screen coordinates, of the window.
3071 * This must be greater than zero.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003072 * @param[in] title The initial, UTF-8 encoded window title.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003073 * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
Camilla Berglund41bc0d12012-11-27 16:55:04 +01003074 * windowed mode.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003075 * @param[in] share The window whose context to share resources with, or `NULL`
3076 * to not share resources.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003077 * @return The handle of the created window, or `NULL` if an
3078 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003079 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003080 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3081 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
3082 * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
3083 * GLFW_PLATFORM_ERROR.
3084 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003085 * @remark @win32 Window creation will fail if the Microsoft GDI software
3086 * OpenGL implementation is the only one available.
Camilla Berglund07db5da2013-09-26 19:15:36 +02003087 *
Camilla Berglund20bce152016-05-30 16:04:37 +02003088 * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
3089 * will be set as the initial icon for the window. If no such icon is present,
Camilla Löwyd73ab0b2017-11-16 10:08:38 +01003090 * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
3091 * see @ref glfwSetWindowIcon.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003092 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003093 * @remark @win32 The context to share resources with must not be current on
3094 * any other thread.
Camilla Berglundb19fb4c2014-12-27 21:14:41 +01003095 *
Camilla Löwy82978bb2019-10-18 13:21:59 +02003096 * @remark @macos The OS only supports core profile contexts for OpenGL
3097 * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or
3098 * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
3099 * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all
3100 * on macOS.
Camilla Löwyfd127d52016-12-03 19:32:00 +01003101 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02003102 * @remark @macos The GLFW window has no icon, as it is not a document
Camilla Berglund71d2b572013-03-12 15:33:05 +01003103 * window, but the dock icon will be the same as the application bundle's icon.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003104 * For more information on bundles, see the
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003105 * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
3106 * in the Mac Developer Library.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003107 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02003108 * @remark @macos On OS X 10.10 and later the window frame will not be rendered
Camilla Löwy58ceab52016-12-07 00:41:54 +01003109 * at full resolution on Retina displays unless the
3110 * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
3111 * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
3112 * application bundle's `Info.plist`. For more information, see
Camilla Berglund821f3e62015-03-16 22:39:14 +01003113 * [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 +02003114 * in the Mac Developer Library. The GLFW test and example programs use
3115 * a custom `Info.plist` template for this, which can be found as
Camilla Löwy2fb33622019-12-03 22:03:36 +01003116 * `CMake/Info.plist.in` in the source tree.
Camilla Berglund821f3e62015-03-16 22:39:14 +01003117 *
Camilla Löwy46613152017-01-01 19:41:50 +01003118 * @remark @macos When activating frame autosaving with
Camilla Löwy9da22852017-12-12 16:45:38 +01003119 * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
luz.paz7105ff22019-08-12 06:52:31 -04003120 * window size and position may be overridden by previously saved values.
Camilla Löwy46613152017-01-01 19:41:50 +01003121 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003122 * @remark @x11 Some window managers will not respect the placement of
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003123 * initially hidden windows.
Camilla Berglund3af1c412013-09-19 21:37:01 +02003124 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003125 * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
3126 * a window to reach its requested state. This means you may not be able to
3127 * query the final size, position or other attributes directly after window
3128 * creation.
Camilla Berglund20ed0a12015-08-12 21:31:54 +02003129 *
Camilla Löwy61588012017-12-12 10:54:18 +01003130 * @remark @x11 The class part of the `WM_CLASS` window property will by
3131 * default be set to the window title passed to this function. The instance
3132 * part will use the contents of the `RESOURCE_NAME` environment variable, if
Camilla Löwy422bf792019-04-01 18:36:30 +02003133 * present and not empty, or fall back to the window title. Set the
3134 * [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
3135 * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
3136 * override this.
Camilla Löwy213dd2d2017-07-25 01:55:08 +02003137 *
Emmanuel Gil Peyrotbcd8f9a2019-02-15 19:02:32 +01003138 * @remark @wayland Compositors should implement the xdg-decoration protocol
3139 * for GLFW to decorate the window properly. If this protocol isn't
3140 * supported, or if the compositor prefers client-side decorations, a very
3141 * simple fallback frame will be drawn using the wp_viewporter protocol. A
3142 * compositor can still emit close, maximize or fullscreen events, using for
3143 * instance a keybind mechanism. If neither of these protocols is supported,
3144 * the window won't be decorated.
linkmauvebc8b0482016-10-16 15:52:39 +01003145 *
3146 * @remark @wayland A full screen window will not attempt to change the mode,
3147 * no matter what the requested size or refresh rate.
3148 *
Emmanuel Gil Peyrot65166852017-02-17 15:52:50 +00003149 * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
3150 * to be implemented in the user's compositor.
linkmauvebc8b0482016-10-16 15:52:39 +01003151 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003152 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003153 *
3154 * @sa @ref window_creation
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003155 * @sa @ref glfwDestroyWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003156 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003157 * @since Added in version 3.0. Replaces `glfwOpenWindow`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003158 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003159 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003160 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003161GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003162
3163/*! @brief Destroys the specified window and its context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003164 *
3165 * This function destroys the specified window and its context. On calling
3166 * this function, no further callbacks will be called for that window.
3167 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003168 * If the context of the specified window is current on the main thread, it is
3169 * detached before being destroyed.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003170 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003171 * @param[in] window The window to destroy.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003172 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003173 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3174 * GLFW_PLATFORM_ERROR.
3175 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003176 * @note The context of the specified window must not be current on any other
3177 * thread when this function is called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003178 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003179 * @reentrancy This function must not be called from a callback.
Camilla Berglund44372b82014-12-17 01:31:36 +01003180 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003181 * @thread_safety This function must only be called from the main thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003182 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003183 * @sa @ref window_creation
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003184 * @sa @ref glfwCreateWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003185 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003186 * @since Added in version 3.0. Replaces `glfwCloseWindow`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003187 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003188 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003189 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003190GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003191
Camilla Berglund64afb192013-03-06 23:29:37 +01003192/*! @brief Checks the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003193 *
3194 * This function returns the value of the close flag of the specified window.
3195 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01003196 * @param[in] window The window to query.
Camilla Berglund64afb192013-03-06 23:29:37 +01003197 * @return The value of the close flag.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003198 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003199 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3200 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003201 * @thread_safety This function may be called from any thread. Access is not
3202 * synchronized.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003203 *
3204 * @sa @ref window_close
3205 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003206 * @since Added in version 3.0.
Camilla Berglund6632cc72013-07-11 02:00:48 +02003207 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01003208 * @ingroup window
3209 */
3210GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
3211
Camilla Berglund64afb192013-03-06 23:29:37 +01003212/*! @brief Sets the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003213 *
3214 * This function sets the value of the close flag of the specified window.
3215 * This can be used to override the user's attempt to close the window, or
3216 * to signal that it should be closed.
3217 *
Camilla Berglund64afb192013-03-06 23:29:37 +01003218 * @param[in] window The window whose flag to change.
Camilla Berglund6fadf372013-03-01 13:45:12 +01003219 * @param[in] value The new value.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003220 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003221 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3222 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003223 * @thread_safety This function may be called from any thread. Access is not
3224 * synchronized.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003225 *
3226 * @sa @ref window_close
3227 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003228 * @since Added in version 3.0.
Camilla Berglund6632cc72013-07-11 02:00:48 +02003229 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01003230 * @ingroup window
Camilla Berglund6fadf372013-03-01 13:45:12 +01003231 */
3232GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
3233
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003234/*! @brief Sets the title of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003235 *
3236 * This function sets the window title, encoded as UTF-8, of the specified
3237 * window.
3238 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003239 * @param[in] window The window whose title to change.
3240 * @param[in] title The UTF-8 encoded window title.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003241 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003242 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3243 * GLFW_PLATFORM_ERROR.
3244 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02003245 * @remark @macos The window title will not be updated until the next time you
Camilla Berglund951a9582016-01-31 21:32:14 +01003246 * process events.
Camilla Berglund6412dcb2015-04-07 21:52:29 +02003247 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003248 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003249 *
3250 * @sa @ref window_title
3251 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003252 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003253 * @glfw3 Added window handle parameter.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003254 *
3255 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003256 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003257GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003258
Camilla Berglundb823f712016-03-07 14:55:30 +01003259/*! @brief Sets the icon for the specified window.
3260 *
3261 * This function sets the icon of the specified window. If passed an array of
3262 * candidate images, those of or closest to the sizes desired by the system are
3263 * selected. If no images are specified, the window reverts to its default
3264 * icon.
3265 *
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02003266 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
3267 * bits per channel with the red channel first. They are arranged canonically
3268 * as packed sequential rows, starting from the top-left corner.
3269 *
Camilla Berglundb823f712016-03-07 14:55:30 +01003270 * The desired image sizes varies depending on platform and system settings.
3271 * The selected images will be rescaled as needed. Good sizes include 16x16,
3272 * 32x32 and 48x48.
3273 *
3274 * @param[in] window The window whose icon to set.
3275 * @param[in] count The number of images in the specified array, or zero to
3276 * revert to the default window icon.
3277 * @param[in] images The images to create the icon from. This is ignored if
3278 * count is zero.
3279 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003280 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy66a48822022-03-15 21:22:49 +01003281 * GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
3282 * GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundb823f712016-03-07 14:55:30 +01003283 *
3284 * @pointer_lifetime The specified image data is copied before this function
3285 * returns.
3286 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003287 * @remark @macos Regular windows do not have icons on macOS. This function
3288 * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
Camilla Berglund20bce152016-05-30 16:04:37 +02003289 * the application bundle's icon. For more information on bundles, see the
Camilla Berglundb823f712016-03-07 14:55:30 +01003290 * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
3291 * in the Mac Developer Library.
3292 *
Emmanuel Gil Peyrota1620042017-12-03 04:19:15 +01003293 * @remark @wayland There is no existing protocol to change an icon, the
3294 * window will thus inherit the one defined in the application's desktop file.
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003295 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01003296 *
Camilla Berglundb823f712016-03-07 14:55:30 +01003297 * @thread_safety This function must only be called from the main thread.
3298 *
3299 * @sa @ref window_icon
3300 *
3301 * @since Added in version 3.2.
3302 *
3303 * @ingroup window
3304 */
3305GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
3306
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003307/*! @brief Retrieves the position of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003308 *
3309 * This function retrieves the position, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003310 * upper-left corner of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003311 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003312 * Any or all of the position arguments may be `NULL`. If an error occurs, all
3313 * non-`NULL` position arguments will be set to zero.
3314 *
Camilla Berglund7c193232013-01-24 19:30:31 +01003315 * @param[in] window The window to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003316 * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003317 * the content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003318 * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003319 * the content area, or `NULL`.
Camilla Berglund7c193232013-01-24 19:30:31 +01003320 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003321 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3322 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01003323 *
linkmauvebc8b0482016-10-16 15:52:39 +01003324 * @remark @wayland There is no way for an application to retrieve the global
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003325 * position of its windows. This function will emit @ref
3326 * GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01003327 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003328 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003329 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003330 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003331 * @sa @ref glfwSetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003332 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003333 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003334 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003335 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01003336 */
3337GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
3338
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003339/*! @brief Sets the position of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003340 *
3341 * This function sets the position, in screen coordinates, of the upper-left
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003342 * corner of the content area of the specified windowed mode window. If the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003343 * window is a full screen window, this function does nothing.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003344 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01003345 * __Do not use this function__ to move an already visible window unless you
3346 * have very good reasons for doing so, as it will confuse and annoy the user.
3347 *
3348 * The window manager may put limits on what positions are allowed. GLFW
3349 * cannot and should not override these limits.
3350 *
Camilla Berglund7c193232013-01-24 19:30:31 +01003351 * @param[in] window The window to query.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003352 * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
3353 * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
Camilla Berglund7c193232013-01-24 19:30:31 +01003354 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003355 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3356 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01003357 *
linkmauvebc8b0482016-10-16 15:52:39 +01003358 * @remark @wayland There is no way for an application to set the global
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003359 * position of its windows. This function will emit @ref
3360 * GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01003361 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003362 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003363 *
3364 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003365 * @sa @ref glfwGetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003366 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003367 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003368 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003369 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003370 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01003371 */
Camilla Berglund52f718d2013-02-12 12:01:12 +01003372GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
Camilla Berglund7c193232013-01-24 19:30:31 +01003373
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003374/*! @brief Retrieves the size of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003375 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003376 * This function retrieves the size, in screen coordinates, of the content area
Camilla Berglund521fa7d2013-09-26 20:02:19 +02003377 * of the specified window. If you wish to retrieve the size of the
Camilla Berglundce8f97c2015-01-11 23:33:14 +01003378 * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003379 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003380 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3381 * non-`NULL` size arguments will be set to zero.
3382 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003383 * @param[in] window The window whose size to retrieve.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003384 * @param[out] width Where to store the width, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003385 * content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003386 * @param[out] height Where to store the height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003387 * content area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003388 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003389 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3390 * GLFW_PLATFORM_ERROR.
3391 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003392 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003393 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003394 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003395 * @sa @ref glfwSetWindowSize
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003396 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003397 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003398 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003399 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003400 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003401 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003402GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003403
Camilla Berglundd84772d2014-02-13 02:57:59 +01003404/*! @brief Sets the size limits of the specified window.
3405 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003406 * This function sets the size limits of the content area of the specified
Emmanuel Gil Peyrotf0f5d9f2016-04-09 00:42:58 +01003407 * window. If the window is full screen, the size limits only take effect
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003408 * once it is made windowed. If the window is not resizable, this function
3409 * does nothing.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003410 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003411 * The size limits are applied immediately to a windowed mode window and may
3412 * cause it to be resized.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003413 *
Camilla Berglund12a69562016-05-04 16:28:08 +02003414 * The maximum dimensions must be greater than or equal to the minimum
3415 * dimensions and all must be greater than or equal to zero.
3416 *
Camilla Berglundd84772d2014-02-13 02:57:59 +01003417 * @param[in] window The window to set limits for.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003418 * @param[in] minwidth The minimum width, in screen coordinates, of the content
Camilla Berglundd84772d2014-02-13 02:57:59 +01003419 * area, or `GLFW_DONT_CARE`.
3420 * @param[in] minheight The minimum height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003421 * content area, or `GLFW_DONT_CARE`.
3422 * @param[in] maxwidth The maximum width, in screen coordinates, of the content
Camilla Berglundd84772d2014-02-13 02:57:59 +01003423 * area, or `GLFW_DONT_CARE`.
3424 * @param[in] maxheight The maximum height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003425 * content area, or `GLFW_DONT_CARE`.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003426 *
Camilla Berglund12a69562016-05-04 16:28:08 +02003427 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3428 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01003429 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003430 * @remark If you set size limits and an aspect ratio that conflict, the
Camilla Berglundd84772d2014-02-13 02:57:59 +01003431 * results are undefined.
3432 *
linkmauvebc8b0482016-10-16 15:52:39 +01003433 * @remark @wayland The size limits will not be applied until the window is
3434 * actually resized, either by the user or by the compositor.
3435 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003436 * @thread_safety This function must only be called from the main thread.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003437 *
3438 * @sa @ref window_sizelimits
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003439 * @sa @ref glfwSetWindowAspectRatio
Camilla Berglundd84772d2014-02-13 02:57:59 +01003440 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003441 * @since Added in version 3.2.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003442 *
3443 * @ingroup window
3444 */
3445GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
3446
3447/*! @brief Sets the aspect ratio of the specified window.
3448 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003449 * This function sets the required aspect ratio of the content area of the
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003450 * specified window. If the window is full screen, the aspect ratio only takes
3451 * effect once it is made windowed. If the window is not resizable, this
Camilla Berglundd84772d2014-02-13 02:57:59 +01003452 * function does nothing.
3453 *
Camilla Berglundaf5b82a2015-10-19 16:01:42 +02003454 * The aspect ratio is specified as a numerator and a denominator and both
3455 * values must be greater than zero. For example, the common 16:9 aspect ratio
3456 * is specified as 16 and 9, respectively.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003457 *
Camilla Berglundaf5b82a2015-10-19 16:01:42 +02003458 * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
3459 * ratio limit is disabled.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003460 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003461 * The aspect ratio is applied immediately to a windowed mode window and may
3462 * cause it to be resized.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003463 *
3464 * @param[in] window The window to set limits for.
3465 * @param[in] numer The numerator of the desired aspect ratio, or
3466 * `GLFW_DONT_CARE`.
3467 * @param[in] denom The denominator of the desired aspect ratio, or
3468 * `GLFW_DONT_CARE`.
3469 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003470 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3471 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3472 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003473 * @remark If you set size limits and an aspect ratio that conflict, the
Camilla Berglundd84772d2014-02-13 02:57:59 +01003474 * results are undefined.
3475 *
linkmauvebc8b0482016-10-16 15:52:39 +01003476 * @remark @wayland The aspect ratio will not be applied until the window is
3477 * actually resized, either by the user or by the compositor.
3478 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003479 * @thread_safety This function must only be called from the main thread.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003480 *
3481 * @sa @ref window_sizelimits
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003482 * @sa @ref glfwSetWindowSizeLimits
Camilla Berglundd84772d2014-02-13 02:57:59 +01003483 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003484 * @since Added in version 3.2.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003485 *
3486 * @ingroup window
3487 */
3488GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
3489
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003490/*! @brief Sets the size of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003491 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003492 * This function sets the size, in screen coordinates, of the content area of
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003493 * the specified window.
3494 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003495 * For full screen windows, this function updates the resolution of its desired
3496 * video mode and switches to the video mode closest to it, without affecting
3497 * the window's context. As the context is unaffected, the bit depths of the
3498 * framebuffer remain unchanged.
3499 *
3500 * If you wish to update the refresh rate of the desired video mode in addition
3501 * to its resolution, see @ref glfwSetWindowMonitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003502 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01003503 * The window manager may put limits on what sizes are allowed. GLFW cannot
3504 * and should not override these limits.
3505 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003506 * @param[in] window The window to resize.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003507 * @param[in] width The desired width, in screen coordinates, of the window
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003508 * content area.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003509 * @param[in] height The desired height, in screen coordinates, of the window
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003510 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003511 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003512 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3513 * GLFW_PLATFORM_ERROR.
3514 *
linkmauvebc8b0482016-10-16 15:52:39 +01003515 * @remark @wayland A full screen window will not attempt to change the mode,
3516 * no matter what the requested size.
3517 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003518 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003519 *
3520 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003521 * @sa @ref glfwGetWindowSize
3522 * @sa @ref glfwSetWindowMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003523 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003524 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003525 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003526 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003527 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003528 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003529GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003530
Camilla Berglund34981632013-06-03 12:51:57 +02003531/*! @brief Retrieves the size of the framebuffer of the specified window.
3532 *
3533 * This function retrieves the size, in pixels, of the framebuffer of the
Camilla Berglund521fa7d2013-09-26 20:02:19 +02003534 * specified window. If you wish to retrieve the size of the window in screen
3535 * coordinates, see @ref glfwGetWindowSize.
Camilla Berglund34981632013-06-03 12:51:57 +02003536 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003537 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3538 * non-`NULL` size arguments will be set to zero.
3539 *
Camilla Berglund34981632013-06-03 12:51:57 +02003540 * @param[in] window The window whose framebuffer to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003541 * @param[out] width Where to store the width, in pixels, of the framebuffer,
3542 * or `NULL`.
3543 * @param[out] height Where to store the height, in pixels, of the framebuffer,
3544 * or `NULL`.
Camilla Berglund34981632013-06-03 12:51:57 +02003545 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003546 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3547 * GLFW_PLATFORM_ERROR.
3548 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003549 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003550 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003551 * @sa @ref window_fbsize
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003552 * @sa @ref glfwSetFramebufferSizeCallback
Camilla Berglund34981632013-06-03 12:51:57 +02003553 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003554 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003555 *
Camilla Berglund34981632013-06-03 12:51:57 +02003556 * @ingroup window
3557 */
3558GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
3559
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003560/*! @brief Retrieves the size of the frame of the window.
3561 *
3562 * This function retrieves the size, in screen coordinates, of each edge of the
3563 * frame of the specified window. This size includes the title bar, if the
3564 * window has one. The size of the frame may vary depending on the
3565 * [window-related hints](@ref window_hints_wnd) used to create it.
3566 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003567 * Because this function retrieves the size of each window frame edge and not
3568 * the offset along a particular coordinate axis, the retrieved values will
3569 * always be zero or positive.
3570 *
3571 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3572 * non-`NULL` size arguments will be set to zero.
3573 *
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003574 * @param[in] window The window whose frame size to query.
3575 * @param[out] left Where to store the size, in screen coordinates, of the left
Camilla Berglund4591ad22014-09-18 15:03:29 +02003576 * edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02003577 * @param[out] top Where to store the size, in screen coordinates, of the top
Camilla Berglund4591ad22014-09-18 15:03:29 +02003578 * edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02003579 * @param[out] right Where to store the size, in screen coordinates, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003580 * right edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02003581 * @param[out] bottom Where to store the size, in screen coordinates, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003582 * bottom edge of the window frame, or `NULL`.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003583 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003584 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3585 * GLFW_PLATFORM_ERROR.
3586 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003587 * @thread_safety This function must only be called from the main thread.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003588 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003589 * @sa @ref window_size
3590 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003591 * @since Added in version 3.1.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003592 *
3593 * @ingroup window
3594 */
3595GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
3596
Camilla Löwy16bf8722017-08-29 19:19:00 +02003597/*! @brief Retrieves the content scale for the specified window.
3598 *
3599 * This function retrieves the content scale for the specified window. The
3600 * content scale is the ratio between the current DPI and the platform's
Camilla Löwy422bf792019-04-01 18:36:30 +02003601 * default DPI. This is especially important for text and any UI elements. If
3602 * the pixel dimensions of your UI scaled by this look appropriate on your
3603 * machine then it should appear at a reasonable size on other machines
3604 * regardless of their DPI and scaling settings. This relies on the system DPI
3605 * and scaling settings being somewhat correct.
Camilla Löwy16bf8722017-08-29 19:19:00 +02003606 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02003607 * On platforms where each monitors can have its own content scale, the window
Camilla Löwy16bf8722017-08-29 19:19:00 +02003608 * content scale will depend on which monitor the system considers the window
3609 * to be on.
3610 *
3611 * @param[in] window The window to query.
3612 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
3613 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
3614 *
3615 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3616 * GLFW_PLATFORM_ERROR.
3617 *
3618 * @thread_safety This function must only be called from the main thread.
3619 *
3620 * @sa @ref window_scale
Camilla Löwy370eac32017-12-11 21:26:40 +01003621 * @sa @ref glfwSetWindowContentScaleCallback
Camilla Löwy16bf8722017-08-29 19:19:00 +02003622 * @sa @ref glfwGetMonitorContentScale
3623 *
3624 * @since Added in version 3.3.
3625 *
3626 * @ingroup window
3627 */
3628GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
3629
Camilla Löwy11e47f02017-09-25 23:14:45 +02003630/*! @brief Returns the opacity of the whole window.
3631 *
3632 * This function returns the opacity of the window, including any decorations.
3633 *
3634 * The opacity (or alpha) value is a positive finite number between zero and
3635 * one, where zero is fully transparent and one is fully opaque. If the system
3636 * does not support whole window transparency, this function always returns one.
3637 *
3638 * The initial opacity value for newly created windows is one.
3639 *
3640 * @param[in] window The window to query.
3641 * @return The opacity value of the specified window.
3642 *
3643 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3644 * GLFW_PLATFORM_ERROR.
3645 *
3646 * @thread_safety This function must only be called from the main thread.
3647 *
3648 * @sa @ref window_transparency
3649 * @sa @ref glfwSetWindowOpacity
3650 *
3651 * @since Added in version 3.3.
3652 *
3653 * @ingroup window
3654 */
3655GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
3656
3657/*! @brief Sets the opacity of the whole window.
3658 *
3659 * This function sets the opacity of the window, including any decorations.
3660 *
3661 * The opacity (or alpha) value is a positive finite number between zero and
3662 * one, where zero is fully transparent and one is fully opaque.
3663 *
3664 * The initial opacity value for newly created windows is one.
3665 *
3666 * A window created with framebuffer transparency may not use whole window
3667 * transparency. The results of doing this are undefined.
3668 *
3669 * @param[in] window The window to set the opacity for.
3670 * @param[in] opacity The desired opacity of the specified window.
3671 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003672 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3673 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3674 *
3675 * @remark @wayland There is no way to set an opacity factor for a window.
3676 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
Camilla Löwy11e47f02017-09-25 23:14:45 +02003677 *
3678 * @thread_safety This function must only be called from the main thread.
3679 *
3680 * @sa @ref window_transparency
3681 * @sa @ref glfwGetWindowOpacity
3682 *
3683 * @since Added in version 3.3.
3684 *
3685 * @ingroup window
3686 */
3687GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
3688
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003689/*! @brief Iconifies the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003690 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003691 * This function iconifies (minimizes) the specified window if it was
3692 * previously restored. If the window is already iconified, this function does
3693 * nothing.
3694 *
Camilla Löwy2796e612022-06-24 19:29:29 +02003695 * If the specified window is a full screen window, GLFW restores the original
3696 * video mode of the monitor. The window's desired video mode is set again
3697 * when the window is restored.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003698 *
3699 * @param[in] window The window to iconify.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003700 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003701 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3702 * GLFW_PLATFORM_ERROR.
3703 *
Emmanuel Gil Peyrot599fb3d2019-03-01 18:46:06 +01003704 * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
3705 * be able to restore it. This is a design decision of the xdg-shell
Emmanuel Gil Peyrota1620042017-12-03 04:19:15 +01003706 * protocol.
linkmauvebc8b0482016-10-16 15:52:39 +01003707 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003708 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003709 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003710 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003711 * @sa @ref glfwRestoreWindow
3712 * @sa @ref glfwMaximizeWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003713 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003714 * @since Added in version 2.1.
Camilla Berglund951a9582016-01-31 21:32:14 +01003715 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003716 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003717 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003718 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003719GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003720
3721/*! @brief Restores the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003722 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003723 * This function restores the specified window if it was previously iconified
Camilla Berglunda10caa42015-10-13 12:50:59 +02003724 * (minimized) or maximized. If the window is already restored, this function
3725 * does nothing.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003726 *
Camilla Löwy2796e612022-06-24 19:29:29 +02003727 * If the specified window is an iconified full screen window, its desired
3728 * video mode is set again for its monitor when the window is restored.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003729 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003730 * @param[in] window The window to restore.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003731 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003732 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3733 * GLFW_PLATFORM_ERROR.
3734 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003735 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003736 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003737 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003738 * @sa @ref glfwIconifyWindow
3739 * @sa @ref glfwMaximizeWindow
Camilla Berglunde248fb62013-03-29 14:06:23 +01003740 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003741 * @since Added in version 2.1.
Camilla Berglund951a9582016-01-31 21:32:14 +01003742 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003743 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01003744 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003745 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003746GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003747
Camilla Berglunda10caa42015-10-13 12:50:59 +02003748/*! @brief Maximizes the specified window.
3749 *
3750 * This function maximizes the specified window if it was previously not
3751 * maximized. If the window is already maximized, this function does nothing.
3752 *
3753 * If the specified window is a full screen window, this function does nothing.
3754 *
3755 * @param[in] window The window to maximize.
3756 *
Camilla Berglundf5b71f52016-05-27 14:20:39 +02003757 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3758 * GLFW_PLATFORM_ERROR.
3759 *
Camilla Berglunda10caa42015-10-13 12:50:59 +02003760 * @par Thread Safety
3761 * This function may only be called from the main thread.
3762 *
3763 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003764 * @sa @ref glfwIconifyWindow
3765 * @sa @ref glfwRestoreWindow
Camilla Berglunda10caa42015-10-13 12:50:59 +02003766 *
3767 * @since Added in GLFW 3.2.
3768 *
3769 * @ingroup window
3770 */
3771GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
3772
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003773/*! @brief Makes the specified window visible.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003774 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003775 * This function makes the specified window visible if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003776 * hidden. If the window is already visible or is in full screen mode, this
Camilla Berglund1e9383d2012-11-23 11:41:53 +01003777 * function does nothing.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003778 *
Doug Binks0be4f3f2018-05-29 14:51:36 +01003779 * By default, windowed mode windows are focused when shown
3780 * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
3781 * to change this behavior for all newly created windows, or change the
3782 * behavior for an existing window with @ref glfwSetWindowAttrib.
3783 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003784 * @param[in] window The window to make visible.
3785 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003786 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3787 * GLFW_PLATFORM_ERROR.
3788 *
Camilla Löwy8edbc492021-12-27 01:31:38 +01003789 * @remark @wayland Because Wayland wants every frame of the desktop to be
3790 * complete, this function does not immediately make the window visible.
3791 * Instead it will become visible the next time the window framebuffer is
3792 * updated after this call.
3793 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003794 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003795 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003796 * @sa @ref window_hide
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003797 * @sa @ref glfwHideWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003798 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003799 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003800 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003801 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003802 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003803GLFWAPI void glfwShowWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003804
3805/*! @brief Hides the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003806 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003807 * This function hides the specified window if it was previously visible. If
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003808 * the window is already hidden or is in full screen mode, this function does
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003809 * nothing.
3810 *
3811 * @param[in] window The window to hide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003812 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003813 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3814 * GLFW_PLATFORM_ERROR.
3815 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003816 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003817 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003818 * @sa @ref window_hide
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003819 * @sa @ref glfwShowWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003820 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003821 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003822 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003823 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003824 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003825GLFWAPI void glfwHideWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003826
Camilla Berglundbaf57442016-02-21 15:42:49 +01003827/*! @brief Brings the specified window to front and sets input focus.
3828 *
3829 * This function brings the specified window to front and sets input focus.
3830 * The window should already be visible and not iconified.
3831 *
3832 * By default, both windowed and full screen mode windows are focused when
Camilla Löwyce161c22016-12-06 01:14:23 +01003833 * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
3834 * disable this behavior.
Camilla Berglundbaf57442016-02-21 15:42:49 +01003835 *
Doug Binks0be4f3f2018-05-29 14:51:36 +01003836 * Also by default, windowed mode windows are focused when shown
3837 * with @ref glfwShowWindow. Set the
3838 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
3839 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003840 * __Do not use this function__ to steal focus from other applications unless
3841 * you are certain that is what the user wants. Focus stealing can be
3842 * extremely disruptive.
3843 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003844 * For a less disruptive way of getting the user's attention, see
3845 * [attention requests](@ref window_attention).
3846 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003847 * @param[in] window The window to give input focus.
3848 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003849 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3850 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundbaf57442016-02-21 15:42:49 +01003851 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003852 * @remark @wayland It is not possible for an application to set the input
3853 * focus. This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01003854 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003855 * @thread_safety This function must only be called from the main thread.
3856 *
3857 * @sa @ref window_focus
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003858 * @sa @ref window_attention
Camilla Berglundbaf57442016-02-21 15:42:49 +01003859 *
3860 * @since Added in version 3.2.
3861 *
3862 * @ingroup window
3863 */
3864GLFWAPI void glfwFocusWindow(GLFWwindow* window);
3865
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003866/*! @brief Requests user attention to the specified window.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003867 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003868 * This function requests user attention to the specified window. On
3869 * platforms where this is not supported, attention is requested to the
3870 * application as a whole.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003871 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003872 * Once the user has given attention, usually by focusing the window or
3873 * application, the system will end the request automatically.
3874 *
3875 * @param[in] window The window to request attention to.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003876 *
3877 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3878 * GLFW_PLATFORM_ERROR.
3879 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003880 * @remark @macos Attention is requested to the application as a whole, not the
3881 * specific window.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003882 *
3883 * @thread_safety This function must only be called from the main thread.
3884 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003885 * @sa @ref window_attention
3886 *
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003887 * @since Added in version 3.3.
3888 *
3889 * @ingroup window
3890 */
3891GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
3892
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003893/*! @brief Returns the monitor that the window uses for full screen mode.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003894 *
3895 * This function returns the handle of the monitor that the specified window is
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003896 * in full screen on.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003897 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01003898 * @param[in] window The window to query.
Camilla Berglund999f3552016-08-17 16:48:22 +02003899 * @return The monitor, or `NULL` if the window is in windowed mode or an
3900 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003901 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003902 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3903 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003904 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003905 *
3906 * @sa @ref window_monitor
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003907 * @sa @ref glfwSetWindowMonitor
Camilla Berglund4591ad22014-09-18 15:03:29 +02003908 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003909 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01003910 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01003911 * @ingroup window
Camilla Berglund41bc0d12012-11-27 16:55:04 +01003912 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003913GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01003914
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003915/*! @brief Sets the mode, monitor, video mode and placement of a window.
3916 *
3917 * This function sets the monitor that the window uses for full screen mode or,
3918 * if the monitor is `NULL`, makes it windowed mode.
3919 *
3920 * When setting a monitor, this function updates the width, height and refresh
3921 * rate of the desired video mode and switches to the video mode closest to it.
3922 * The window position is ignored when setting a monitor.
3923 *
3924 * When the monitor is `NULL`, the position, width and height are used to
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003925 * place the window content area. The refresh rate is ignored when no monitor
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003926 * is specified.
3927 *
3928 * If you only wish to update the resolution of a full screen window or the
3929 * size of a windowed mode window, see @ref glfwSetWindowSize.
3930 *
3931 * When a window transitions from full screen to windowed mode, this function
3932 * restores any previous window settings such as whether it is decorated,
linkmauvebc8b0482016-10-16 15:52:39 +01003933 * floating, resizable, has size or aspect ratio limits, etc.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003934 *
3935 * @param[in] window The window whose monitor, size or video mode to set.
3936 * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
3937 * @param[in] xpos The desired x-coordinate of the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003938 * content area.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003939 * @param[in] ypos The desired y-coordinate of the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003940 * content area.
3941 * @param[in] width The desired with, in screen coordinates, of the content
3942 * area or video mode.
3943 * @param[in] height The desired height, in screen coordinates, of the content
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003944 * area or video mode.
Camilla Berglund325729d2016-05-22 14:25:04 +02003945 * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
3946 * or `GLFW_DONT_CARE`.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003947 *
3948 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3949 * GLFW_PLATFORM_ERROR.
3950 *
Camilla Berglundec171612016-10-28 06:20:20 +02003951 * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
3952 * affected by any resizing or mode switching, although you may need to update
3953 * your viewport if the framebuffer size has changed.
3954 *
linkmauvebc8b0482016-10-16 15:52:39 +01003955 * @remark @wayland The desired window position is ignored, as there is no way
3956 * for an application to set this property.
3957 *
3958 * @remark @wayland Setting the window to full screen will not attempt to
3959 * change the mode, no matter what the requested size or refresh rate.
3960 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003961 * @thread_safety This function must only be called from the main thread.
3962 *
3963 * @sa @ref window_monitor
3964 * @sa @ref window_full_screen
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003965 * @sa @ref glfwGetWindowMonitor
3966 * @sa @ref glfwSetWindowSize
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003967 *
3968 * @since Added in version 3.2.
3969 *
3970 * @ingroup window
3971 */
3972GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
3973
Camilla Berglundad1f6f02013-05-27 15:30:32 +02003974/*! @brief Returns an attribute of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003975 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003976 * This function returns the value of an attribute of the specified window or
3977 * its OpenGL or OpenGL ES context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003978 *
Camilla Berglund1e9383d2012-11-23 11:41:53 +01003979 * @param[in] window The window to query.
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02003980 * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
3981 * return.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003982 * @return The value of the attribute, or zero if an
3983 * [error](@ref error_handling) occurred.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01003984 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003985 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3986 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
3987 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003988 * @remark Framebuffer related hints are not window attributes. See @ref
Camilla Berglund59abeeb2015-04-07 14:34:12 +02003989 * window_attribs_fb for more information.
3990 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003991 * @remark Zero is a valid value for many window and context related
Camilla Berglund59abeeb2015-04-07 14:34:12 +02003992 * attributes so you cannot use a return value of zero as an indication of
3993 * errors. However, this function should not fail as long as it is passed
3994 * valid arguments and the library has been [initialized](@ref intro_init).
3995 *
Camilla Löwy2796e612022-06-24 19:29:29 +02003996 * @remark @wayland The Wayland protocol provides no way to check whether a
3997 * window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`.
3998 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003999 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004000 *
4001 * @sa @ref window_attribs
Camilla Löwy9e560992016-09-30 01:52:22 +02004002 * @sa @ref glfwSetWindowAttrib
Camilla Berglund4591ad22014-09-18 15:03:29 +02004003 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004004 * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
Camilla Berglund4188c262015-01-18 01:55:25 +01004005 * `glfwGetGLVersion`.
Camilla Berglund0e205772014-03-24 11:58:35 +01004006 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004007 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004008 */
Camilla Berglundad1f6f02013-05-27 15:30:32 +02004009GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004010
Camilla Löwy9e560992016-09-30 01:52:22 +02004011/*! @brief Sets an attribute of the specified window.
4012 *
4013 * This function sets the value of an attribute of the specified window.
4014 *
4015 * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
4016 * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
Doug Binks0be4f3f2018-05-29 14:51:36 +01004017 * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
4018 * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
4019 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
Rokas Kupstysd285a9f2019-09-30 15:44:43 +03004020 * [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
Camilla Löwy9e560992016-09-30 01:52:22 +02004021 *
4022 * Some of these attributes are ignored for full screen windows. The new
4023 * value will take effect if the window is later made windowed.
4024 *
4025 * Some of these attributes are ignored for windowed mode windows. The new
4026 * value will take effect if the window is later made full screen.
4027 *
4028 * @param[in] window The window to set the attribute for.
4029 * @param[in] attrib A supported window attribute.
4030 * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
4031 *
4032 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4033 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
4034 *
4035 * @remark Calling @ref glfwGetWindowAttrib will always return the latest
4036 * value, even if that value is ignored by the current mode of the window.
4037 *
4038 * @thread_safety This function must only be called from the main thread.
4039 *
4040 * @sa @ref window_attribs
4041 * @sa @ref glfwGetWindowAttrib
4042 *
4043 * @since Added in version 3.3.
4044 *
4045 * @ingroup window
4046 */
4047GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
4048
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004049/*! @brief Sets the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004050 *
4051 * This function sets the user-defined pointer of the specified window. The
4052 * current value is retained until the window is destroyed. The initial value
4053 * is `NULL`.
4054 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004055 * @param[in] window The window whose pointer to set.
4056 * @param[in] pointer The new value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004057 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004058 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4059 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004060 * @thread_safety This function may be called from any thread. Access is not
4061 * synchronized.
Camilla Berglund0e205772014-03-24 11:58:35 +01004062 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004063 * @sa @ref window_userptr
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004064 * @sa @ref glfwGetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004065 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004066 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004067 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004068 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004069 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004070GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004071
4072/*! @brief Returns the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004073 *
4074 * This function returns the current value of the user-defined pointer of the
4075 * specified window. The initial value is `NULL`.
4076 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004077 * @param[in] window The window whose pointer to return.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004078 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004079 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4080 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004081 * @thread_safety This function may be called from any thread. Access is not
4082 * synchronized.
Camilla Berglund0e205772014-03-24 11:58:35 +01004083 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004084 * @sa @ref window_userptr
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004085 * @sa @ref glfwSetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004086 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004087 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004088 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004089 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004090 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004091GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004092
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004093/*! @brief Sets the position callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004094 *
4095 * This function sets the position callback of the specified window, which is
Camilla Löwy2867ca12017-10-29 16:27:15 +01004096 * called when the window is moved. The callback is provided with the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004097 * position, in screen coordinates, of the upper-left corner of the content
4098 * area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004099 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004100 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004101 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004102 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004103 * @return The previously set callback, or `NULL` if no callback was set or the
4104 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004105 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004106 * @callback_signature
4107 * @code
4108 * void function_name(GLFWwindow* window, int xpos, int ypos)
4109 * @endcode
4110 * For more information about the callback parameters, see the
4111 * [function pointer type](@ref GLFWwindowposfun).
4112 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004113 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4114 *
linkmauvebc8b0482016-10-16 15:52:39 +01004115 * @remark @wayland This callback will never be called, as there is no way for
4116 * an application to know its global position.
4117 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004118 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004119 *
4120 * @sa @ref window_pos
4121 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004122 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004123 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004124 * @ingroup window
4125 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004126GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004127
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004128/*! @brief Sets the size callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004129 *
4130 * This function sets the size callback of the specified window, which is
4131 * called when the window is resized. The callback is provided with the size,
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004132 * in screen coordinates, of the content area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004133 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004134 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004135 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004136 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004137 * @return The previously set callback, or `NULL` if no callback was set or the
4138 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004139 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004140 * @callback_signature
4141 * @code
4142 * void function_name(GLFWwindow* window, int width, int height)
4143 * @endcode
4144 * For more information about the callback parameters, see the
4145 * [function pointer type](@ref GLFWwindowsizefun).
4146 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004147 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4148 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004149 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004150 *
4151 * @sa @ref window_size
4152 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004153 * @since Added in version 1.0.
4154 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01004155 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004156 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004157 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004158GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004159
4160/*! @brief Sets the close callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004161 *
4162 * This function sets the close callback of the specified window, which is
4163 * called when the user attempts to close the window, for example by clicking
4164 * the close widget in the title bar.
4165 *
4166 * The close flag is set before this callback is called, but you can modify it
4167 * at any time with @ref glfwSetWindowShouldClose.
4168 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004169 * The close callback is not triggered by @ref glfwDestroyWindow.
4170 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004171 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004172 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004173 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004174 * @return The previously set callback, or `NULL` if no callback was set or the
4175 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004176 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004177 * @callback_signature
4178 * @code
4179 * void function_name(GLFWwindow* window)
4180 * @endcode
4181 * For more information about the callback parameters, see the
4182 * [function pointer type](@ref GLFWwindowclosefun).
4183 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004184 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4185 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02004186 * @remark @macos Selecting Quit from the application menu will trigger the
4187 * close callback for all windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004188 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004189 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004190 *
4191 * @sa @ref window_close
4192 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004193 * @since Added in version 2.5.
4194 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01004195 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004196 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004197 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004198GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004199
4200/*! @brief Sets the refresh callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004201 *
4202 * This function sets the refresh callback of the specified window, which is
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004203 * called when the content area of the window needs to be redrawn, for example
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004204 * if the window has been exposed after having been covered by another window.
4205 *
linkmauvebc8b0482016-10-16 15:52:39 +01004206 * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
4207 * the window contents are saved off-screen, this callback may be called only
4208 * very infrequently or never at all.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02004209 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004210 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004211 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004212 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004213 * @return The previously set callback, or `NULL` if no callback was set or the
4214 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004215 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004216 * @callback_signature
4217 * @code
4218 * void function_name(GLFWwindow* window);
4219 * @endcode
4220 * For more information about the callback parameters, see the
4221 * [function pointer type](@ref GLFWwindowrefreshfun).
4222 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004223 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4224 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004225 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004226 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004227 * @sa @ref window_refresh
4228 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004229 * @since Added in version 2.5.
4230 * @glfw3 Added window handle parameter and return value.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01004231 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004232 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004233 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004234GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004235
4236/*! @brief Sets the focus callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004237 *
4238 * This function sets the focus callback of the specified window, which is
Camilla Berglund4188c262015-01-18 01:55:25 +01004239 * called when the window gains or loses input focus.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004240 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004241 * After the focus callback is called for a window that lost input focus,
4242 * synthetic key and mouse button release events will be generated for all such
4243 * that had been pressed. For more information, see @ref glfwSetKeyCallback
4244 * and @ref glfwSetMouseButtonCallback.
Camilla Berglund4538a522013-04-24 19:49:46 +02004245 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004246 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004247 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004248 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004249 * @return The previously set callback, or `NULL` if no callback was set or the
4250 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004251 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004252 * @callback_signature
4253 * @code
4254 * void function_name(GLFWwindow* window, int focused)
4255 * @endcode
4256 * For more information about the callback parameters, see the
4257 * [function pointer type](@ref GLFWwindowfocusfun).
4258 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004259 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4260 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004261 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004262 *
4263 * @sa @ref window_focus
4264 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004265 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004266 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004267 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004268 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004269GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004270
4271/*! @brief Sets the iconify callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004272 *
4273 * This function sets the iconification callback of the specified window, which
4274 * is called when the window is iconified or restored.
4275 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004276 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004277 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004278 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004279 * @return The previously set callback, or `NULL` if no callback was set or the
4280 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004281 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004282 * @callback_signature
4283 * @code
4284 * void function_name(GLFWwindow* window, int iconified)
4285 * @endcode
4286 * For more information about the callback parameters, see the
4287 * [function pointer type](@ref GLFWwindowiconifyfun).
4288 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004289 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4290 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004291 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004292 *
4293 * @sa @ref window_iconify
4294 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004295 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004296 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004297 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004298 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004299GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
Camilla Berglund135194a2010-09-09 18:15:32 +02004300
Camilla Berglundc156b502016-06-16 13:09:28 +02004301/*! @brief Sets the maximize callback for the specified window.
4302 *
4303 * This function sets the maximization callback of the specified window, which
4304 * is called when the window is maximized or restored.
4305 *
4306 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004307 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundc156b502016-06-16 13:09:28 +02004308 * callback.
4309 * @return The previously set callback, or `NULL` if no callback was set or the
4310 * library had not been [initialized](@ref intro_init).
4311 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004312 * @callback_signature
4313 * @code
4314 * void function_name(GLFWwindow* window, int maximized)
4315 * @endcode
4316 * For more information about the callback parameters, see the
4317 * [function pointer type](@ref GLFWwindowmaximizefun).
4318 *
Camilla Berglundc156b502016-06-16 13:09:28 +02004319 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4320 *
4321 * @thread_safety This function must only be called from the main thread.
4322 *
4323 * @sa @ref window_maximize
4324 *
4325 * @since Added in version 3.3.
4326 *
4327 * @ingroup window
4328 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004329GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
Camilla Berglundc156b502016-06-16 13:09:28 +02004330
Camilla Berglund34981632013-06-03 12:51:57 +02004331/*! @brief Sets the framebuffer resize callback for the specified window.
4332 *
4333 * This function sets the framebuffer resize callback of the specified window,
4334 * which is called when the framebuffer of the specified window is resized.
4335 *
4336 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004337 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund34981632013-06-03 12:51:57 +02004338 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004339 * @return The previously set callback, or `NULL` if no callback was set or the
4340 * library had not been [initialized](@ref intro_init).
Camilla Berglund34981632013-06-03 12:51:57 +02004341 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004342 * @callback_signature
4343 * @code
4344 * void function_name(GLFWwindow* window, int width, int height)
4345 * @endcode
4346 * For more information about the callback parameters, see the
4347 * [function pointer type](@ref GLFWframebuffersizefun).
4348 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004349 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4350 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004351 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004352 *
4353 * @sa @ref window_fbsize
4354 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004355 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004356 *
Camilla Berglund34981632013-06-03 12:51:57 +02004357 * @ingroup window
4358 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004359GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
Camilla Berglund34981632013-06-03 12:51:57 +02004360
Camilla Löwy370eac32017-12-11 21:26:40 +01004361/*! @brief Sets the window content scale callback for the specified window.
4362 *
4363 * This function sets the window content scale callback of the specified window,
4364 * which is called when the content scale of the specified window changes.
4365 *
4366 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004367 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Löwy370eac32017-12-11 21:26:40 +01004368 * callback.
4369 * @return The previously set callback, or `NULL` if no callback was set or the
4370 * library had not been [initialized](@ref intro_init).
4371 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004372 * @callback_signature
4373 * @code
4374 * void function_name(GLFWwindow* window, float xscale, float yscale)
4375 * @endcode
4376 * For more information about the callback parameters, see the
4377 * [function pointer type](@ref GLFWwindowcontentscalefun).
4378 *
Camilla Löwy370eac32017-12-11 21:26:40 +01004379 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4380 *
4381 * @thread_safety This function must only be called from the main thread.
4382 *
4383 * @sa @ref window_scale
4384 * @sa @ref glfwGetWindowContentScale
4385 *
4386 * @since Added in version 3.3.
4387 *
4388 * @ingroup window
4389 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004390GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
Camilla Löwy370eac32017-12-11 21:26:40 +01004391
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004392/*! @brief Processes all pending events.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004393 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004394 * This function processes only those events that are already in the event
4395 * queue and then returns immediately. Processing events will cause the window
4396 * and input callbacks associated with those events to be called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004397 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004398 * On some platforms, a window move, resize or menu operation will cause event
4399 * processing to block. This is due to how event processing is designed on
4400 * those platforms. You can use the
4401 * [window refresh callback](@ref window_refresh) to redraw the contents of
4402 * your window when necessary during such operations.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004403 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004404 * Do not assume that callbacks you set will _only_ be called in response to
4405 * event processing functions like this one. While it is necessary to poll for
4406 * events, window systems that require GLFW to register callbacks of its own
4407 * can pass events to GLFW in response to many window system function calls.
4408 * GLFW will pass those events on to the application callbacks before
4409 * returning.
Camilla Berglund401033c2013-03-12 19:17:07 +01004410 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004411 * Event processing is not required for joystick input to work.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01004412 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004413 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4414 * GLFW_PLATFORM_ERROR.
4415 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004416 * @reentrancy This function must not be called from a callback.
Camilla Berglundb48128f2013-02-14 18:49:03 +01004417 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004418 * @thread_safety This function must only be called from the main thread.
Camilla Berglund948cc042013-04-16 02:02:22 +02004419 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004420 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004421 * @sa @ref glfwWaitEvents
4422 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004423 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004424 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004425 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004426 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004427 */
Camilla Berglund9a716692010-09-08 16:40:43 +02004428GLFWAPI void glfwPollEvents(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004429
Camilla Berglund4591ad22014-09-18 15:03:29 +02004430/*! @brief Waits until events are queued and processes them.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004431 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004432 * This function puts the calling thread to sleep until at least one event is
4433 * available in the event queue. Once one or more events are available,
4434 * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
4435 * are processed and the function then returns immediately. Processing events
4436 * will cause the window and input callbacks associated with those events to be
4437 * called.
Camilla Berglund948cc042013-04-16 02:02:22 +02004438 *
4439 * Since not all events are associated with callbacks, this function may return
4440 * without a callback having been called even if you are monitoring all
4441 * callbacks.
4442 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004443 * On some platforms, a window move, resize or menu operation will cause event
4444 * processing to block. This is due to how event processing is designed on
4445 * those platforms. You can use the
4446 * [window refresh callback](@ref window_refresh) to redraw the contents of
4447 * your window when necessary during such operations.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004448 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004449 * Do not assume that callbacks you set will _only_ be called in response to
4450 * event processing functions like this one. While it is necessary to poll for
4451 * events, window systems that require GLFW to register callbacks of its own
4452 * can pass events to GLFW in response to many window system function calls.
4453 * GLFW will pass those events on to the application callbacks before
4454 * returning.
Camilla Berglund4188c262015-01-18 01:55:25 +01004455 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004456 * Event processing is not required for joystick input to work.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01004457 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004458 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4459 * GLFW_PLATFORM_ERROR.
4460 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004461 * @reentrancy This function must not be called from a callback.
Camilla Berglund44372b82014-12-17 01:31:36 +01004462 *
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 events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004466 * @sa @ref glfwPollEvents
4467 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004468 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004469 * @since Added in version 2.5.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004470 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004471 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004472 */
Camilla Berglund9a716692010-09-08 16:40:43 +02004473GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +02004474
Camilla Berglund56208952016-02-02 21:11:16 +01004475/*! @brief Waits with timeout until events are queued and processes them.
4476 *
4477 * This function puts the calling thread to sleep until at least one event is
4478 * available in the event queue, or until the specified timeout is reached. If
4479 * one or more events are available, it behaves exactly like @ref
4480 * glfwPollEvents, i.e. the events in the queue are processed and the function
4481 * then returns immediately. Processing events will cause the window and input
4482 * callbacks associated with those events to be called.
4483 *
4484 * The timeout value must be a positive finite number.
4485 *
4486 * Since not all events are associated with callbacks, this function may return
4487 * without a callback having been called even if you are monitoring all
4488 * callbacks.
4489 *
4490 * On some platforms, a window move, resize or menu operation will cause event
4491 * processing to block. This is due to how event processing is designed on
4492 * those platforms. You can use the
4493 * [window refresh callback](@ref window_refresh) to redraw the contents of
4494 * your window when necessary during such operations.
4495 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004496 * Do not assume that callbacks you set will _only_ be called in response to
4497 * event processing functions like this one. While it is necessary to poll for
4498 * events, window systems that require GLFW to register callbacks of its own
4499 * can pass events to GLFW in response to many window system function calls.
4500 * GLFW will pass those events on to the application callbacks before
4501 * returning.
Camilla Berglund56208952016-02-02 21:11:16 +01004502 *
Camilla Berglund56208952016-02-02 21:11:16 +01004503 * Event processing is not required for joystick input to work.
4504 *
4505 * @param[in] timeout The maximum amount of time, in seconds, to wait.
4506 *
Sylvain Boilard3b255af2018-09-13 16:23:44 +02004507 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy8e313d92018-12-13 20:33:17 +01004508 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Sylvain Boilard3b255af2018-09-13 16:23:44 +02004509 *
Camilla Berglund56208952016-02-02 21:11:16 +01004510 * @reentrancy This function must not be called from a callback.
4511 *
4512 * @thread_safety This function must only be called from the main thread.
4513 *
4514 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004515 * @sa @ref glfwPollEvents
4516 * @sa @ref glfwWaitEvents
Camilla Berglund56208952016-02-02 21:11:16 +01004517 *
4518 * @since Added in version 3.2.
4519 *
4520 * @ingroup window
4521 */
4522GLFWAPI void glfwWaitEventsTimeout(double timeout);
4523
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004524/*! @brief Posts an empty event to the event queue.
4525 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004526 * This function posts an empty event from the current thread to the event
Camilla Berglund73abf8a2016-07-06 13:06:59 +02004527 * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004528 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004529 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4530 * GLFW_PLATFORM_ERROR.
4531 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004532 * @thread_safety This function may be called from any thread.
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004533 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004534 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004535 * @sa @ref glfwWaitEvents
4536 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004537 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004538 * @since Added in version 3.1.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004539 *
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004540 * @ingroup window
4541 */
4542GLFWAPI void glfwPostEmptyEvent(void);
4543
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004544/*! @brief Returns the value of an input option for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004545 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02004546 * This function returns the value of an input option for the specified window.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004547 * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
Nathan Poirier9e29f552018-12-14 03:08:25 +01004548 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
Camilla Löwy1155c832019-02-11 19:10:20 +01004549 * @ref GLFW_RAW_MOUSE_MOTION.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004550 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004551 * @param[in] window The window to query.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004552 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
Camilla Löwy1155c832019-02-11 19:10:20 +01004553 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4554 * `GLFW_RAW_MOUSE_MOTION`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004555 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004556 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4557 * GLFW_INVALID_ENUM.
4558 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004559 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004560 *
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004561 * @sa @ref glfwSetInputMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004562 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004563 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004564 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004565 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004566 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004567GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004568
4569/*! @brief Sets an input option for the specified window.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004570 *
4571 * This function sets an input mode option for the specified window. The mode
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004572 * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
Nathan Poirier9e29f552018-12-14 03:08:25 +01004573 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
Camilla Löwy1155c832019-02-11 19:10:20 +01004574 * @ref GLFW_RAW_MOUSE_MOTION.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004575 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004576 * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004577 * modes:
Camilla Berglund13ccf7d2013-04-07 13:46:38 +02004578 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004579 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
4580 * content area of the window but does not restrict the cursor from leaving.
Camilla Berglunda18b1872013-12-05 03:27:12 +01004581 * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
4582 * and unlimited cursor movement. This is useful for implementing for
4583 * example 3D camera controls.
Camilla Löwy488008e2019-12-03 17:58:20 +01004584 * - `GLFW_CURSOR_CAPTURED` makes the cursor visible and confines it to the
4585 * content area of the window.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004586 *
Camilla Berglund0eccf752015-08-23 19:30:04 +02004587 * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
4588 * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
Camilla Berglund95654cf2014-10-02 17:35:10 +02004589 * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
4590 * the next time it is called even if the key had been released before the
4591 * call. This is useful when you are only interested in whether keys have been
4592 * pressed but not when or in which order.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004593 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004594 * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
Camilla Berglund0eccf752015-08-23 19:30:04 +02004595 * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
4596 * If sticky mouse buttons are enabled, a mouse button press will ensure that
4597 * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
4598 * if the mouse button had been released before the call. This is useful when
4599 * you are only interested in whether mouse buttons have been pressed but not
4600 * when or in which order.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004601 *
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004602 * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
4603 * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
4604 * callbacks that receive modifier bits will also have the @ref
4605 * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
4606 * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
4607 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004608 * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
4609 * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
4610 * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02004611 * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
Camilla Löwy1155c832019-02-11 19:10:20 +01004612 * glfwRawMouseMotionSupported to check for support.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004613 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02004614 * @param[in] window The window whose input mode to set.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004615 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
Camilla Löwy1155c832019-02-11 19:10:20 +01004616 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4617 * `GLFW_RAW_MOUSE_MOTION`.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004618 * @param[in] value The new value of the specified input mode.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004619 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004620 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02004621 * GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
4622 * GLFW_FEATURE_UNAVAILABLE (see above).
Camilla Berglundf51cf812016-02-05 00:51:40 +01004623 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004624 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004625 *
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004626 * @sa @ref glfwGetInputMode
Camilla Berglunde248fb62013-03-29 14:06:23 +01004627 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004628 * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004629 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01004630 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004631 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004632GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004633
Camilla Löwy1155c832019-02-11 19:10:20 +01004634/*! @brief Returns whether raw mouse motion is supported.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004635 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004636 * This function returns whether raw mouse motion is supported on the current
4637 * system. This status does not change after GLFW has been initialized so you
4638 * only need to check this once. If you attempt to enable raw motion on
4639 * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004640 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004641 * Raw mouse motion is closer to the actual motion of the mouse across
4642 * a surface. It is not affected by the scaling and acceleration applied to
4643 * the motion of the desktop cursor. That processing is suitable for a cursor
4644 * while raw motion is better for controlling for example a 3D camera. Because
4645 * of this, raw mouse motion is only provided when the cursor is disabled.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004646 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004647 * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
4648 * or `GLFW_FALSE` otherwise.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004649 *
4650 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4651 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004652 * @thread_safety This function must only be called from the main thread.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004653 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004654 * @sa @ref raw_mouse_motion
Nathan Poirier9e29f552018-12-14 03:08:25 +01004655 * @sa @ref glfwSetInputMode
4656 *
4657 * @since Added in version 3.3.
4658 *
4659 * @ingroup input
4660 */
Camilla Löwy1155c832019-02-11 19:10:20 +01004661GLFWAPI int glfwRawMouseMotionSupported(void);
Nathan Poirier9e29f552018-12-14 03:08:25 +01004662
Camilla Löwy9558b852017-04-04 18:05:36 +02004663/*! @brief Returns the layout-specific name of the specified printable key.
Camilla Berglund9c315412015-07-02 14:24:50 +02004664 *
Camilla Löwy9558b852017-04-04 18:05:36 +02004665 * This function returns the name of the specified printable key, encoded as
4666 * UTF-8. This is typically the character that key would produce without any
4667 * modifier keys, intended for displaying key bindings to the user. For dead
4668 * keys, it is typically the diacritic it would add to a character.
Camilla Berglund9c315412015-07-02 14:24:50 +02004669 *
Camilla Löwy071a0492017-02-28 22:29:10 +01004670 * __Do not use this function__ for [text input](@ref input_char). You will
4671 * break text input for many languages even if it happens to work for yours.
Camilla Berglund70ffae72016-02-22 11:54:56 +01004672 *
Camilla Löwy071a0492017-02-28 22:29:10 +01004673 * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
4674 * otherwise the scancode is ignored. If you specify a non-printable key, or
4675 * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
4676 * function returns `NULL` but does not emit an error.
4677 *
4678 * This behavior allows you to always pass in the arguments in the
Camilla Berglund70ffae72016-02-22 11:54:56 +01004679 * [key callback](@ref input_key) without modification.
4680 *
4681 * The printable keys are:
4682 * - `GLFW_KEY_APOSTROPHE`
4683 * - `GLFW_KEY_COMMA`
4684 * - `GLFW_KEY_MINUS`
4685 * - `GLFW_KEY_PERIOD`
4686 * - `GLFW_KEY_SLASH`
4687 * - `GLFW_KEY_SEMICOLON`
4688 * - `GLFW_KEY_EQUAL`
4689 * - `GLFW_KEY_LEFT_BRACKET`
4690 * - `GLFW_KEY_RIGHT_BRACKET`
4691 * - `GLFW_KEY_BACKSLASH`
4692 * - `GLFW_KEY_WORLD_1`
4693 * - `GLFW_KEY_WORLD_2`
4694 * - `GLFW_KEY_0` to `GLFW_KEY_9`
4695 * - `GLFW_KEY_A` to `GLFW_KEY_Z`
4696 * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
4697 * - `GLFW_KEY_KP_DECIMAL`
4698 * - `GLFW_KEY_KP_DIVIDE`
4699 * - `GLFW_KEY_KP_MULTIPLY`
4700 * - `GLFW_KEY_KP_SUBTRACT`
4701 * - `GLFW_KEY_KP_ADD`
4702 * - `GLFW_KEY_KP_EQUAL`
Camilla Berglund9c315412015-07-02 14:24:50 +02004703 *
Camilla Löwy071a0492017-02-28 22:29:10 +01004704 * Names for printable keys depend on keyboard layout, while names for
4705 * non-printable keys are the same across layouts but depend on the application
4706 * language and should be localized along with other user interface text.
4707 *
Camilla Berglund9c315412015-07-02 14:24:50 +02004708 * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
4709 * @param[in] scancode The scancode of the key to query.
Camilla Löwy9558b852017-04-04 18:05:36 +02004710 * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
Camilla Berglund9c315412015-07-02 14:24:50 +02004711 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004712 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4713 * GLFW_PLATFORM_ERROR.
4714 *
Camilla Löwy56ca0cb2019-08-22 21:31:46 +02004715 * @remark The contents of the returned string may change when a keyboard
4716 * layout change event is received.
4717 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004718 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
Camilla Löwy56ca0cb2019-08-22 21:31:46 +02004719 * should not free it yourself. It is valid until the library is terminated.
Camilla Berglund9c315412015-07-02 14:24:50 +02004720 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004721 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9c315412015-07-02 14:24:50 +02004722 *
4723 * @sa @ref input_key_name
4724 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004725 * @since Added in version 3.2.
Camilla Berglund9c315412015-07-02 14:24:50 +02004726 *
4727 * @ingroup input
4728 */
4729GLFWAPI const char* glfwGetKeyName(int key, int scancode);
4730
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004731/*! @brief Returns the platform-specific scancode of the specified key.
Michael Stockere745b0d2016-08-11 19:11:40 +02004732 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004733 * This function returns the platform-specific scancode of the specified key.
Michael Stockere745b0d2016-08-11 19:11:40 +02004734 *
4735 * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
4736 * method will return `-1`.
4737 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004738 * @param[in] key Any [named key](@ref keys).
4739 * @return The platform-specific scancode for the key, or `-1` if an
Camilla Berglundbb3cb8f2016-09-06 15:40:31 +02004740 * [error](@ref error_handling) occurred.
Michael Stockere745b0d2016-08-11 19:11:40 +02004741 *
Camilla Berglundbb3cb8f2016-09-06 15:40:31 +02004742 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4743 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
Michael Stockere745b0d2016-08-11 19:11:40 +02004744 *
4745 * @thread_safety This function may be called from any thread.
4746 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004747 * @sa @ref input_key
Michael Stockere745b0d2016-08-11 19:11:40 +02004748 *
4749 * @since Added in version 3.3.
4750 *
4751 * @ingroup input
4752 */
Camilla Berglundbb3cb8f2016-09-06 15:40:31 +02004753GLFWAPI int glfwGetKeyScancode(int key);
Michael Stockere745b0d2016-08-11 19:11:40 +02004754
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004755/*! @brief Returns the last reported state of a keyboard key for the specified
4756 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004757 *
4758 * This function returns the last state reported for the specified key to the
4759 * specified window. The returned state is one of `GLFW_PRESS` or
Camilla Löwyaa80d242022-06-28 23:19:30 +02004760 * `GLFW_RELEASE`. The action `GLFW_REPEAT` is only reported to the key callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004761 *
Camilla Löwy46393072017-02-20 13:45:11 +01004762 * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
Camilla Berglund4591ad22014-09-18 15:03:29 +02004763 * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
4764 * that key has already been released.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004765 *
4766 * The key functions deal with physical keys, with [key tokens](@ref keys)
4767 * named after their use on the standard US keyboard layout. If you want to
4768 * input text, use the Unicode character callback instead.
4769 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004770 * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
4771 * used with this function.
4772 *
Camilla Berglund9c315412015-07-02 14:24:50 +02004773 * __Do not use this function__ to implement [text input](@ref input_char).
4774 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004775 * @param[in] window The desired window.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004776 * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
4777 * not a valid key for this function.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004778 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004779 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004780 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4781 * GLFW_INVALID_ENUM.
4782 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004783 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004784 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004785 * @sa @ref input_key
4786 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004787 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01004788 * @glfw3 Added window handle parameter.
Camilla Berglund11615fc2013-05-30 17:19:12 +02004789 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004790 * @ingroup input
4791 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004792GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004793
4794/*! @brief Returns the last reported state of a mouse button for the specified
4795 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004796 *
4797 * This function returns the last state reported for the specified mouse button
Camilla Berglund4591ad22014-09-18 15:03:29 +02004798 * to the specified window. The returned state is one of `GLFW_PRESS` or
Camilla Berglundce8f97c2015-01-11 23:33:14 +01004799 * `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004800 *
Camilla Löwy46393072017-02-20 13:45:11 +01004801 * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
Coşku Başf4764f72018-08-06 18:13:24 +03004802 * returns `GLFW_PRESS` the first time you call it for a mouse button that was
4803 * pressed, even if that mouse button has already been released.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004804 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004805 * @param[in] window The desired window.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004806 * @param[in] button The desired [mouse button](@ref buttons).
4807 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004808 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004809 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4810 * GLFW_INVALID_ENUM.
4811 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004812 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004813 *
4814 * @sa @ref input_mouse_button
4815 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004816 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01004817 * @glfw3 Added window handle parameter.
Camilla Berglund0e205772014-03-24 11:58:35 +01004818 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004819 * @ingroup input
4820 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004821GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004822
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004823/*! @brief Retrieves the position of the cursor relative to the content area of
Camilla Berglundd4591452014-02-11 18:24:01 +01004824 * the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004825 *
Camilla Berglundd4591452014-02-11 18:24:01 +01004826 * This function returns the position of the cursor, in screen coordinates,
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004827 * relative to the upper-left corner of the content area of the specified
Camilla Berglundd4591452014-02-11 18:24:01 +01004828 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004829 *
Camilla Berglund6df692b2013-04-26 17:20:31 +02004830 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
4831 * position is unbounded and limited only by the minimum and maximum values of
4832 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02004833 *
Camilla Berglund3ec29252013-04-25 18:03:15 +02004834 * The coordinate can be converted to their integer equivalents with the
4835 * `floor` function. Casting directly to an integer type works for positive
4836 * coordinates, but fails for negative ones.
4837 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004838 * Any or all of the position arguments may be `NULL`. If an error occurs, all
4839 * non-`NULL` position arguments will be set to zero.
4840 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004841 * @param[in] window The desired window.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004842 * @param[out] xpos Where to store the cursor x-coordinate, relative to the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004843 * left edge of the content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004844 * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004845 * top edge of the content area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004846 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004847 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4848 * GLFW_PLATFORM_ERROR.
4849 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004850 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004851 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004852 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004853 * @sa @ref glfwSetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004854 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004855 * @since Added in version 3.0. Replaces `glfwGetMousePos`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004856 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004857 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004858 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02004859GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004860
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004861/*! @brief Sets the position of the cursor, relative to the content area of the
Camilla Berglund6d9d8562013-09-28 22:12:50 +02004862 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004863 *
Camilla Berglund6d9d8562013-09-28 22:12:50 +02004864 * This function sets the position, in screen coordinates, of the cursor
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004865 * relative to the upper-left corner of the content area of the specified
Camilla Berglund4188c262015-01-18 01:55:25 +01004866 * window. The window must have input focus. If the window does not have
4867 * input focus when this function is called, it fails silently.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004868 *
Camilla Berglund20858762015-01-01 18:41:22 +01004869 * __Do not use this function__ to implement things like camera controls. GLFW
4870 * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
4871 * cursor, transparently re-centers it and provides unconstrained cursor
4872 * motion. See @ref glfwSetInputMode for more information.
4873 *
4874 * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
4875 * unconstrained and limited only by the minimum and maximum values of
Camilla Berglund6df692b2013-04-26 17:20:31 +02004876 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02004877 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004878 * @param[in] window The desired window.
4879 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004880 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004881 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004882 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004883 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004884 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4885 * GLFW_PLATFORM_ERROR.
4886 *
linkmauvebc8b0482016-10-16 15:52:39 +01004887 * @remark @wayland This function will only work when the cursor mode is
4888 * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
4889 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004890 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004891 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004892 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004893 * @sa @ref glfwGetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004894 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004895 * @since Added in version 3.0. Replaces `glfwSetMousePos`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004896 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004897 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004898 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02004899GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004900
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004901/*! @brief Creates a custom cursor.
urraka40c04a72013-12-04 10:19:22 -03004902 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004903 * Creates a new custom cursor image that can be set for a window with @ref
4904 * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
4905 * Any remaining cursors are destroyed by @ref glfwTerminate.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004906 *
Camilla Berglund85a01bf2015-08-17 21:04:19 +02004907 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02004908 * bits per channel with the red channel first. They are arranged canonically
4909 * as packed sequential rows, starting from the top-left corner.
Camilla Berglund4188c262015-01-18 01:55:25 +01004910 *
4911 * The cursor hotspot is specified in pixels, relative to the upper-left corner
4912 * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
4913 * points to the right and the Y-axis points down.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004914 *
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01004915 * @param[in] image The desired cursor image.
Camilla Berglund4188c262015-01-18 01:55:25 +01004916 * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
4917 * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
Camilla Berglund4188c262015-01-18 01:55:25 +01004918 * @return The handle of the created cursor, or `NULL` if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02004919 * [error](@ref error_handling) occurred.
urraka40c04a72013-12-04 10:19:22 -03004920 *
Camilla Löwy66a48822022-03-15 21:22:49 +01004921 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4922 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01004923 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004924 * @pointer_lifetime The specified image data is copied before this function
4925 * returns.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004926 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004927 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004928 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004929 * @sa @ref cursor_object
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004930 * @sa @ref glfwDestroyCursor
4931 * @sa @ref glfwCreateStandardCursor
Camilla Berglund4591ad22014-09-18 15:03:29 +02004932 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004933 * @since Added in version 3.1.
urraka40c04a72013-12-04 10:19:22 -03004934 *
4935 * @ingroup input
4936 */
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01004937GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
urraka40c04a72013-12-04 10:19:22 -03004938
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004939/*! @brief Creates a cursor with a standard shape.
4940 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02004941 * Returns a cursor with a standard shape, that can be set for a window with
4942 * @ref glfwSetCursor. The images for these cursors come from the system
4943 * cursor theme and their exact appearance will vary between platforms.
4944 *
4945 * Most of these shapes are guaranteed to exist on every supported platform but
4946 * a few may not be present. See the table below for details.
4947 *
4948 * Cursor shape | Windows | macOS | X11 | Wayland
4949 * ------------------------------ | ------- | ----- | ------ | -------
4950 * @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes
4951 * @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes
4952 * @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes
4953 * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes
4954 * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes
4955 * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes
4956 * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
4957 * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
4958 * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes
4959 * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe<sup>2</sup> | Maybe<sup>2</sup>
4960 *
4961 * 1) This uses a private system API and may fail in the future.
4962 *
4963 * 2) This uses a newer standard that not all cursor themes support.
4964 *
4965 * If the requested shape is not available, this function emits a @ref
4966 * GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004967 *
4968 * @param[in] shape One of the [standard shapes](@ref shapes).
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004969 * @return A new cursor ready to use or `NULL` if an
4970 * [error](@ref error_handling) occurred.
4971 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004972 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02004973 * GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
4974 * GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01004975 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004976 * @thread_safety This function must only be called from the main thread.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004977 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02004978 * @sa @ref cursor_standard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004979 * @sa @ref glfwCreateCursor
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004980 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004981 * @since Added in version 3.1.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02004982 *
4983 * @ingroup input
4984 */
4985GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
4986
urraka40c04a72013-12-04 10:19:22 -03004987/*! @brief Destroys a cursor.
4988 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004989 * This function destroys a cursor previously created with @ref
4990 * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
4991 * glfwTerminate.
urraka40c04a72013-12-04 10:19:22 -03004992 *
Camilla Löwy46393072017-02-20 13:45:11 +01004993 * If the specified cursor is current for any window, that window will be
4994 * reverted to the default cursor. This does not affect the cursor mode.
4995 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004996 * @param[in] cursor The cursor object to destroy.
urraka40c04a72013-12-04 10:19:22 -03004997 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004998 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4999 * GLFW_PLATFORM_ERROR.
5000 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005001 * @reentrancy This function must not be called from a callback.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005002 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005003 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005004 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005005 * @sa @ref cursor_object
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005006 * @sa @ref glfwCreateCursor
Camilla Berglund4591ad22014-09-18 15:03:29 +02005007 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005008 * @since Added in version 3.1.
urraka40c04a72013-12-04 10:19:22 -03005009 *
5010 * @ingroup input
5011 */
5012GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
5013
Camilla Berglund4188c262015-01-18 01:55:25 +01005014/*! @brief Sets the cursor for the window.
urraka40c04a72013-12-04 10:19:22 -03005015 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005016 * This function sets the cursor image to be used when the cursor is over the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01005017 * content area of the specified window. The set cursor will only be visible
Camilla Berglund4188c262015-01-18 01:55:25 +01005018 * when the [cursor mode](@ref cursor_mode) of the window is
5019 * `GLFW_CURSOR_NORMAL`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005020 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005021 * On some platforms, the set cursor may not be visible unless the window also
5022 * has input focus.
5023 *
5024 * @param[in] window The window to set the cursor for.
5025 * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
5026 * arrow cursor.
urraka40c04a72013-12-04 10:19:22 -03005027 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005028 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5029 * GLFW_PLATFORM_ERROR.
5030 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005031 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005032 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005033 * @sa @ref cursor_object
Camilla Berglund4591ad22014-09-18 15:03:29 +02005034 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005035 * @since Added in version 3.1.
Camilla Berglund0e205772014-03-24 11:58:35 +01005036 *
urraka40c04a72013-12-04 10:19:22 -03005037 * @ingroup input
5038 */
5039GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
5040
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005041/*! @brief Sets the key callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005042 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005043 * This function sets the key callback of the specified window, which is called
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005044 * when a key is pressed, repeated or released.
5045 *
Camilla Berglund948cc042013-04-16 02:02:22 +02005046 * The key functions deal with physical keys, with layout independent
5047 * [key tokens](@ref keys) named after their values in the standard US keyboard
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005048 * layout. If you want to input text, use the
5049 * [character callback](@ref glfwSetCharCallback) instead.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005050 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005051 * When a window loses input focus, it will generate synthetic key release
5052 * events for all pressed keys. You can tell these events from user-generated
5053 * events by the fact that the synthetic ones are generated after the focus
5054 * loss event has been processed, i.e. after the
5055 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
Camilla Berglund4538a522013-04-24 19:49:46 +02005056 *
Camilla Berglund11615fc2013-05-30 17:19:12 +02005057 * The scancode of a key is specific to that platform or sometimes even to that
5058 * machine. Scancodes are intended to allow users to bind keys that don't have
5059 * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
Camilla Berglund4591ad22014-09-18 15:03:29 +02005060 * state is not saved and so it cannot be queried with @ref glfwGetKey.
Camilla Berglund11615fc2013-05-30 17:19:12 +02005061 *
5062 * Sometimes GLFW needs to generate synthetic key events, in which case the
5063 * scancode may be zero.
5064 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005065 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005066 * @param[in] callback The new key callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005067 * set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005068 * @return The previously set callback, or `NULL` if no callback was set or the
5069 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005070 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005071 * @callback_signature
5072 * @code
5073 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
5074 * @endcode
5075 * For more information about the callback parameters, see the
5076 * [function pointer type](@ref GLFWkeyfun).
5077 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005078 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5079 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005080 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005081 *
5082 * @sa @ref input_key
5083 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005084 * @since Added in version 1.0.
5085 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01005086 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005087 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005088 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005089GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005090
5091/*! @brief Sets the Unicode character callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005092 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005093 * This function sets the character callback of the specified window, which is
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005094 * called when a Unicode character is input.
5095 *
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005096 * The character callback is intended for Unicode text input. As it deals with
5097 * characters, it is keyboard layout dependent, whereas the
5098 * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
5099 * to physical keys, as a key may produce zero, one or more characters. If you
5100 * want to know whether a specific physical key was pressed or released, see
5101 * the key callback instead.
5102 *
5103 * The character callback behaves as system text input normally does and will
5104 * not be called if modifier keys are held down that would prevent normal text
Camilla Berglund8d6f2652016-10-20 00:50:54 +02005105 * input on that platform, for example a Super (Command) key on macOS or Alt key
Camilla Löwy86e7bf42018-12-25 22:11:23 +01005106 * on Windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005107 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005108 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005109 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005110 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005111 * @return The previously set callback, or `NULL` if no callback was set or the
5112 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005113 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005114 * @callback_signature
5115 * @code
5116 * void function_name(GLFWwindow* window, unsigned int codepoint)
5117 * @endcode
5118 * For more information about the callback parameters, see the
5119 * [function pointer type](@ref GLFWcharfun).
5120 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005121 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5122 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005123 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005124 *
5125 * @sa @ref input_char
5126 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005127 * @since Added in version 2.4.
5128 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01005129 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005130 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005131 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005132GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005133
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005134/*! @brief Sets the Unicode character with modifiers callback.
5135 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005136 * This function sets the character with modifiers callback of the specified
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005137 * window, which is called when a Unicode character is input regardless of what
5138 * modifier keys are used.
5139 *
5140 * The character with modifiers callback is intended for implementing custom
5141 * Unicode character input. For regular Unicode text input, see the
5142 * [character callback](@ref glfwSetCharCallback). Like the character
5143 * callback, the character with modifiers callback deals with characters and is
5144 * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
5145 * a key may produce zero, one or more characters. If you want to know whether
5146 * a specific physical key was pressed or released, see the
5147 * [key callback](@ref glfwSetKeyCallback) instead.
5148 *
5149 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005150 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005151 * callback.
5152 * @return The previously set callback, or `NULL` if no callback was set or an
Camilla Berglund999f3552016-08-17 16:48:22 +02005153 * [error](@ref error_handling) occurred.
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005154 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005155 * @callback_signature
5156 * @code
5157 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
5158 * @endcode
5159 * For more information about the callback parameters, see the
5160 * [function pointer type](@ref GLFWcharmodsfun).
5161 *
Camilla Löwyadebcc72017-11-14 23:28:12 +01005162 * @deprecated Scheduled for removal in version 4.0.
5163 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005164 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5165 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005166 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005167 *
5168 * @sa @ref input_char
5169 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005170 * @since Added in version 3.1.
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005171 *
5172 * @ingroup input
5173 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005174GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005175
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005176/*! @brief Sets the mouse button callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005177 *
5178 * This function sets the mouse button callback of the specified window, which
5179 * is called when a mouse button is pressed or released.
5180 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005181 * When a window loses input focus, it will generate synthetic mouse button
5182 * release events for all pressed mouse buttons. You can tell these events
5183 * from user-generated events by the fact that the synthetic ones are generated
5184 * after the focus loss event has been processed, i.e. after the
5185 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
Camilla Berglund4538a522013-04-24 19:49:46 +02005186 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005187 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005188 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005189 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005190 * @return The previously set callback, or `NULL` if no callback was set or the
5191 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005192 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005193 * @callback_signature
5194 * @code
5195 * void function_name(GLFWwindow* window, int button, int action, int mods)
5196 * @endcode
5197 * For more information about the callback parameters, see the
5198 * [function pointer type](@ref GLFWmousebuttonfun).
5199 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005200 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5201 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005202 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005203 *
5204 * @sa @ref input_mouse_button
5205 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005206 * @since Added in version 1.0.
5207 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01005208 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005209 * @ingroup input
5210 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005211GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005212
5213/*! @brief Sets the cursor position callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005214 *
5215 * This function sets the cursor position callback of the specified window,
5216 * which is called when the cursor is moved. The callback is provided with the
Camilla Berglund6d9d8562013-09-28 22:12:50 +02005217 * position, in screen coordinates, relative to the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01005218 * content area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005219 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005220 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005221 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005222 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005223 * @return The previously set callback, or `NULL` if no callback was set or the
5224 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005225 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005226 * @callback_signature
5227 * @code
5228 * void function_name(GLFWwindow* window, double xpos, double ypos);
5229 * @endcode
5230 * For more information about the callback parameters, see the
5231 * [function pointer type](@ref GLFWcursorposfun).
5232 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005233 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5234 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005235 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005236 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005237 * @sa @ref cursor_pos
Camilla Berglund4591ad22014-09-18 15:03:29 +02005238 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005239 * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
Camilla Berglund0e205772014-03-24 11:58:35 +01005240 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005241 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005242 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005243GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005244
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005245/*! @brief Sets the cursor enter/leave callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005246 *
5247 * This function sets the cursor boundary crossing callback of the specified
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01005248 * window, which is called when the cursor enters or leaves the content area of
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005249 * the window.
5250 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005251 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005252 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005253 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005254 * @return The previously set callback, or `NULL` if no callback was set or the
5255 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005256 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005257 * @callback_signature
5258 * @code
5259 * void function_name(GLFWwindow* window, int entered)
5260 * @endcode
5261 * For more information about the callback parameters, see the
5262 * [function pointer type](@ref GLFWcursorenterfun).
5263 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005264 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5265 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005266 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005267 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005268 * @sa @ref cursor_enter
Camilla Berglund4591ad22014-09-18 15:03:29 +02005269 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005270 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01005271 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005272 * @ingroup input
5273 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005274GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005275
5276/*! @brief Sets the scroll callback.
Camilla Berglunde248fb62013-03-29 14:06:23 +01005277 *
5278 * This function sets the scroll callback of the specified window, which is
5279 * called when a scrolling device is used, such as a mouse wheel or scrolling
5280 * area of a touchpad.
5281 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005282 * The scroll callback receives all scrolling input, like that from a mouse
5283 * wheel or a touchpad scrolling area.
5284 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005285 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005286 * @param[in] callback The new scroll callback, or `NULL` to remove the
5287 * currently set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005288 * @return The previously set callback, or `NULL` if no callback was set or the
5289 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005290 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005291 * @callback_signature
5292 * @code
5293 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
5294 * @endcode
5295 * For more information about the callback parameters, see the
5296 * [function pointer type](@ref GLFWscrollfun).
5297 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005298 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5299 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005300 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005301 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005302 * @sa @ref scrolling
Camilla Berglund4591ad22014-09-18 15:03:29 +02005303 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005304 * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
Camilla Berglund0e205772014-03-24 11:58:35 +01005305 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01005306 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005307 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005308GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
Camilla Berglund3249f812010-09-07 17:34:51 +02005309
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005310/*! @brief Sets the path drop callback.
arturo89d07232013-07-10 11:42:14 +02005311 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005312 * This function sets the path drop callback of the specified window, which is
5313 * called when one or more dragged paths are dropped on the window.
arturo89d07232013-07-10 11:42:14 +02005314 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005315 * Because the path array and its strings may have been generated specifically
5316 * for that event, they are not guaranteed to be valid after the callback has
5317 * returned. If you wish to use them after the callback returns, you need to
5318 * make a deep copy.
arturo89d07232013-07-10 11:42:14 +02005319 *
5320 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005321 * @param[in] callback The new file drop callback, or `NULL` to remove the
Camilla Berglund5c8121e2014-03-29 21:35:21 +01005322 * currently set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005323 * @return The previously set callback, or `NULL` if no callback was set or the
5324 * library had not been [initialized](@ref intro_init).
arturo89d07232013-07-10 11:42:14 +02005325 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005326 * @callback_signature
5327 * @code
5328 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
5329 * @endcode
5330 * For more information about the callback parameters, see the
5331 * [function pointer type](@ref GLFWdropfun).
5332 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005333 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5334 *
linkmauvebc8b0482016-10-16 15:52:39 +01005335 * @remark @wayland File drop is currently unimplemented.
5336 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005337 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005338 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005339 * @sa @ref path_drop
Camilla Berglund4591ad22014-09-18 15:03:29 +02005340 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005341 * @since Added in version 3.1.
Camilla Berglund0e205772014-03-24 11:58:35 +01005342 *
arturo89d07232013-07-10 11:42:14 +02005343 * @ingroup input
5344 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005345GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
arturo89d07232013-07-10 11:42:14 +02005346
Camilla Berglundfdd45182013-05-27 15:13:09 +02005347/*! @brief Returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005348 *
Camilla Berglundfdd45182013-05-27 15:13:09 +02005349 * This function returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005350 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005351 * There is no need to call this function before other functions that accept
5352 * a joystick ID, as they all check for presence before performing any other
5353 * work.
5354 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005355 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund0eccf752015-08-23 19:30:04 +02005356 * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005357 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005358 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5359 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5360 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005361 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005362 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005363 * @sa @ref joystick
Camilla Berglund4591ad22014-09-18 15:03:29 +02005364 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005365 * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
Camilla Berglund0e205772014-03-24 11:58:35 +01005366 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005367 * @ingroup input
5368 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005369GLFWAPI int glfwJoystickPresent(int jid);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005370
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02005371/*! @brief Returns the values of all axes of the specified joystick.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005372 *
5373 * This function returns the values of all axes of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005374 * Each element in the array is a value between -1.0 and 1.0.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005375 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005376 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005377 * but will not generate an error. This can be used instead of first calling
5378 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01005379 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005380 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005381 * @param[out] count Where to store the number of axis values in the returned
Camilla Berglund999f3552016-08-17 16:48:22 +02005382 * array. This is set to zero if the joystick is not present or an error
5383 * occurred.
5384 * @return An array of axis values, or `NULL` if the joystick is not present or
5385 * an [error](@ref error_handling) occurred.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02005386 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005387 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5388 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5389 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005390 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5391 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01005392 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01005393 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005394 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02005395 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005396 * @sa @ref joystick_axis
Camilla Berglund4591ad22014-09-18 15:03:29 +02005397 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005398 * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005399 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005400 * @ingroup input
5401 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005402GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005403
Camilla Berglunde93bade2013-06-16 02:33:33 +02005404/*! @brief Returns the state of all buttons of the specified joystick.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005405 *
Camilla Berglunde93bade2013-06-16 02:33:33 +02005406 * This function returns the state of all buttons of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005407 * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005408 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005409 * For backward compatibility with earlier versions that did not have @ref
5410 * glfwGetJoystickHats, the button array also includes all hats, each
5411 * represented as four buttons. The hats are in the same order as returned by
5412 * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
5413 * _left_. To disable these extra buttons, set the @ref
5414 * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
5415 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005416 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005417 * but will not generate an error. This can be used instead of first calling
5418 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01005419 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005420 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005421 * @param[out] count Where to store the number of button states in the returned
Camilla Berglund999f3552016-08-17 16:48:22 +02005422 * array. This is set to zero if the joystick is not present or an error
5423 * occurred.
5424 * @return An array of button states, or `NULL` if the joystick is not present
5425 * or an [error](@ref error_handling) occurred.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02005426 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005427 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5428 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5429 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005430 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5431 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01005432 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01005433 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005434 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02005435 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005436 * @sa @ref joystick_button
Camilla Berglund4591ad22014-09-18 15:03:29 +02005437 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005438 * @since Added in version 2.2.
Camilla Berglund951a9582016-01-31 21:32:14 +01005439 * @glfw3 Changed to return a dynamic array.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005440 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005441 * @ingroup input
5442 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005443GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
Camilla Berglund3249f812010-09-07 17:34:51 +02005444
IntellectualKitty368dec72016-11-25 20:56:24 -07005445/*! @brief Returns the state of all hats of the specified joystick.
5446 *
5447 * This function returns the state of all hats of the specified joystick.
Camilla Löwy798d7c62017-03-01 23:27:20 +01005448 * Each element in the array is one of the following values:
IntellectualKitty368dec72016-11-25 20:56:24 -07005449 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005450 * Name | Value
Camilla Löwybb2ca1d2018-11-27 21:49:19 +01005451 * ---- | -----
Camilla Löwy798d7c62017-03-01 23:27:20 +01005452 * `GLFW_HAT_CENTERED` | 0
5453 * `GLFW_HAT_UP` | 1
5454 * `GLFW_HAT_RIGHT` | 2
5455 * `GLFW_HAT_DOWN` | 4
5456 * `GLFW_HAT_LEFT` | 8
5457 * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
5458 * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
5459 * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
5460 * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
IntellectualKitty368dec72016-11-25 20:56:24 -07005461 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005462 * The diagonal directions are bitwise combinations of the primary (up, right,
5463 * down and left) directions and you can test for these individually by ANDing
5464 * it with the corresponding direction.
IntellectualKitty368dec72016-11-25 20:56:24 -07005465 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005466 * @code
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00005467 * if (hats[2] & GLFW_HAT_RIGHT)
5468 * {
5469 * // State of hat 2 could be right-up, right or right-down
5470 * }
Camilla Löwy798d7c62017-03-01 23:27:20 +01005471 * @endcode
IntellectualKitty368dec72016-11-25 20:56:24 -07005472 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005473 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005474 * but will not generate an error. This can be used instead of first calling
5475 * @ref glfwJoystickPresent.
IntellectualKitty368dec72016-11-25 20:56:24 -07005476 *
5477 * @param[in] jid The [joystick](@ref joysticks) to query.
5478 * @param[out] count Where to store the number of hat states in the returned
5479 * array. This is set to zero if the joystick is not present or an error
5480 * occurred.
5481 * @return An array of hat states, or `NULL` if the joystick is not present
5482 * or an [error](@ref error_handling) occurred.
5483 *
5484 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5485 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5486 *
IntellectualKitty368dec72016-11-25 20:56:24 -07005487 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5488 * should not free it yourself. It is valid until the specified joystick is
5489 * disconnected, this function is called again for that joystick or the library
5490 * is terminated.
5491 *
5492 * @thread_safety This function must only be called from the main thread.
5493 *
5494 * @sa @ref joystick_hat
5495 *
5496 * @since Added in version 3.3.
5497 *
5498 * @ingroup input
5499 */
5500GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
5501
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01005502/*! @brief Returns the name of the specified joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005503 *
5504 * This function returns the name, encoded as UTF-8, of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005505 * The returned string is allocated and freed by GLFW. You should not free it
5506 * yourself.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005507 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005508 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005509 * but will not generate an error. This can be used instead of first calling
5510 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01005511 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005512 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01005513 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
Camilla Berglund999f3552016-08-17 16:48:22 +02005514 * is not present or an [error](@ref error_handling) occurred.
Camilla Berglundd4a08b12012-12-02 17:13:41 +01005515 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005516 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5517 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5518 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005519 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5520 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01005521 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01005522 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005523 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02005524 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005525 * @sa @ref joystick_name
Camilla Berglund4591ad22014-09-18 15:03:29 +02005526 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005527 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005528 *
5529 * @ingroup input
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01005530 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005531GLFWAPI const char* glfwGetJoystickName(int jid);
Camilla Berglund3249f812010-09-07 17:34:51 +02005532
luz.paz7105ff22019-08-12 06:52:31 -04005533/*! @brief Returns the SDL compatible GUID of the specified joystick.
Camilla Löwy5b7281b2017-07-23 16:34:11 +02005534 *
5535 * This function returns the SDL compatible GUID, as a UTF-8 encoded
5536 * hexadecimal string, of the specified joystick. The returned string is
5537 * allocated and freed by GLFW. You should not free it yourself.
5538 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005539 * The GUID is what connects a joystick to a gamepad mapping. A connected
5540 * joystick will always have a GUID even if there is no gamepad mapping
5541 * assigned to it.
5542 *
Camilla Löwy5b7281b2017-07-23 16:34:11 +02005543 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005544 * but will not generate an error. This can be used instead of first calling
5545 * @ref glfwJoystickPresent.
Camilla Löwy5b7281b2017-07-23 16:34:11 +02005546 *
5547 * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
5548 * uniquely identify the make and model of a joystick but does not identify
5549 * a specific unit, e.g. all wired Xbox 360 controllers will have the same
5550 * GUID on that platform. The GUID for a unit may vary between platforms
5551 * depending on what hardware information the platform specific APIs provide.
5552 *
5553 * @param[in] jid The [joystick](@ref joysticks) to query.
5554 * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
5555 * is not present or an [error](@ref error_handling) occurred.
5556 *
5557 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5558 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5559 *
5560 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5561 * should not free it yourself. It is valid until the specified joystick is
5562 * disconnected or the library is terminated.
5563 *
5564 * @thread_safety This function must only be called from the main thread.
5565 *
5566 * @sa @ref gamepad
5567 *
5568 * @since Added in version 3.3.
5569 *
5570 * @ingroup input
5571 */
5572GLFWAPI const char* glfwGetJoystickGUID(int jid);
5573
Camilla Löwy7c2c7852017-12-07 16:19:57 +01005574/*! @brief Sets the user pointer of the specified joystick.
5575 *
5576 * This function sets the user-defined pointer of the specified joystick. The
5577 * current value is retained until the joystick is disconnected. The initial
5578 * value is `NULL`.
5579 *
5580 * This function may be called from the joystick callback, even for a joystick
5581 * that is being disconnected.
5582 *
Camilla Löwyd222a402018-02-25 20:37:31 +01005583 * @param[in] jid The joystick whose pointer to set.
Camilla Löwy7c2c7852017-12-07 16:19:57 +01005584 * @param[in] pointer The new value.
5585 *
5586 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5587 *
5588 * @thread_safety This function may be called from any thread. Access is not
5589 * synchronized.
5590 *
5591 * @sa @ref joystick_userptr
5592 * @sa @ref glfwGetJoystickUserPointer
5593 *
5594 * @since Added in version 3.3.
5595 *
5596 * @ingroup input
5597 */
5598GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
5599
5600/*! @brief Returns the user pointer of the specified joystick.
5601 *
5602 * This function returns the current value of the user-defined pointer of the
5603 * specified joystick. The initial value is `NULL`.
5604 *
5605 * This function may be called from the joystick callback, even for a joystick
5606 * that is being disconnected.
5607 *
Camilla Löwyd222a402018-02-25 20:37:31 +01005608 * @param[in] jid The joystick whose pointer to return.
Camilla Löwy7c2c7852017-12-07 16:19:57 +01005609 *
5610 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5611 *
5612 * @thread_safety This function may be called from any thread. Access is not
5613 * synchronized.
5614 *
5615 * @sa @ref joystick_userptr
5616 * @sa @ref glfwSetJoystickUserPointer
5617 *
5618 * @since Added in version 3.3.
5619 *
5620 * @ingroup input
5621 */
5622GLFWAPI void* glfwGetJoystickUserPointer(int jid);
5623
Camilla Löwy953106e2017-06-18 15:13:25 +02005624/*! @brief Returns whether the specified joystick has a gamepad mapping.
5625 *
5626 * This function returns whether the specified joystick is both present and has
5627 * a gamepad mapping.
5628 *
5629 * If the specified joystick is present but does not have a gamepad mapping
5630 * this function will return `GLFW_FALSE` but will not generate an error. Call
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005631 * @ref glfwJoystickPresent to check if a joystick is present regardless of
5632 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02005633 *
5634 * @param[in] jid The [joystick](@ref joysticks) to query.
5635 * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
5636 * or `GLFW_FALSE` otherwise.
5637 *
5638 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5639 * GLFW_INVALID_ENUM.
5640 *
5641 * @thread_safety This function must only be called from the main thread.
5642 *
5643 * @sa @ref gamepad
5644 * @sa @ref glfwGetGamepadState
5645 *
5646 * @since Added in version 3.3.
5647 *
5648 * @ingroup input
5649 */
5650GLFWAPI int glfwJoystickIsGamepad(int jid);
5651
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005652/*! @brief Sets the joystick configuration callback.
5653 *
5654 * This function sets the joystick configuration callback, or removes the
5655 * currently set callback. This is called when a joystick is connected to or
5656 * disconnected from the system.
5657 *
Camilla Löwya46c95c2017-02-01 04:55:46 +01005658 * For joystick connection and disconnection events to be delivered on all
5659 * platforms, you need to call one of the [event processing](@ref events)
5660 * functions. Joystick disconnection may also be detected and the callback
5661 * called by joystick functions. The function will then return whatever it
Camilla Löwy953106e2017-06-18 15:13:25 +02005662 * returns if the joystick is not present.
Camilla Löwya46c95c2017-02-01 04:55:46 +01005663 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005664 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005665 * callback.
5666 * @return The previously set callback, or `NULL` if no callback was set or the
5667 * library had not been [initialized](@ref intro_init).
5668 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005669 * @callback_signature
5670 * @code
5671 * void function_name(int jid, int event)
5672 * @endcode
5673 * For more information about the callback parameters, see the
5674 * [function pointer type](@ref GLFWjoystickfun).
5675 *
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005676 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5677 *
5678 * @thread_safety This function must only be called from the main thread.
5679 *
5680 * @sa @ref joystick_event
5681 *
5682 * @since Added in version 3.2.
5683 *
5684 * @ingroup input
5685 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005686GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005687
Camilla Löwy953106e2017-06-18 15:13:25 +02005688/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
5689 *
5690 * This function parses the specified ASCII encoded string and updates the
5691 * internal list with any gamepad mappings it finds. This string may
5692 * contain either a single gamepad mapping or many mappings separated by
5693 * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
5694 * source file including empty lines and comments.
5695 *
5696 * See @ref gamepad_mapping for a description of the format.
5697 *
5698 * If there is already a gamepad mapping for a given GUID in the internal list,
5699 * it will be replaced by the one passed to this function. If the library is
5700 * terminated and re-initialized the internal list will revert to the built-in
5701 * default.
5702 *
5703 * @param[in] string The string containing the gamepad mappings.
5704 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
5705 * [error](@ref error_handling) occurred.
5706 *
5707 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5708 * GLFW_INVALID_VALUE.
5709 *
5710 * @thread_safety This function must only be called from the main thread.
5711 *
5712 * @sa @ref gamepad
5713 * @sa @ref glfwJoystickIsGamepad
5714 * @sa @ref glfwGetGamepadName
5715 *
5716 * @since Added in version 3.3.
5717 *
5718 * @ingroup input
5719 */
5720GLFWAPI int glfwUpdateGamepadMappings(const char* string);
5721
5722/*! @brief Returns the human-readable gamepad name for the specified joystick.
5723 *
5724 * This function returns the human-readable name of the gamepad from the
5725 * gamepad mapping assigned to the specified joystick.
5726 *
5727 * If the specified joystick is not present or does not have a gamepad mapping
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005728 * this function will return `NULL` but will not generate an error. Call
5729 * @ref glfwJoystickPresent to check whether it is present regardless of
5730 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02005731 *
5732 * @param[in] jid The [joystick](@ref joysticks) to query.
5733 * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
5734 * joystick is not present, does not have a mapping or an
5735 * [error](@ref error_handling) occurred.
5736 *
InKryptionc19f36b2021-12-05 17:51:43 +01005737 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
5738 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005739 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5740 * should not free it yourself. It is valid until the specified joystick is
5741 * disconnected, the gamepad mappings are updated or the library is terminated.
5742 *
5743 * @thread_safety This function must only be called from the main thread.
5744 *
5745 * @sa @ref gamepad
5746 * @sa @ref glfwJoystickIsGamepad
5747 *
5748 * @since Added in version 3.3.
5749 *
5750 * @ingroup input
5751 */
5752GLFWAPI const char* glfwGetGamepadName(int jid);
5753
5754/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
5755 *
luz.paz7105ff22019-08-12 06:52:31 -04005756 * This function retrieves the state of the specified joystick remapped to
Camilla Löwy953106e2017-06-18 15:13:25 +02005757 * an Xbox-like gamepad.
5758 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005759 * If the specified joystick is not present or does not have a gamepad mapping
5760 * this function will return `GLFW_FALSE` but will not generate an error. Call
5761 * @ref glfwJoystickPresent to check whether it is present regardless of
5762 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02005763 *
5764 * The Guide button may not be available for input as it is often hooked by the
5765 * system or the Steam client.
5766 *
5767 * Not all devices have all the buttons or axes provided by @ref
5768 * GLFWgamepadstate. Unavailable buttons and axes will always report
Camilla Löwy34d20b02018-03-03 22:24:26 +01005769 * `GLFW_RELEASE` and 0.0 respectively.
Camilla Löwy953106e2017-06-18 15:13:25 +02005770 *
5771 * @param[in] jid The [joystick](@ref joysticks) to query.
5772 * @param[out] state The gamepad input state of the joystick.
5773 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
5774 * connected, it has no gamepad mapping or an [error](@ref error_handling)
5775 * occurred.
5776 *
5777 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5778 * GLFW_INVALID_ENUM.
5779 *
Camilla Löwye1495c02018-08-09 13:57:10 +02005780 * @thread_safety This function must only be called from the main thread.
5781 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005782 * @sa @ref gamepad
5783 * @sa @ref glfwUpdateGamepadMappings
5784 * @sa @ref glfwJoystickIsGamepad
5785 *
5786 * @since Added in version 3.3.
5787 *
5788 * @ingroup input
5789 */
5790GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
5791
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005792/*! @brief Sets the clipboard to the specified string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005793 *
5794 * This function sets the system clipboard to the specified, UTF-8 encoded
Camilla Berglund4591ad22014-09-18 15:03:29 +02005795 * string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005796 *
Camilla Löwy31cbb202017-11-04 21:11:58 +01005797 * @param[in] window Deprecated. Any valid window or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005798 * @param[in] string A UTF-8 encoded string.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005799 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005800 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5801 * GLFW_PLATFORM_ERROR.
5802 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005803 * @pointer_lifetime The specified string is copied before this function
5804 * returns.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01005805 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005806 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005807 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005808 * @sa @ref clipboard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005809 * @sa @ref glfwGetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005810 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005811 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005812 *
Camilla Berglund8d170c72014-09-09 16:26:57 +02005813 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005814 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005815GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005816
Camilla Berglund4591ad22014-09-18 15:03:29 +02005817/*! @brief Returns the contents of the clipboard as a string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005818 *
5819 * This function returns the contents of the system clipboard, if it contains
Camilla Berglundcf9079c2015-09-16 18:51:49 +02005820 * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
Camilla Berglund0b650532015-09-16 16:27:28 +02005821 * if its contents cannot be converted, `NULL` is returned and a @ref
5822 * GLFW_FORMAT_UNAVAILABLE error is generated.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005823 *
Camilla Löwy31cbb202017-11-04 21:11:58 +01005824 * @param[in] window Deprecated. Any valid window or `NULL`.
Camilla Berglund71d2b572013-03-12 15:33:05 +01005825 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
Camilla Berglund4591ad22014-09-18 15:03:29 +02005826 * if an [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005827 *
InKryptionbb193322021-11-22 23:32:29 +00005828 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5829 * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01005830 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005831 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5832 * should not free it yourself. It is valid until the next call to @ref
Camilla Berglund6be821c2014-10-06 23:18:33 +02005833 * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
5834 * is terminated.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005835 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005836 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005837 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005838 * @sa @ref clipboard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005839 * @sa @ref glfwSetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005840 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005841 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005842 *
Camilla Berglund8d170c72014-09-09 16:26:57 +02005843 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005844 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005845GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
Ralph Eastwood31c91542011-09-21 10:09:47 +01005846
Camilla Löwybb6945a2019-05-20 17:13:09 +02005847/*! @brief Returns the GLFW time.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005848 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02005849 * This function returns the current GLFW time, in seconds. Unless the time
5850 * has been set using @ref glfwSetTime it measures time elapsed since GLFW was
5851 * initialized.
5852 *
5853 * This function and @ref glfwSetTime are helper functions on top of @ref
5854 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005855 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005856 * The resolution of the timer is system dependent, but is usually on the order
5857 * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
Camilla Löwy56a4cb02021-07-13 21:50:09 +02005858 * time source on each operating system.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005859 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02005860 * @return The current time, in seconds, or zero if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02005861 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005862 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005863 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5864 *
Camilla Berglund20bce152016-05-30 16:04:37 +02005865 * @thread_safety This function may be called from any thread. Reading and
Camilla Löwybb6945a2019-05-20 17:13:09 +02005866 * writing of the internal base time is not atomic, so it needs to be
Camilla Berglund20bce152016-05-30 16:04:37 +02005867 * externally synchronized with calls to @ref glfwSetTime.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005868 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005869 * @sa @ref time
Camilla Berglund4591ad22014-09-18 15:03:29 +02005870 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005871 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005872 *
5873 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005874 */
Camilla Berglund9a716692010-09-08 16:40:43 +02005875GLFWAPI double glfwGetTime(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02005876
Camilla Löwybb6945a2019-05-20 17:13:09 +02005877/*! @brief Sets the GLFW time.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005878 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02005879 * This function sets the current GLFW time, in seconds. The value must be
5880 * a positive finite number less than or equal to 18446744073.0, which is
5881 * approximately 584.5 years.
5882 *
5883 * This function and @ref glfwGetTime are helper functions on top of @ref
5884 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005885 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005886 * @param[in] time The new value, in seconds.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005887 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005888 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5889 * GLFW_INVALID_VALUE.
5890 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02005891 * @remark The upper limit of GLFW time is calculated as
Camilla Berglund6e20cda2015-03-10 12:01:38 +01005892 * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
5893 * storing nanoseconds in 64 bits. The limit may be increased in the future.
5894 *
Camilla Berglund20bce152016-05-30 16:04:37 +02005895 * @thread_safety This function may be called from any thread. Reading and
Camilla Löwybb6945a2019-05-20 17:13:09 +02005896 * writing of the internal base time is not atomic, so it needs to be
Camilla Berglund20bce152016-05-30 16:04:37 +02005897 * externally synchronized with calls to @ref glfwGetTime.
Camilla Berglund0e205772014-03-24 11:58:35 +01005898 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005899 * @sa @ref time
Camilla Berglunde248fb62013-03-29 14:06:23 +01005900 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005901 * @since Added in version 2.2.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005902 *
5903 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005904 */
5905GLFWAPI void glfwSetTime(double time);
5906
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005907/*! @brief Returns the current value of the raw timer.
5908 *
Camilla Berglund337c77a2016-03-06 14:11:14 +01005909 * This function returns the current value of the raw timer, measured in
5910 * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
5911 * glfwGetTimerFrequency.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005912 *
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00005913 * @return The value of the timer, or zero if an
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005914 * [error](@ref error_handling) occurred.
5915 *
Camilla Berglund46fce402016-03-07 13:35:37 +01005916 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005917 *
5918 * @thread_safety This function may be called from any thread.
5919 *
5920 * @sa @ref time
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005921 * @sa @ref glfwGetTimerFrequency
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005922 *
5923 * @since Added in version 3.2.
5924 *
5925 * @ingroup input
5926 */
Camilla Berglund5661d032016-03-23 10:09:07 +01005927GLFWAPI uint64_t glfwGetTimerValue(void);
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005928
5929/*! @brief Returns the frequency, in Hz, of the raw timer.
5930 *
Camilla Berglunddefaea32016-03-07 13:36:54 +01005931 * This function returns the frequency, in Hz, of the raw timer.
5932 *
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005933 * @return The frequency of the timer, in Hz, or zero if an
5934 * [error](@ref error_handling) occurred.
5935 *
Camilla Berglund46fce402016-03-07 13:35:37 +01005936 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005937 *
5938 * @thread_safety This function may be called from any thread.
5939 *
5940 * @sa @ref time
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005941 * @sa @ref glfwGetTimerValue
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005942 *
5943 * @since Added in version 3.2.
5944 *
5945 * @ingroup input
5946 */
Camilla Berglund5661d032016-03-23 10:09:07 +01005947GLFWAPI uint64_t glfwGetTimerFrequency(void);
Camilla Berglund31f67dd2016-03-06 11:38:55 +01005948
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005949/*! @brief Makes the context of the specified window current for the calling
5950 * thread.
5951 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005952 * This function makes the OpenGL or OpenGL ES context of the specified window
Camilla Löwyf2756d02017-11-02 19:30:12 +01005953 * current on the calling thread. A context must only be made current on
Camilla Berglund4591ad22014-09-18 15:03:29 +02005954 * a single thread at a time and each thread can have only a single current
5955 * context at a time.
5956 *
Camilla Löwyf2756d02017-11-02 19:30:12 +01005957 * When moving a context between threads, you must make it non-current on the
5958 * old thread before making it current on the new one.
5959 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005960 * By default, making a context non-current implicitly forces a pipeline flush.
5961 * On machines that support `GL_KHR_context_flush_control`, you can control
5962 * whether a context performs this flush by setting the
Camilla Löwyce161c22016-12-06 01:14:23 +01005963 * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
5964 * hint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005965 *
Camilla Berglund98b478f2015-11-05 13:44:15 +01005966 * The specified window must have an OpenGL or OpenGL ES context. Specifying
5967 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
5968 * error.
5969 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01005970 * @param[in] window The window whose context to make current, or `NULL` to
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005971 * detach the current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005972 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005973 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5974 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
5975 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005976 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005977 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005978 * @sa @ref context_current
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005979 * @sa @ref glfwGetCurrentContext
Camilla Berglunde248fb62013-03-29 14:06:23 +01005980 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005981 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005982 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01005983 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005984 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005985GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005986
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005987/*! @brief Returns the window whose context is current on the calling thread.
5988 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005989 * This function returns the window whose OpenGL or OpenGL ES context is
5990 * current on the calling thread.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005991 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01005992 * @return The window whose context is current, or `NULL` if no window's
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005993 * context is current.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005994 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005995 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5996 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005997 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005998 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005999 * @sa @ref context_current
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006000 * @sa @ref glfwMakeContextCurrent
Camilla Berglunde248fb62013-03-29 14:06:23 +01006001 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006002 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006003 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01006004 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006005 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01006006GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006007
6008/*! @brief Swaps the front and back buffers of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006009 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006010 * This function swaps the front and back buffers of the specified window when
6011 * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
6012 * zero, the GPU driver waits the specified number of screen updates before
6013 * swapping the buffers.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006014 *
Camilla Berglund98b478f2015-11-05 13:44:15 +01006015 * The specified window must have an OpenGL or OpenGL ES context. Specifying
6016 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
6017 * error.
6018 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006019 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6020 * see `vkQueuePresentKHR` instead.
6021 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01006022 * @param[in] window The window whose buffers to swap.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006023 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006024 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6025 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6026 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006027 * @remark __EGL:__ The context of the specified window must be current on the
Camilla Berglund276b1bc2016-01-31 19:17:18 +01006028 * calling thread.
6029 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006030 * @thread_safety This function may be called from any thread.
Camilla Berglund401033c2013-03-12 19:17:07 +01006031 *
Camilla Berglund4188c262015-01-18 01:55:25 +01006032 * @sa @ref buffer_swap
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006033 * @sa @ref glfwSwapInterval
Camilla Berglunde248fb62013-03-29 14:06:23 +01006034 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006035 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01006036 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006037 *
6038 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006039 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01006040GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006041
6042/*! @brief Sets the swap interval for the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006043 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006044 * This function sets the swap interval for the current OpenGL or OpenGL ES
6045 * context, i.e. the number of screen updates to wait from the time @ref
6046 * glfwSwapBuffers was called before swapping the buffers and returning. This
6047 * is sometimes called _vertical synchronization_, _vertical retrace
6048 * synchronization_ or just _vsync_.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006049 *
Camilla Löwy8094a1c2017-11-27 15:53:59 +01006050 * A context that supports either of the `WGL_EXT_swap_control_tear` and
Camilla Löwybfe2d422017-11-27 01:18:51 +01006051 * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
6052 * intervals, which allows the driver to swap immediately even if a frame
6053 * arrives a little bit late. You can check for these extensions with @ref
6054 * glfwExtensionSupported.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02006055 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006056 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01006057 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006058 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006059 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6060 * see the present mode of your swapchain instead.
6061 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02006062 * @param[in] interval The minimum number of screen updates to wait for
6063 * until the buffers are swapped by @ref glfwSwapBuffers.
6064 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006065 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6066 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6067 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006068 * @remark This function is not called during context creation, leaving the
Camilla Löwy56a4cb02021-07-13 21:50:09 +02006069 * swap interval set to whatever is the default for that API. This is done
Camilla Berglund3af1c412013-09-19 21:37:01 +02006070 * because some swap interval extensions used by GLFW do not allow the swap
6071 * interval to be reset to zero once it has been set to a non-zero value.
6072 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006073 * @remark Some GPU drivers do not honor the requested swap interval, either
Camilla Berglund11c22d62015-02-19 15:33:51 +01006074 * because of a user setting that overrides the application's request or due to
6075 * bugs in the driver.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02006076 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006077 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006078 *
Camilla Berglund4188c262015-01-18 01:55:25 +01006079 * @sa @ref buffer_swap
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006080 * @sa @ref glfwSwapBuffers
Camilla Berglunde248fb62013-03-29 14:06:23 +01006081 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006082 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006083 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01006084 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006085 */
6086GLFWAPI void glfwSwapInterval(int interval);
6087
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006088/*! @brief Returns whether the specified extension is available.
6089 *
Camilla Berglund608109c2013-04-11 20:18:46 +02006090 * This function returns whether the specified
Camilla Berglund001c50c2016-02-19 09:13:56 +01006091 * [API extension](@ref context_glext) is supported by the current OpenGL or
6092 * OpenGL ES context. It searches both for client API extension and context
6093 * creation API extensions.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006094 *
6095 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01006096 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006097 *
6098 * As this functions retrieves and searches one or more extension strings each
6099 * call, it is recommended that you cache its results if it is going to be used
6100 * frequently. The extension strings will not change during the lifetime of
6101 * a context, so there is no danger in doing this.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006102 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006103 * This function does not apply to Vulkan. If you are using Vulkan, see @ref
6104 * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
6105 * and `vkEnumerateDeviceExtensionProperties` instead.
6106 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006107 * @param[in] extension The ASCII encoded name of the extension.
Camilla Berglund0eccf752015-08-23 19:30:04 +02006108 * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
6109 * otherwise.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006110 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006111 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6112 * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
6113 * GLFW_PLATFORM_ERROR.
6114 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006115 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006116 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006117 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006118 * @sa @ref glfwGetProcAddress
Camilla Berglund4591ad22014-09-18 15:03:29 +02006119 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006120 * @since Added in version 1.0.
Camilla Berglunde248fb62013-03-29 14:06:23 +01006121 *
6122 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006123 */
6124GLFWAPI int glfwExtensionSupported(const char* extension);
6125
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006126/*! @brief Returns the address of the specified function for the current
6127 * context.
6128 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006129 * This function returns the address of the specified OpenGL or OpenGL ES
Camilla Berglund11c22d62015-02-19 15:33:51 +01006130 * [core or extension function](@ref context_glext), if it is supported
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02006131 * by the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006132 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006133 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01006134 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006135 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006136 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6137 * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
6138 * `vkGetDeviceProcAddr` instead.
6139 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006140 * @param[in] procname The ASCII encoded name of the function.
Camilla Berglunda36e3a22015-11-05 17:14:26 +01006141 * @return The address of the function, or `NULL` if an
6142 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006143 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006144 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6145 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6146 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006147 * @remark The address of a given function is not guaranteed to be the same
Camilla Berglund4591ad22014-09-18 15:03:29 +02006148 * between contexts.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006149 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006150 * @remark This function may return a non-`NULL` address despite the
Camilla Berglund11c22d62015-02-19 15:33:51 +01006151 * associated version or extension not being available. Always check the
Camilla Berglundc8e06872015-08-27 21:40:22 +02006152 * context version or extension string first.
Camilla Berglund11c22d62015-02-19 15:33:51 +01006153 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006154 * @pointer_lifetime The returned function pointer is valid until the context
6155 * is destroyed or the library is terminated.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006156 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006157 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006158 *
6159 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006160 * @sa @ref glfwExtensionSupported
Camilla Berglund4591ad22014-09-18 15:03:29 +02006161 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006162 * @since Added in version 1.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006163 *
6164 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006165 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02006166GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
Camilla Berglund3249f812010-09-07 17:34:51 +02006167
Camilla Löwy98bdd362017-02-07 20:56:48 +01006168/*! @brief Returns whether the Vulkan loader and an ICD have been found.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006169 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01006170 * This function returns whether the Vulkan loader and any minimally functional
6171 * ICD have been found.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006172 *
Camilla Löwy4be04442021-10-12 12:54:19 +02006173 * The availability of a Vulkan loader and even an ICD does not by itself guarantee that
6174 * surface creation or even instance creation is possible. Call @ref
6175 * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
6176 * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
6177 * check whether a queue family of a physical device supports image presentation.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006178 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01006179 * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
6180 * otherwise.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006181 *
6182 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
6183 *
6184 * @thread_safety This function may be called from any thread.
6185 *
6186 * @sa @ref vulkan_support
6187 *
6188 * @since Added in version 3.2.
6189 *
6190 * @ingroup vulkan
6191 */
6192GLFWAPI int glfwVulkanSupported(void);
6193
6194/*! @brief Returns the Vulkan instance extensions required by GLFW.
6195 *
6196 * This function returns an array of names of Vulkan instance extensions required
6197 * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
Lukas Zanner84b13112019-06-14 12:53:57 +02006198 * list will always contain `VK_KHR_surface`, so if you don't require any
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006199 * additional extensions you can pass this list directly to the
6200 * `VkInstanceCreateInfo` struct.
6201 *
6202 * If Vulkan is not available on the machine, this function returns `NULL` and
6203 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01006204 * to check whether Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006205 *
6206 * If Vulkan is available but no set of extensions allowing window surface
6207 * creation was found, this function returns `NULL`. You may still use Vulkan
6208 * for off-screen rendering and compute work.
6209 *
6210 * @param[out] count Where to store the number of extensions in the returned
6211 * array. This is set to zero if an error occurred.
6212 * @return An array of ASCII encoded extension names, or `NULL` if an
6213 * [error](@ref error_handling) occurred.
6214 *
6215 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6216 * GLFW_API_UNAVAILABLE.
6217 *
Camilla Berglund67931bd2016-10-26 16:58:56 +02006218 * @remark Additional extensions may be required by future versions of GLFW.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006219 * You should check if any extensions you wish to enable are already in the
6220 * returned array, as it is an error to specify an extension more than once in
6221 * the `VkInstanceCreateInfo` struct.
6222 *
6223 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
6224 * should not free it yourself. It is guaranteed to be valid only until the
6225 * library is terminated.
6226 *
6227 * @thread_safety This function may be called from any thread.
6228 *
6229 * @sa @ref vulkan_ext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006230 * @sa @ref glfwCreateWindowSurface
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006231 *
6232 * @since Added in version 3.2.
6233 *
6234 * @ingroup vulkan
6235 */
Camilla Berglund7ab7d8b2016-03-23 10:24:01 +01006236GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006237
6238#if defined(VK_VERSION_1_0)
6239
6240/*! @brief Returns the address of the specified Vulkan instance function.
6241 *
6242 * This function returns the address of the specified Vulkan core or extension
6243 * function for the specified instance. If instance is set to `NULL` it can
6244 * return any function exported from the Vulkan loader, including at least the
6245 * following functions:
6246 *
6247 * - `vkEnumerateInstanceExtensionProperties`
6248 * - `vkEnumerateInstanceLayerProperties`
6249 * - `vkCreateInstance`
6250 * - `vkGetInstanceProcAddr`
6251 *
6252 * If Vulkan is not available on the machine, this function returns `NULL` and
6253 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01006254 * to check whether Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006255 *
6256 * This function is equivalent to calling `vkGetInstanceProcAddr` with
6257 * a platform-specific query of the Vulkan loader as a fallback.
6258 *
6259 * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
6260 * functions related to instance creation.
6261 * @param[in] procname The ASCII encoded name of the function.
6262 * @return The address of the function, or `NULL` if an
6263 * [error](@ref error_handling) occurred.
6264 *
6265 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6266 * GLFW_API_UNAVAILABLE.
6267 *
6268 * @pointer_lifetime The returned function pointer is valid until the library
6269 * is terminated.
6270 *
6271 * @thread_safety This function may be called from any thread.
6272 *
6273 * @sa @ref vulkan_proc
6274 *
6275 * @since Added in version 3.2.
6276 *
6277 * @ingroup vulkan
6278 */
6279GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
6280
6281/*! @brief Returns whether the specified queue family can present images.
6282 *
6283 * This function returns whether the specified queue family of the specified
6284 * physical device supports presentation to the platform GLFW was built for.
6285 *
6286 * If Vulkan or the required window surface creation instance extensions are
6287 * not available on the machine, or if the specified instance was not created
6288 * with the required extensions, this function returns `GLFW_FALSE` and
6289 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01006290 * to check whether Vulkan is at least minimally available and @ref
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006291 * glfwGetRequiredInstanceExtensions to check what instance extensions are
6292 * required.
6293 *
6294 * @param[in] instance The instance that the physical device belongs to.
6295 * @param[in] device The physical device that the queue family belongs to.
6296 * @param[in] queuefamily The index of the queue family to query.
6297 * @return `GLFW_TRUE` if the queue family supports presentation, or
6298 * `GLFW_FALSE` otherwise.
6299 *
6300 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6301 * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
6302 *
Camilla Berglunde94d1662016-10-14 01:46:56 +02006303 * @remark @macos This function currently always returns `GLFW_TRUE`, as the
Camilla Löwy4c90e212020-12-10 00:28:09 +01006304 * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
Camilla Berglunde94d1662016-10-14 01:46:56 +02006305 * a `vkGetPhysicalDevice*PresentationSupport` type function.
6306 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006307 * @thread_safety This function may be called from any thread. For
6308 * synchronization details of Vulkan objects, see the Vulkan specification.
6309 *
6310 * @sa @ref vulkan_present
6311 *
6312 * @since Added in version 3.2.
6313 *
6314 * @ingroup vulkan
6315 */
6316GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
6317
6318/*! @brief Creates a Vulkan surface for the specified window.
6319 *
6320 * This function creates a Vulkan surface for the specified window.
6321 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01006322 * If the Vulkan loader or at least one minimally functional ICD were not found,
6323 * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
6324 * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
6325 * Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006326 *
6327 * If the required window surface creation instance extensions are not
6328 * available or if the specified instance was not created with these extensions
6329 * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
6330 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
6331 * glfwGetRequiredInstanceExtensions to check what instance extensions are
6332 * required.
6333 *
Corentin Wallez8a8eefa2018-01-30 13:25:17 -05006334 * The window surface cannot be shared with another API so the window must
6335 * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
6336 * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
6337 * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
6338 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006339 * The window surface must be destroyed before the specified Vulkan instance.
6340 * It is the responsibility of the caller to destroy the window surface. GLFW
6341 * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
6342 * surface.
6343 *
6344 * @param[in] instance The Vulkan instance to create the surface in.
6345 * @param[in] window The window to create the surface for.
6346 * @param[in] allocator The allocator to use, or `NULL` to use the default
6347 * allocator.
6348 * @param[out] surface Where to store the handle of the surface. This is set
6349 * to `VK_NULL_HANDLE` if an error occurred.
6350 * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
6351 * [error](@ref error_handling) occurred.
6352 *
6353 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Corentin Wallez8a8eefa2018-01-30 13:25:17 -05006354 * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006355 *
Camilla Berglund67931bd2016-10-26 16:58:56 +02006356 * @remark If an error occurs before the creation call is made, GLFW returns
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006357 * the Vulkan error code most appropriate for the error. Appropriate use of
6358 * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
Camilla Berglundee33dcd2016-03-07 14:42:51 +01006359 * eliminate almost all occurrences of these errors.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006360 *
Camilla Löwy05b0e2f2021-12-26 18:02:00 +01006361 * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
6362 * `VK_MVK_macos_surface` extension as a fallback. The name of the selected
6363 * extension, if any, is included in the array returned by @ref
6364 * glfwGetRequiredInstanceExtensions.
Camilla Berglunde94d1662016-10-14 01:46:56 +02006365 *
6366 * @remark @macos This function creates and sets a `CAMetalLayer` instance for
6367 * the window content view, which is required for MoltenVK to function.
6368 *
Camilla Löwy05b0e2f2021-12-26 18:02:00 +01006369 * @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension,
6370 * with the `VK_KHR_xlib_surface` extension as a fallback. You can make
6371 * `VK_KHR_xlib_surface` the preferred extension by setting the
Camilla Löwya25e8eb2020-12-10 00:11:44 +01006372 * [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
Camilla Löwy05b0e2f2021-12-26 18:02:00 +01006373 * hint. The name of the selected extension, if any, is included in the array
6374 * returned by @ref glfwGetRequiredInstanceExtensions.
Camilla Löwya25e8eb2020-12-10 00:11:44 +01006375 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006376 * @thread_safety This function may be called from any thread. For
6377 * synchronization details of Vulkan objects, see the Vulkan specification.
6378 *
6379 * @sa @ref vulkan_surface
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006380 * @sa @ref glfwGetRequiredInstanceExtensions
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006381 *
6382 * @since Added in version 3.2.
6383 *
6384 * @ingroup vulkan
6385 */
6386GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
6387
6388#endif /*VK_VERSION_1_0*/
6389
Camilla Berglund3249f812010-09-07 17:34:51 +02006390
Camilla Berglund4afc67c2011-07-27 17:09:17 +02006391/*************************************************************************
6392 * Global definition cleanup
6393 *************************************************************************/
6394
6395/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
6396
Camilla Berglund4afc67c2011-07-27 17:09:17 +02006397#ifdef GLFW_WINGDIAPI_DEFINED
6398 #undef WINGDIAPI
6399 #undef GLFW_WINGDIAPI_DEFINED
6400#endif
6401
6402#ifdef GLFW_CALLBACK_DEFINED
6403 #undef CALLBACK
6404 #undef GLFW_CALLBACK_DEFINED
6405#endif
6406
Camilla Löwybe51c202017-07-03 14:25:47 +02006407/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
6408 * defined by some gl.h variants (OpenBSD) so define it after if needed.
6409 */
6410#ifndef GLAPIENTRY
6411 #define GLAPIENTRY APIENTRY
Camilla Löwyce85c7d2022-05-03 19:54:08 +02006412 #define GLFW_GLAPIENTRY_DEFINED
Camilla Löwybe51c202017-07-03 14:25:47 +02006413#endif
6414
Camilla Berglund4afc67c2011-07-27 17:09:17 +02006415/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
6416
6417
Camilla Berglund3249f812010-09-07 17:34:51 +02006418#ifdef __cplusplus
6419}
6420#endif
6421
Camilla Berglundf8df91d2013-01-15 01:59:56 +01006422#endif /* _glfw3_h_ */
Camilla Berglund3249f812010-09-07 17:34:51 +02006423