blob: 79b0628849e0398ae21305f441be7137e98380dc [file] [log] [blame]
Camilla Berglund2955cd32010-11-17 15:42:55 +01001/*************************************************************************
Camilla Löwyd24ee992024-02-29 15:28:46 +01002 * GLFW 3.5 - 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öwyd24ee992024-02-29 15:28:46 +0100294#define GLFW_VERSION_MINOR 5
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)
Camilla Löwy9959dc62023-12-04 20:06:10 +0100364
365/*! @ingroup input
366 */
367#define GLFW_KEY_UNKNOWN -1
368
IntellectualKitty368dec72016-11-25 20:56:24 -0700369/*! @} */
370
Camilla Löwy9959dc62023-12-04 20:06:10 +0100371/*! @defgroup keys Keyboard key tokens
372 * @brief Keyboard key tokens.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200373 *
Camilla Berglund4188c262015-01-18 01:55:25 +0100374 * See [key input](@ref input_key) for how these are used.
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200375 *
Camilla Berglund4188c262015-01-18 01:55:25 +0100376 * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
377 * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
378 * put in the 256+ range).
379 *
380 * The naming of the key codes follow these rules:
381 * - The US keyboard layout is used
luz paz0fe96ec2021-09-15 08:20:56 -0400382 * - Names of printable alphanumeric characters are used (e.g. "A", "R",
Camilla Berglund4188c262015-01-18 01:55:25 +0100383 * "3", etc.)
384 * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
385 * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
386 * correspond to the Unicode standard (usually for brevity)
387 * - Keys that lack a clear US mapping are named "WORLD_x"
388 * - For non-printable keys, custom names are used (e.g. "F4",
389 * "BACKSPACE", etc.)
Camilla Berglund8282a8f2013-04-10 23:01:12 +0200390 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100391 * @ingroup input
392 * @{
393 */
394
Marcusc0cb4c22011-01-02 11:18:14 +0100395/* Printable keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100396#define GLFW_KEY_SPACE 32
397#define GLFW_KEY_APOSTROPHE 39 /* ' */
398#define GLFW_KEY_COMMA 44 /* , */
399#define GLFW_KEY_MINUS 45 /* - */
400#define GLFW_KEY_PERIOD 46 /* . */
401#define GLFW_KEY_SLASH 47 /* / */
402#define GLFW_KEY_0 48
403#define GLFW_KEY_1 49
404#define GLFW_KEY_2 50
405#define GLFW_KEY_3 51
406#define GLFW_KEY_4 52
407#define GLFW_KEY_5 53
408#define GLFW_KEY_6 54
409#define GLFW_KEY_7 55
410#define GLFW_KEY_8 56
411#define GLFW_KEY_9 57
412#define GLFW_KEY_SEMICOLON 59 /* ; */
413#define GLFW_KEY_EQUAL 61 /* = */
414#define GLFW_KEY_A 65
415#define GLFW_KEY_B 66
416#define GLFW_KEY_C 67
417#define GLFW_KEY_D 68
418#define GLFW_KEY_E 69
419#define GLFW_KEY_F 70
420#define GLFW_KEY_G 71
421#define GLFW_KEY_H 72
422#define GLFW_KEY_I 73
423#define GLFW_KEY_J 74
424#define GLFW_KEY_K 75
425#define GLFW_KEY_L 76
426#define GLFW_KEY_M 77
427#define GLFW_KEY_N 78
428#define GLFW_KEY_O 79
429#define GLFW_KEY_P 80
430#define GLFW_KEY_Q 81
431#define GLFW_KEY_R 82
432#define GLFW_KEY_S 83
433#define GLFW_KEY_T 84
434#define GLFW_KEY_U 85
435#define GLFW_KEY_V 86
436#define GLFW_KEY_W 87
437#define GLFW_KEY_X 88
438#define GLFW_KEY_Y 89
439#define GLFW_KEY_Z 90
440#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
441#define GLFW_KEY_BACKSLASH 92 /* \ */
442#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
443#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
444#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
445#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
Marcusc0cb4c22011-01-02 11:18:14 +0100446
447/* Function keys */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100448#define GLFW_KEY_ESCAPE 256
449#define GLFW_KEY_ENTER 257
450#define GLFW_KEY_TAB 258
451#define GLFW_KEY_BACKSPACE 259
452#define GLFW_KEY_INSERT 260
453#define GLFW_KEY_DELETE 261
454#define GLFW_KEY_RIGHT 262
455#define GLFW_KEY_LEFT 263
456#define GLFW_KEY_DOWN 264
457#define GLFW_KEY_UP 265
458#define GLFW_KEY_PAGE_UP 266
459#define GLFW_KEY_PAGE_DOWN 267
460#define GLFW_KEY_HOME 268
461#define GLFW_KEY_END 269
462#define GLFW_KEY_CAPS_LOCK 280
463#define GLFW_KEY_SCROLL_LOCK 281
464#define GLFW_KEY_NUM_LOCK 282
465#define GLFW_KEY_PRINT_SCREEN 283
466#define GLFW_KEY_PAUSE 284
467#define GLFW_KEY_F1 290
468#define GLFW_KEY_F2 291
469#define GLFW_KEY_F3 292
470#define GLFW_KEY_F4 293
471#define GLFW_KEY_F5 294
472#define GLFW_KEY_F6 295
473#define GLFW_KEY_F7 296
474#define GLFW_KEY_F8 297
475#define GLFW_KEY_F9 298
476#define GLFW_KEY_F10 299
477#define GLFW_KEY_F11 300
478#define GLFW_KEY_F12 301
479#define GLFW_KEY_F13 302
480#define GLFW_KEY_F14 303
481#define GLFW_KEY_F15 304
482#define GLFW_KEY_F16 305
483#define GLFW_KEY_F17 306
484#define GLFW_KEY_F18 307
485#define GLFW_KEY_F19 308
486#define GLFW_KEY_F20 309
487#define GLFW_KEY_F21 310
488#define GLFW_KEY_F22 311
489#define GLFW_KEY_F23 312
490#define GLFW_KEY_F24 313
491#define GLFW_KEY_F25 314
492#define GLFW_KEY_KP_0 320
493#define GLFW_KEY_KP_1 321
494#define GLFW_KEY_KP_2 322
495#define GLFW_KEY_KP_3 323
496#define GLFW_KEY_KP_4 324
497#define GLFW_KEY_KP_5 325
498#define GLFW_KEY_KP_6 326
499#define GLFW_KEY_KP_7 327
500#define GLFW_KEY_KP_8 328
501#define GLFW_KEY_KP_9 329
502#define GLFW_KEY_KP_DECIMAL 330
503#define GLFW_KEY_KP_DIVIDE 331
504#define GLFW_KEY_KP_MULTIPLY 332
505#define GLFW_KEY_KP_SUBTRACT 333
506#define GLFW_KEY_KP_ADD 334
507#define GLFW_KEY_KP_ENTER 335
508#define GLFW_KEY_KP_EQUAL 336
509#define GLFW_KEY_LEFT_SHIFT 340
510#define GLFW_KEY_LEFT_CONTROL 341
511#define GLFW_KEY_LEFT_ALT 342
512#define GLFW_KEY_LEFT_SUPER 343
513#define GLFW_KEY_RIGHT_SHIFT 344
514#define GLFW_KEY_RIGHT_CONTROL 345
515#define GLFW_KEY_RIGHT_ALT 346
516#define GLFW_KEY_RIGHT_SUPER 347
517#define GLFW_KEY_MENU 348
Camilla Berglund9c315412015-07-02 14:24:50 +0200518
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100519#define GLFW_KEY_LAST GLFW_KEY_MENU
Marcusc0cb4c22011-01-02 11:18:14 +0100520
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100521/*! @} */
522
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200523/*! @defgroup mods Modifier key flags
Camilla Löwy21eabd32017-02-06 17:31:25 +0100524 * @brief Modifier key flags.
Camilla Berglund4188c262015-01-18 01:55:25 +0100525 *
526 * See [key input](@ref input_key) for how these are used.
527 *
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200528 * @ingroup input
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100529 * @{ */
530
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200531/*! @brief If this bit is set one or more Shift keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100532 *
533 * If this bit is set one or more Shift keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100534 */
535#define GLFW_MOD_SHIFT 0x0001
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200536/*! @brief If this bit is set one or more Control keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100537 *
538 * If this bit is set one or more Control keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100539 */
Camilla Berglund3bcffba2013-05-23 14:11:05 +0200540#define GLFW_MOD_CONTROL 0x0002
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200541/*! @brief If this bit is set one or more Alt keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100542 *
543 * If this bit is set one or more Alt keys were held down.
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100544 */
545#define GLFW_MOD_ALT 0x0004
Camilla Berglund98cbf6f2013-05-23 14:42:33 +0200546/*! @brief If this bit is set one or more Super keys were held down.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100547 *
548 * If this bit is set one or more Super keys were held down.
Noel Cowereff85f92013-05-23 13:22:27 +0200549 */
550#define GLFW_MOD_SUPER 0x0008
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +0100551/*! @brief If this bit is set the Caps Lock key is enabled.
552 *
553 * If this bit is set the Caps Lock key is enabled and the @ref
554 * GLFW_LOCK_KEY_MODS input mode is set.
555 */
556#define GLFW_MOD_CAPS_LOCK 0x0010
557/*! @brief If this bit is set the Num Lock key is enabled.
558 *
559 * If this bit is set the Num Lock key is enabled and the @ref
560 * GLFW_LOCK_KEY_MODS input mode is set.
561 */
562#define GLFW_MOD_NUM_LOCK 0x0020
Camilla Berglund2d1b8352012-12-09 19:19:00 +0100563
564/*! @} */
565
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100566/*! @defgroup buttons Mouse buttons
Camilla Löwy21eabd32017-02-06 17:31:25 +0100567 * @brief Mouse button IDs.
Camilla Berglund4188c262015-01-18 01:55:25 +0100568 *
569 * See [mouse button input](@ref input_mouse_button) for how these are used.
570 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100571 * @ingroup input
572 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100573#define GLFW_MOUSE_BUTTON_1 0
574#define GLFW_MOUSE_BUTTON_2 1
575#define GLFW_MOUSE_BUTTON_3 2
576#define GLFW_MOUSE_BUTTON_4 3
577#define GLFW_MOUSE_BUTTON_5 4
578#define GLFW_MOUSE_BUTTON_6 5
579#define GLFW_MOUSE_BUTTON_7 6
580#define GLFW_MOUSE_BUTTON_8 7
581#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
582#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
583#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
584#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100585/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200586
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100587/*! @defgroup joysticks Joysticks
Camilla Löwy21eabd32017-02-06 17:31:25 +0100588 * @brief Joystick IDs.
Camilla Berglund4188c262015-01-18 01:55:25 +0100589 *
590 * See [joystick input](@ref joystick) for how these are used.
591 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100592 * @ingroup input
593 * @{ */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100594#define GLFW_JOYSTICK_1 0
595#define GLFW_JOYSTICK_2 1
596#define GLFW_JOYSTICK_3 2
597#define GLFW_JOYSTICK_4 3
598#define GLFW_JOYSTICK_5 4
599#define GLFW_JOYSTICK_6 5
600#define GLFW_JOYSTICK_7 6
601#define GLFW_JOYSTICK_8 7
602#define GLFW_JOYSTICK_9 8
603#define GLFW_JOYSTICK_10 9
604#define GLFW_JOYSTICK_11 10
605#define GLFW_JOYSTICK_12 11
606#define GLFW_JOYSTICK_13 12
607#define GLFW_JOYSTICK_14 13
608#define GLFW_JOYSTICK_15 14
609#define GLFW_JOYSTICK_16 15
610#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100611/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200612
Camilla Löwy953106e2017-06-18 15:13:25 +0200613/*! @defgroup gamepad_buttons Gamepad buttons
614 * @brief Gamepad buttons.
615 *
616 * See @ref gamepad for how these are used.
617 *
618 * @ingroup input
619 * @{ */
620#define GLFW_GAMEPAD_BUTTON_A 0
621#define GLFW_GAMEPAD_BUTTON_B 1
622#define GLFW_GAMEPAD_BUTTON_X 2
623#define GLFW_GAMEPAD_BUTTON_Y 3
624#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
625#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
626#define GLFW_GAMEPAD_BUTTON_BACK 6
627#define GLFW_GAMEPAD_BUTTON_START 7
628#define GLFW_GAMEPAD_BUTTON_GUIDE 8
629#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
630#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
631#define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
632#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
633#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
634#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
635#define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
636
637#define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
638#define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
639#define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
640#define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
641/*! @} */
642
643/*! @defgroup gamepad_axes Gamepad axes
644 * @brief Gamepad axes.
645 *
646 * See @ref gamepad for how these are used.
647 *
648 * @ingroup input
649 * @{ */
650#define GLFW_GAMEPAD_AXIS_LEFT_X 0
651#define GLFW_GAMEPAD_AXIS_LEFT_Y 1
652#define GLFW_GAMEPAD_AXIS_RIGHT_X 2
653#define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
654#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
655#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
656#define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
657/*! @} */
658
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100659/*! @defgroup errors Error codes
Camilla Löwy21eabd32017-02-06 17:31:25 +0100660 * @brief Error codes.
Camilla Berglund4188c262015-01-18 01:55:25 +0100661 *
662 * See [error handling](@ref error_handling) for how these are used.
663 *
Camilla Berglund4591ad22014-09-18 15:03:29 +0200664 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100665 * @{ */
Camilla Löwy63506412017-05-01 19:20:57 +0200666/*! @brief No error has occurred.
667 *
668 * No error has occurred.
669 *
670 * @analysis Yay.
671 */
672#define GLFW_NO_ERROR 0
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100673/*! @brief GLFW has not been initialized.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200674 *
Camilla Berglund0df4e062015-12-13 14:07:27 +0100675 * This occurs if a GLFW function was called that must not be called unless the
Camilla Berglund4591ad22014-09-18 15:03:29 +0200676 * library is [initialized](@ref intro_init).
677 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100678 * @analysis Application programmer error. Initialize GLFW before calling any
679 * function that requires initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100680 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200681#define GLFW_NOT_INITIALIZED 0x00010001
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100682/*! @brief No context is current for this thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200683 *
684 * This occurs if a GLFW function was called that needs and operates on the
685 * current OpenGL or OpenGL ES context but no context is current on the calling
686 * thread. One such function is @ref glfwSwapInterval.
687 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100688 * @analysis Application programmer error. Ensure a context is current before
689 * calling functions that require a current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100690 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200691#define GLFW_NO_CURRENT_CONTEXT 0x00010002
Camilla Berglund4591ad22014-09-18 15:03:29 +0200692/*! @brief One of the arguments to the function was an invalid enum value.
693 *
694 * One of the arguments to the function was an invalid enum value, for example
Camilla Löwyce161c22016-12-06 01:14:23 +0100695 * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200696 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100697 * @analysis Application programmer error. Fix the offending call.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100698 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200699#define GLFW_INVALID_ENUM 0x00010003
Camilla Berglund4591ad22014-09-18 15:03:29 +0200700/*! @brief One of the arguments to the function was an invalid value.
701 *
702 * One of the arguments to the function was an invalid value, for example
703 * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
704 *
705 * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
706 * result in a @ref GLFW_VERSION_UNAVAILABLE error.
707 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100708 * @analysis Application programmer error. Fix the offending call.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100709 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200710#define GLFW_INVALID_VALUE 0x00010004
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100711/*! @brief A memory allocation failed.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200712 *
713 * A memory allocation failed.
714 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100715 * @analysis A bug in GLFW or the underlying operating system. Report the bug
716 * to our [issue tracker](https://github.com/glfw/glfw/issues).
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100717 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200718#define GLFW_OUT_OF_MEMORY 0x00010005
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200719/*! @brief GLFW could not find support for the requested API on the system.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200720 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200721 * GLFW could not find support for the requested API on the system.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200722 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100723 * @analysis The installed graphics driver does not support the requested
Camilla Löwy56a4cb02021-07-13 21:50:09 +0200724 * API, or does not support it via the chosen context creation API.
Camilla Berglund951a9582016-01-31 21:32:14 +0100725 * Below are a few examples.
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200726 *
727 * @par
728 * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
Camilla Berglundd95b79f2015-03-30 23:20:49 +0200729 * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
Camilla Berglund8d6f2652016-10-20 00:50:54 +0200730 * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
Camilla Berglund138feb82015-01-05 16:46:04 +0100731 * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
Camilla Berglund9b75bff2015-08-10 20:19:04 +0200732 * driver. Older graphics drivers do not support Vulkan.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100733 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200734#define GLFW_API_UNAVAILABLE 0x00010006
Camilla Berglund4591ad22014-09-18 15:03:29 +0200735/*! @brief The requested OpenGL or OpenGL ES version is not available.
736 *
Camilla Berglundd493a822015-03-10 19:51:14 +0100737 * The requested OpenGL or OpenGL ES version (including any requested context
738 * or framebuffer hints) is not available on this machine.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200739 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100740 * @analysis The machine does not support your requirements. If your
741 * application is sufficiently flexible, downgrade your requirements and try
742 * again. Otherwise, inform the user that their machine does not match your
Camilla Berglund4591ad22014-09-18 15:03:29 +0200743 * requirements.
744 *
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200745 * @par
746 * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
747 * comes out before the 4.x series gets that far, also fail with this error and
748 * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
749 * will exist.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100750 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200751#define GLFW_VERSION_UNAVAILABLE 0x00010007
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100752/*! @brief A platform-specific error occurred that does not match any of the
753 * more specific categories.
Camilla Berglund4591ad22014-09-18 15:03:29 +0200754 *
755 * A platform-specific error occurred that does not match any of the more
756 * specific categories.
757 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100758 * @analysis A bug or configuration error in GLFW, the underlying operating
759 * system or its drivers, or a lack of required resources. Report the issue to
760 * our [issue tracker](https://github.com/glfw/glfw/issues).
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100761 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200762#define GLFW_PLATFORM_ERROR 0x00010008
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200763/*! @brief The requested format is not supported or available.
764 *
765 * If emitted during window creation, the requested pixel format is not
766 * supported.
767 *
768 * If emitted when querying the clipboard, the contents of the clipboard could
769 * not be converted to the requested format.
770 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100771 * @analysis If emitted during window creation, one or more
Camilla Berglund2d13eb02014-10-13 16:00:11 +0200772 * [hard constraints](@ref window_hints_hard) did not match any of the
773 * available pixel formats. If your application is sufficiently flexible,
774 * downgrade your requirements and try again. Otherwise, inform the user that
775 * their machine does not match your requirements.
776 *
777 * @par
778 * If emitted when querying the clipboard, ignore the error or report it to
779 * the user, as appropriate.
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100780 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200781#define GLFW_FORMAT_UNAVAILABLE 0x00010009
Camilla Berglund496f5592015-06-18 14:03:02 +0200782/*! @brief The specified window does not have an OpenGL or OpenGL ES context.
783 *
784 * A window that does not have an OpenGL or OpenGL ES context was passed to
785 * a function that requires it to have one.
786 *
Camilla Berglund951a9582016-01-31 21:32:14 +0100787 * @analysis Application programmer error. Fix the offending call.
Camilla Berglund496f5592015-06-18 14:03:02 +0200788 */
789#define GLFW_NO_WINDOW_CONTEXT 0x0001000A
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +0200790/*! @brief The specified cursor shape is not available.
791 *
792 * The specified standard cursor shape is not available, either because the
Camilla Löwy56a4cb02021-07-13 21:50:09 +0200793 * current platform cursor theme does not provide it or because it is not
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +0200794 * available on the platform.
795 *
796 * @analysis Platform or system settings limitation. Pick another
797 * [standard cursor shape](@ref shapes) or create a
798 * [custom cursor](@ref cursor_custom).
799 */
800#define GLFW_CURSOR_UNAVAILABLE 0x0001000B
Luflosib66f1052020-06-23 16:20:27 +0200801/*! @brief The requested feature is not provided by the platform.
Camilla Löwy9a87c2a2020-05-20 18:02:58 +0200802 *
803 * The requested feature is not provided by the platform, so GLFW is unable to
804 * implement it. The documentation for each function notes if it could emit
805 * this error.
806 *
807 * @analysis Platform or platform version limitation. The error can be ignored
808 * unless the feature is critical to the application.
809 *
810 * @par
811 * A function call that emits this error has no effect other than the error and
812 * updating any existing out parameters.
813 */
814#define GLFW_FEATURE_UNAVAILABLE 0x0001000C
815/*! @brief The requested feature is not implemented for the platform.
816 *
817 * The requested feature has not yet been implemented in GLFW for this platform.
818 *
819 * @analysis An incomplete implementation of GLFW for this platform, hopefully
820 * fixed in a future release. The error can be ignored unless the feature is
821 * critical to the application.
822 *
823 * @par
824 * A function call that emits this error has no effect other than the error and
825 * updating any existing out parameters.
826 */
827#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D
Camilla Löwy56a4cb02021-07-13 21:50:09 +0200828/*! @brief Platform unavailable or no matching platform was found.
829 *
Camilla Löwyd2b88cf2024-01-12 17:42:37 +0100830 * If emitted during initialization, no matching platform was found. If the @ref
831 * GLFW_PLATFORM init hint was set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of
832 * the platforms supported by this library binary, except for the Null platform. If the
833 * init hint was set to a specific platform, it is either not supported by this library
834 * binary or GLFW was not able to detect it.
Camilla Löwy56a4cb02021-07-13 21:50:09 +0200835 *
836 * If emitted by a native access function, GLFW was initialized for a different platform
837 * than the function is for.
838 *
839 * @analysis Failure to detect any platform usually only happens on non-macOS Unix
840 * systems, either when no window system is running or the program was run from
841 * a terminal that does not have the necessary environment variables. Fall back to
842 * a different platform if possible or notify the user that no usable platform was
843 * detected.
844 *
845 * Failure to detect a specific platform may have the same cause as above or be because
846 * support for that platform was not compiled in. Call @ref glfwPlatformSupported to
847 * check whether a specific platform is supported by a library binary.
848 */
849#define GLFW_PLATFORM_UNAVAILABLE 0x0001000E
Camilla Berglundbce2cd62012-11-22 16:38:24 +0100850/*! @} */
Camilla Berglund3249f812010-09-07 17:34:51 +0200851
Camilla Löwyce161c22016-12-06 01:14:23 +0100852/*! @addtogroup window
853 * @{ */
854/*! @brief Input focus window hint and attribute
855 *
856 * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
857 * [window attribute](@ref GLFW_FOCUSED_attrib).
858 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100859#define GLFW_FOCUSED 0x00020001
Camilla Löwyce161c22016-12-06 01:14:23 +0100860/*! @brief Window iconification window attribute
861 *
862 * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
863 */
Camilla Berglund2fca5c52013-01-17 21:51:39 +0100864#define GLFW_ICONIFIED 0x00020002
Camilla Löwyce161c22016-12-06 01:14:23 +0100865/*! @brief Window resize-ability window hint and attribute
866 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100867 * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100868 * [window attribute](@ref GLFW_RESIZABLE_attrib).
869 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200870#define GLFW_RESIZABLE 0x00020003
Camilla Löwyce161c22016-12-06 01:14:23 +0100871/*! @brief Window visibility window hint and attribute
872 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100873 * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100874 * [window attribute](@ref GLFW_VISIBLE_attrib).
875 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200876#define GLFW_VISIBLE 0x00020004
Camilla Löwyce161c22016-12-06 01:14:23 +0100877/*! @brief Window decoration window hint and attribute
878 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100879 * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100880 * [window attribute](@ref GLFW_DECORATED_attrib).
881 */
Camilla Berglund393e4392013-05-27 22:16:59 +0200882#define GLFW_DECORATED 0x00020005
Camilla Löwy9e560992016-09-30 01:52:22 +0200883/*! @brief Window auto-iconification window hint and attribute
Camilla Löwyce161c22016-12-06 01:14:23 +0100884 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100885 * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
Camilla Löwy9e560992016-09-30 01:52:22 +0200886 * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
Camilla Löwyce161c22016-12-06 01:14:23 +0100887 */
Camilla Berglund25e7ff12014-04-08 15:32:34 +0200888#define GLFW_AUTO_ICONIFY 0x00020006
Camilla Löwyce161c22016-12-06 01:14:23 +0100889/*! @brief Window decoration window hint and attribute
890 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100891 * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100892 * [window attribute](@ref GLFW_FLOATING_attrib).
893 */
Camilla Berglund3ce7bfe2014-05-23 14:01:02 +0200894#define GLFW_FLOATING 0x00020007
Camilla Löwyce161c22016-12-06 01:14:23 +0100895/*! @brief Window maximization window hint and attribute
896 *
Camilla Löwy831426c2016-12-08 17:08:36 +0100897 * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
Camilla Löwyce161c22016-12-06 01:14:23 +0100898 * [window attribute](@ref GLFW_MAXIMIZED_attrib).
899 */
Camilla Berglunda10caa42015-10-13 12:50:59 +0200900#define GLFW_MAXIMIZED 0x00020008
Camilla Löwy5a74b502017-02-06 15:03:50 +0100901/*! @brief Cursor centering window hint
902 *
903 * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
904 */
Liam Middlebrook72ac5ba2016-08-18 11:47:54 -0400905#define GLFW_CENTER_CURSOR 0x00020009
Camilla Löwy32e78ae2017-09-18 18:10:57 +0200906/*! @brief Window framebuffer transparency hint and attribute
907 *
Camilla Löwy49130ab2017-11-07 22:50:01 +0100908 * Window framebuffer transparency
909 * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
910 * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
Camilla Löwy32e78ae2017-09-18 18:10:57 +0200911 */
Camilla Löwy49130ab2017-11-07 22:50:01 +0100912#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
Camilla Löwyd6b3a602018-01-11 14:13:54 +0100913/*! @brief Mouse cursor hover window attribute.
914 *
915 * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
916 */
Camilla Löwyee9dffc2018-01-04 13:50:58 +0100917#define GLFW_HOVERED 0x0002000B
Doug Binks0be4f3f2018-05-29 14:51:36 +0100918/*! @brief Input focus on calling show window hint and attribute
919 *
920 * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
921 * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
922 */
923#define GLFW_FOCUS_ON_SHOW 0x0002000C
Camilla Berglund2c091572010-09-09 21:09:11 +0200924
Camilla Löwya122d912020-07-08 23:21:28 +0200925/*! @brief Mouse input transparency window hint and attribute
Rokas Kupstysd285a9f2019-09-30 15:44:43 +0300926 *
Camilla Löwya122d912020-07-08 23:21:28 +0200927 * Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or
Rokas Kupstysd285a9f2019-09-30 15:44:43 +0300928 * [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
929 */
930#define GLFW_MOUSE_PASSTHROUGH 0x0002000D
931
Camilla Löwy0f9a9572021-10-26 14:25:03 +0200932/*! @brief Initial position x-coordinate window hint.
933 *
934 * Initial position x-coordinate [window hint](@ref GLFW_POSITION_X).
935 */
936#define GLFW_POSITION_X 0x0002000E
937
938/*! @brief Initial position y-coordinate window hint.
939 *
940 * Initial position y-coordinate [window hint](@ref GLFW_POSITION_Y).
941 */
942#define GLFW_POSITION_Y 0x0002000F
943
Camilla Löwyce161c22016-12-06 01:14:23 +0100944/*! @brief Framebuffer bit depth hint.
945 *
946 * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
947 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200948#define GLFW_RED_BITS 0x00021001
Camilla Löwyce161c22016-12-06 01:14:23 +0100949/*! @brief Framebuffer bit depth hint.
950 *
951 * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
952 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200953#define GLFW_GREEN_BITS 0x00021002
Camilla Löwyce161c22016-12-06 01:14:23 +0100954/*! @brief Framebuffer bit depth hint.
955 *
956 * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
957 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200958#define GLFW_BLUE_BITS 0x00021003
Camilla Löwyce161c22016-12-06 01:14:23 +0100959/*! @brief Framebuffer bit depth hint.
960 *
961 * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
962 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200963#define GLFW_ALPHA_BITS 0x00021004
Camilla Löwyce161c22016-12-06 01:14:23 +0100964/*! @brief Framebuffer bit depth hint.
965 *
966 * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
967 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200968#define GLFW_DEPTH_BITS 0x00021005
Camilla Löwyce161c22016-12-06 01:14:23 +0100969/*! @brief Framebuffer bit depth hint.
970 *
971 * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
972 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200973#define GLFW_STENCIL_BITS 0x00021006
Camilla Löwyce161c22016-12-06 01:14:23 +0100974/*! @brief Framebuffer bit depth hint.
975 *
976 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
977 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200978#define GLFW_ACCUM_RED_BITS 0x00021007
Camilla Löwyce161c22016-12-06 01:14:23 +0100979/*! @brief Framebuffer bit depth hint.
980 *
981 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
982 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200983#define GLFW_ACCUM_GREEN_BITS 0x00021008
Camilla Löwyce161c22016-12-06 01:14:23 +0100984/*! @brief Framebuffer bit depth hint.
985 *
986 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
987 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200988#define GLFW_ACCUM_BLUE_BITS 0x00021009
Camilla Löwyce161c22016-12-06 01:14:23 +0100989/*! @brief Framebuffer bit depth hint.
990 *
991 * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
992 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200993#define GLFW_ACCUM_ALPHA_BITS 0x0002100A
Camilla Löwyce161c22016-12-06 01:14:23 +0100994/*! @brief Framebuffer auxiliary buffer hint.
995 *
996 * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
997 */
Camilla Berglund53b39a62013-05-30 18:55:45 +0200998#define GLFW_AUX_BUFFERS 0x0002100B
Camilla Löwyce161c22016-12-06 01:14:23 +0100999/*! @brief OpenGL stereoscopic rendering hint.
1000 *
1001 * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
1002 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001003#define GLFW_STEREO 0x0002100C
Camilla Löwyce161c22016-12-06 01:14:23 +01001004/*! @brief Framebuffer MSAA samples hint.
1005 *
1006 * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
1007 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001008#define GLFW_SAMPLES 0x0002100D
Camilla Löwyce161c22016-12-06 01:14:23 +01001009/*! @brief Framebuffer sRGB hint.
1010 *
1011 * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
1012 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001013#define GLFW_SRGB_CAPABLE 0x0002100E
Camilla Löwyce161c22016-12-06 01:14:23 +01001014/*! @brief Monitor refresh rate hint.
1015 *
1016 * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
1017 */
Camilla Berglund2cd34382013-05-30 20:42:50 +02001018#define GLFW_REFRESH_RATE 0x0002100F
Camilla Löwy04f21ab2021-05-13 21:38:46 +02001019/*! @brief Framebuffer double buffering hint and attribute.
Camilla Löwyce161c22016-12-06 01:14:23 +01001020 *
Camilla Löwy04f21ab2021-05-13 21:38:46 +02001021 * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER_hint) and
1022 * [attribute](@ref GLFW_DOUBLEBUFFER_attrib).
Camilla Löwyce161c22016-12-06 01:14:23 +01001023 */
Camilla Berglundc9808582014-04-24 19:21:10 +02001024#define GLFW_DOUBLEBUFFER 0x00021010
Bailey Cosier93e66662017-09-19 18:27:45 +02001025
Camilla Löwy831426c2016-12-08 17:08:36 +01001026/*! @brief Context client API hint and attribute.
1027 *
1028 * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
1029 * [attribute](@ref GLFW_CLIENT_API_attrib).
1030 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001031#define GLFW_CLIENT_API 0x00022001
Camilla Löwy831426c2016-12-08 17:08:36 +01001032/*! @brief Context client API major version hint and attribute.
1033 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001034 * Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint)
1035 * and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001036 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001037#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
Camilla Löwy831426c2016-12-08 17:08:36 +01001038/*! @brief Context client API minor version hint and attribute.
1039 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001040 * Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint)
1041 * and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001042 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001043#define GLFW_CONTEXT_VERSION_MINOR 0x00022003
Stephen Gutekanst37fc28b2021-11-15 15:50:37 -07001044/*! @brief Context client API revision number attribute.
Camilla Löwy831426c2016-12-08 17:08:36 +01001045 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001046 * Context client API revision number
1047 * [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001048 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001049#define GLFW_CONTEXT_REVISION 0x00022004
Camilla Löwy831426c2016-12-08 17:08:36 +01001050/*! @brief Context robustness hint and attribute.
1051 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001052 * Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint)
1053 * and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001054 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001055#define GLFW_CONTEXT_ROBUSTNESS 0x00022005
Camilla Löwy831426c2016-12-08 17:08:36 +01001056/*! @brief OpenGL forward-compatibility hint and attribute.
1057 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001058 * OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
1059 * and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001060 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001061#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
Camilla Löwy4e3b4332020-06-28 19:21:36 +02001062/*! @brief Debug mode context hint and attribute.
Camilla Löwy831426c2016-12-08 17:08:36 +01001063 *
Camilla Löwyb420ca72020-06-26 18:35:48 +02001064 * Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and
1065 * [attribute](@ref GLFW_CONTEXT_DEBUG_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001066 */
Camilla Löwyb420ca72020-06-26 18:35:48 +02001067#define GLFW_CONTEXT_DEBUG 0x00022007
1068/*! @brief Legacy name for compatibility.
1069 *
1070 * This is an alias for compatibility with earlier versions.
1071 */
1072#define GLFW_OPENGL_DEBUG_CONTEXT GLFW_CONTEXT_DEBUG
Camilla Löwy831426c2016-12-08 17:08:36 +01001073/*! @brief OpenGL profile hint and attribute.
1074 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001075 * OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
1076 * [attribute](@ref GLFW_OPENGL_PROFILE_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001077 */
Camilla Berglund53b39a62013-05-30 18:55:45 +02001078#define GLFW_OPENGL_PROFILE 0x00022008
Camilla Löwy831426c2016-12-08 17:08:36 +01001079/*! @brief Context flush-on-release hint and attribute.
1080 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001081 * Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and
1082 * [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001083 */
Camilla Berglund44c899c2014-08-21 19:21:45 +02001084#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
Camilla Löwy831426c2016-12-08 17:08:36 +01001085/*! @brief Context error suppression hint and attribute.
1086 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001087 * Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and
1088 * [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001089 */
Camilla Berglund7be82092015-08-10 12:46:14 +02001090#define GLFW_CONTEXT_NO_ERROR 0x0002200A
Camilla Löwy831426c2016-12-08 17:08:36 +01001091/*! @brief Context creation API hint and attribute.
1092 *
Camilla Löwy3cf76452019-05-19 21:41:57 +02001093 * Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and
1094 * [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
Camilla Löwy831426c2016-12-08 17:08:36 +01001095 */
Camilla Berglundef80bea2016-03-28 13:19:31 +02001096#define GLFW_CONTEXT_CREATION_API 0x0002200B
Camilla Löwy089ea9a2018-08-31 13:33:48 +02001097/*! @brief Window content area scaling window
1098 * [window hint](@ref GLFW_SCALE_TO_MONITOR).
1099 */
1100#define GLFW_SCALE_TO_MONITOR 0x0002200C
Camilla Löwya9cc7c72024-02-07 20:04:14 +01001101/*! @brief Window framebuffer scaling
1102 * [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint).
1103 */
1104#define GLFW_SCALE_FRAMEBUFFER 0x0002200D
1105/*! @brief Legacy name for compatibility.
1106 *
1107 * This is an alias for the
1108 * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for
1109 * compatibility with earlier versions.
Camilla Löwy422bf792019-04-01 18:36:30 +02001110 */
Camilla Löwy58ceab52016-12-07 00:41:54 +01001111#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
Camilla Löwy422bf792019-04-01 18:36:30 +02001112/*! @brief macOS specific
1113 * [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
1114 */
Camilla Löwy9da22852017-12-12 16:45:38 +01001115#define GLFW_COCOA_FRAME_NAME 0x00023002
Camilla Löwy422bf792019-04-01 18:36:30 +02001116/*! @brief macOS specific
1117 * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint).
1118 */
Camilla Löwy77a8f102017-01-27 12:02:09 +01001119#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
Camilla Löwy422bf792019-04-01 18:36:30 +02001120/*! @brief X11 specific
1121 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1122 */
Camilla Löwy61588012017-12-12 10:54:18 +01001123#define GLFW_X11_CLASS_NAME 0x00024001
Camilla Löwy422bf792019-04-01 18:36:30 +02001124/*! @brief X11 specific
1125 * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
1126 */
Camilla Löwy61588012017-12-12 10:54:18 +01001127#define GLFW_X11_INSTANCE_NAME 0x00024002
Camilla Löwy8e288dc2019-08-20 19:00:59 +02001128#define GLFW_WIN32_KEYBOARD_MENU 0x00025001
Camilla Löwy8946f532024-02-01 02:10:34 +01001129/*! @brief Win32 specific [window hint](@ref GLFW_WIN32_SHOWDEFAULT_hint).
1130 */
1131#define GLFW_WIN32_SHOWDEFAULT 0x00025002
Michael Penningtonb9ed25d2022-05-26 20:33:28 -04001132/*! @brief Wayland specific
1133 * [window hint](@ref GLFW_WAYLAND_APP_ID_hint).
1134 *
1135 * Allows specification of the Wayland app_id.
1136 */
1137#define GLFW_WAYLAND_APP_ID 0x00026001
Camilla Löwy831426c2016-12-08 17:08:36 +01001138/*! @} */
Camilla Löwy58ceab52016-12-07 00:41:54 +01001139
Camilla Berglund496f5592015-06-18 14:03:02 +02001140#define GLFW_NO_API 0
Camilla Berglund393e4392013-05-27 22:16:59 +02001141#define GLFW_OPENGL_API 0x00030001
1142#define GLFW_OPENGL_ES_API 0x00030002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001143
Camilla Berglund393e4392013-05-27 22:16:59 +02001144#define GLFW_NO_ROBUSTNESS 0
1145#define GLFW_NO_RESET_NOTIFICATION 0x00031001
1146#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001147
Camilla Berglund44e84012013-06-05 16:13:30 +02001148#define GLFW_OPENGL_ANY_PROFILE 0
Camilla Berglund393e4392013-05-27 22:16:59 +02001149#define GLFW_OPENGL_CORE_PROFILE 0x00032001
1150#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001151
Grzesiek11bf945f12024-02-29 15:50:50 +00001152#define GLFW_CURSOR 0x00033001
1153#define GLFW_STICKY_KEYS 0x00033002
1154#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
1155#define GLFW_LOCK_KEY_MODS 0x00033004
1156#define GLFW_RAW_MOUSE_MOTION 0x00033005
1157#define GLFW_UNLIMITED_MOUSE_BUTTONS 0x00033006
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001158
Camilla Berglund393e4392013-05-27 22:16:59 +02001159#define GLFW_CURSOR_NORMAL 0x00034001
1160#define GLFW_CURSOR_HIDDEN 0x00034002
1161#define GLFW_CURSOR_DISABLED 0x00034003
Camilla Löwy488008e2019-12-03 17:58:20 +01001162#define GLFW_CURSOR_CAPTURED 0x00034004
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001163
Camilla Berglund44c899c2014-08-21 19:21:45 +02001164#define GLFW_ANY_RELEASE_BEHAVIOR 0
1165#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
1166#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
1167
Camilla Berglundef80bea2016-03-28 13:19:31 +02001168#define GLFW_NATIVE_CONTEXT_API 0x00036001
1169#define GLFW_EGL_CONTEXT_API 0x00036002
Camilla Löwye9560ef2017-02-28 19:23:25 +01001170#define GLFW_OSMESA_CONTEXT_API 0x00036003
Camilla Berglundef80bea2016-03-28 13:19:31 +02001171
Camilla Löwy0dea8a42020-06-25 18:22:08 +02001172#define GLFW_ANGLE_PLATFORM_TYPE_NONE 0x00037001
1173#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL 0x00037002
1174#define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
1175#define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004
1176#define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005
1177#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007
1178#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008
1179
Camilla Löwyfbdb53b2022-12-27 14:37:27 +01001180#define GLFW_WAYLAND_PREFER_LIBDECOR 0x00038001
1181#define GLFW_WAYLAND_DISABLE_LIBDECOR 0x00038002
1182
Camilla Löwy0f9a9572021-10-26 14:25:03 +02001183#define GLFW_ANY_POSITION 0x80000000
1184
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001185/*! @defgroup shapes Standard cursor shapes
Camilla Löwy21eabd32017-02-06 17:31:25 +01001186 * @brief Standard system cursor shapes.
Camilla Berglund4188c262015-01-18 01:55:25 +01001187 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001188 * These are the [standard cursor shapes](@ref cursor_standard) that can be
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001189 * requested from the platform (window system).
Camilla Berglund4188c262015-01-18 01:55:25 +01001190 *
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001191 * @ingroup input
1192 * @{ */
1193
1194/*! @brief The regular arrow cursor shape.
1195 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001196 * The regular arrow cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001197 */
1198#define GLFW_ARROW_CURSOR 0x00036001
1199/*! @brief The text input I-beam cursor shape.
1200 *
1201 * The text input I-beam cursor shape.
1202 */
1203#define GLFW_IBEAM_CURSOR 0x00036002
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001204/*! @brief The crosshair cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001205 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001206 * The crosshair cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001207 */
1208#define GLFW_CROSSHAIR_CURSOR 0x00036003
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001209/*! @brief The pointing hand cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001210 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001211 * The pointing hand cursor shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001212 */
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001213#define GLFW_POINTING_HAND_CURSOR 0x00036004
1214/*! @brief The horizontal resize/move arrow shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001215 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001216 * The horizontal resize/move arrow shape. This is usually a horizontal
1217 * double-headed arrow.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001218 */
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001219#define GLFW_RESIZE_EW_CURSOR 0x00036005
1220/*! @brief The vertical resize/move arrow shape.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001221 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001222 * The vertical resize/move shape. This is usually a vertical double-headed
1223 * arrow.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001224 */
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001225#define GLFW_RESIZE_NS_CURSOR 0x00036006
1226/*! @brief The top-left to bottom-right diagonal resize/move arrow shape.
1227 *
1228 * The top-left to bottom-right diagonal resize/move shape. This is usually
1229 * a diagonal double-headed arrow.
1230 *
1231 * @note @macos This shape is provided by a private system API and may fail
1232 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1233 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001234 * @note @wayland This shape is provided by a newer standard not supported by
1235 * all cursor themes.
Camilla Löwy0bb605c2024-02-19 15:06:59 +01001236 *
1237 * @note @x11 This shape is provided by a newer standard not supported by all
1238 * cursor themes.
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001239 */
1240#define GLFW_RESIZE_NWSE_CURSOR 0x00036007
1241/*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
1242 *
1243 * The top-right to bottom-left diagonal resize/move shape. This is usually
1244 * a diagonal double-headed arrow.
1245 *
1246 * @note @macos This shape is provided by a private system API and may fail
1247 * with @ref GLFW_CURSOR_UNAVAILABLE in the future.
1248 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001249 * @note @wayland This shape is provided by a newer standard not supported by
1250 * all cursor themes.
Camilla Löwy0bb605c2024-02-19 15:06:59 +01001251 *
1252 * @note @x11 This shape is provided by a newer standard not supported by all
1253 * cursor themes.
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001254 */
1255#define GLFW_RESIZE_NESW_CURSOR 0x00036008
1256/*! @brief The omni-directional resize/move cursor shape.
1257 *
1258 * The omni-directional resize cursor/move shape. This is usually either
1259 * a combined horizontal and vertical double-headed arrow or a grabbing hand.
1260 */
1261#define GLFW_RESIZE_ALL_CURSOR 0x00036009
1262/*! @brief The operation-not-allowed shape.
1263 *
1264 * The operation-not-allowed shape. This is usually a circle with a diagonal
1265 * line through it.
1266 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001267 * @note @wayland This shape is provided by a newer standard not supported by
1268 * all cursor themes.
Camilla Löwy0bb605c2024-02-19 15:06:59 +01001269 *
1270 * @note @x11 This shape is provided by a newer standard not supported by all
1271 * cursor themes.
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02001272 */
1273#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
1274/*! @brief Legacy name for compatibility.
1275 *
1276 * This is an alias for compatibility with earlier versions.
1277 */
1278#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR
1279/*! @brief Legacy name for compatibility.
1280 *
1281 * This is an alias for compatibility with earlier versions.
1282 */
1283#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR
1284/*! @brief Legacy name for compatibility.
1285 *
1286 * This is an alias for compatibility with earlier versions.
1287 */
1288#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR
Camilla Berglund2a1375e2014-09-02 16:52:16 +02001289/*! @} */
1290
Camilla Berglund393e4392013-05-27 22:16:59 +02001291#define GLFW_CONNECTED 0x00040001
1292#define GLFW_DISCONNECTED 0x00040002
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001293
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001294/*! @addtogroup init
1295 * @{ */
Camilla Löwy04116782018-11-05 17:37:49 +01001296/*! @brief Joystick hat buttons init hint.
1297 *
Camilla Löwy422bf792019-04-01 18:36:30 +02001298 * Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
Camilla Löwy04116782018-11-05 17:37:49 +01001299 */
Camilla Löwy798d7c62017-03-01 23:27:20 +01001300#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
Camilla Löwy0dea8a42020-06-25 18:22:08 +02001301/*! @brief ANGLE rendering backend init hint.
1302 *
1303 * ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
1304 */
1305#define GLFW_ANGLE_PLATFORM_TYPE 0x00050002
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001306/*! @brief Platform selection init hint.
1307 *
1308 * Platform selection [init hint](@ref GLFW_PLATFORM).
1309 */
1310#define GLFW_PLATFORM 0x00050003
Camilla Löwy04116782018-11-05 17:37:49 +01001311/*! @brief macOS specific init hint.
1312 *
Camilla Löwy422bf792019-04-01 18:36:30 +02001313 * macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
Camilla Löwy04116782018-11-05 17:37:49 +01001314 */
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001315#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
Camilla Löwy04116782018-11-05 17:37:49 +01001316/*! @brief macOS specific init hint.
1317 *
Camilla Löwy422bf792019-04-01 18:36:30 +02001318 * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
Camilla Löwy04116782018-11-05 17:37:49 +01001319 */
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001320#define GLFW_COCOA_MENUBAR 0x00051002
Nicolas Caramelli84f95a72020-10-23 18:55:37 +02001321/*! @brief X11 specific init hint.
1322 *
1323 * X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
1324 */
1325#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
Camilla Löwyfbdb53b2022-12-27 14:37:27 +01001326/*! @brief Wayland specific init hint.
1327 *
1328 * Wayland specific [init hint](@ref GLFW_WAYLAND_LIBDECOR_hint).
1329 */
1330#define GLFW_WAYLAND_LIBDECOR 0x00053001
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01001331/*! @} */
1332
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001333/*! @addtogroup init
1334 * @{ */
1335/*! @brief Hint value that enables automatic platform selection.
1336 *
1337 * Hint value for @ref GLFW_PLATFORM that enables automatic platform selection.
1338 */
1339#define GLFW_ANY_PLATFORM 0x00060000
1340#define GLFW_PLATFORM_WIN32 0x00060001
1341#define GLFW_PLATFORM_COCOA 0x00060002
1342#define GLFW_PLATFORM_WAYLAND 0x00060003
1343#define GLFW_PLATFORM_X11 0x00060004
1344#define GLFW_PLATFORM_NULL 0x00060005
1345/*! @} */
1346
Camilla Berglund28101302014-04-08 18:57:43 +02001347#define GLFW_DONT_CARE -1
1348
Camilla Berglund97387282011-10-06 23:28:56 +02001349
Camilla Berglund3249f812010-09-07 17:34:51 +02001350/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +01001351 * GLFW API types
Camilla Berglund3249f812010-09-07 17:34:51 +02001352 *************************************************************************/
1353
Camilla Berglund3f5843f2012-12-13 02:22:39 +01001354/*! @brief Client API function pointer type.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001355 *
1356 * Generic function pointer used for returning client API function pointers
1357 * without forcing a cast from a regular pointer.
1358 *
Camilla Berglundbce20c32015-11-05 13:58:52 +01001359 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001360 * @sa @ref glfwGetProcAddress
Camilla Berglundbce20c32015-11-05 13:58:52 +01001361 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001362 * @since Added in version 3.0.
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00001363 *
Camilla Berglund3f5843f2012-12-13 02:22:39 +01001364 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001365 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02001366typedef void (*GLFWglproc)(void);
1367
Camilla Berglund9b75bff2015-08-10 20:19:04 +02001368/*! @brief Vulkan API function pointer type.
1369 *
1370 * Generic function pointer used for returning Vulkan API function pointers
1371 * without forcing a cast from a regular pointer.
1372 *
1373 * @sa @ref vulkan_proc
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001374 * @sa @ref glfwGetInstanceProcAddress
Camilla Berglund9b75bff2015-08-10 20:19:04 +02001375 *
1376 * @since Added in version 3.2.
1377 *
1378 * @ingroup vulkan
1379 */
1380typedef void (*GLFWvkproc)(void);
1381
Camilla Berglunddba2d802013-01-17 23:06:56 +01001382/*! @brief Opaque monitor object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001383 *
1384 * Opaque monitor object.
1385 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001386 * @see @ref monitor_object
1387 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001388 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001389 *
Camilla Berglund41bc0d12012-11-27 16:55:04 +01001390 * @ingroup monitor
1391 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001392typedef struct GLFWmonitor GLFWmonitor;
Camilla Berglunde0ce9202012-08-29 20:39:05 +02001393
Camilla Berglunddba2d802013-01-17 23:06:56 +01001394/*! @brief Opaque window object.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001395 *
1396 * Opaque window object.
1397 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001398 * @see @ref window_object
1399 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001400 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001401 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001402 * @ingroup window
1403 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01001404typedef struct GLFWwindow GLFWwindow;
Camilla Berglund135194a2010-09-09 18:15:32 +02001405
urraka40c04a72013-12-04 10:19:22 -03001406/*! @brief Opaque cursor object.
1407 *
1408 * Opaque cursor object.
1409 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001410 * @see @ref cursor_object
1411 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001412 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001413 *
Camilla Löwy04116782018-11-05 17:37:49 +01001414 * @ingroup input
urraka40c04a72013-12-04 10:19:22 -03001415 */
1416typedef struct GLFWcursor GLFWcursor;
1417
Camilla Löwy22b586b2021-08-03 20:53:48 +02001418/*! @brief The function pointer type for memory allocation callbacks.
1419 *
1420 * This is the function pointer type for memory allocation callbacks. A memory
1421 * allocation callback function has the following signature:
1422 * @code
1423 * void* function_name(size_t size, void* user)
1424 * @endcode
1425 *
1426 * This function must return either a memory block at least `size` bytes long,
1427 * or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
1428 * failures gracefully yet.
1429 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001430 * This function must support being called during @ref glfwInit but before the library is
1431 * flagged as initialized, as well as during @ref glfwTerminate after the library is no
1432 * longer flagged as initialized.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001433 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001434 * Any memory allocated via this function will be deallocated via the same allocator
1435 * during library termination or earlier.
1436 *
1437 * Any memory allocated via this function must be suitably aligned for any object type.
1438 * If you are using C99 or earlier, this alignment is platform-dependent but will be the
1439 * same as what `malloc` provides. If you are using C11 or later, this is the value of
1440 * `alignof(max_align_t)`.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001441 *
1442 * The size will always be greater than zero. Allocations of size zero are filtered out
1443 * before reaching the custom allocator.
1444 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001445 * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
1446 *
1447 * This function must not call any GLFW function.
1448 *
Camilla Löwy22b586b2021-08-03 20:53:48 +02001449 * @param[in] size The minimum size, in bytes, of the memory block.
1450 * @param[in] user The user-defined pointer from the allocator.
1451 * @return The address of the newly allocated memory block, or `NULL` if an
1452 * error occurred.
1453 *
1454 * @pointer_lifetime The returned memory block must be valid at least until it
1455 * is deallocated.
1456 *
1457 * @reentrancy This function should not call any GLFW function.
1458 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001459 * @thread_safety This function must support being called from any thread that calls GLFW
1460 * functions.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001461 *
1462 * @sa @ref init_allocator
1463 * @sa @ref GLFWallocator
1464 *
1465 * @since Added in version 3.4.
1466 *
1467 * @ingroup init
1468 */
1469typedef void* (* GLFWallocatefun)(size_t size, void* user);
1470
1471/*! @brief The function pointer type for memory reallocation callbacks.
1472 *
1473 * This is the function pointer type for memory reallocation callbacks.
1474 * A memory reallocation callback function has the following signature:
1475 * @code
1476 * void* function_name(void* block, size_t size, void* user)
1477 * @endcode
1478 *
1479 * This function must return a memory block at least `size` bytes long, or
1480 * `NULL` if allocation failed. Note that not all parts of GLFW handle allocation
1481 * failures gracefully yet.
1482 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001483 * This function must support being called during @ref glfwInit but before the library is
1484 * flagged as initialized, as well as during @ref glfwTerminate after the library is no
1485 * longer flagged as initialized.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001486 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001487 * Any memory allocated via this function will be deallocated via the same allocator
1488 * during library termination or earlier.
1489 *
1490 * Any memory allocated via this function must be suitably aligned for any object type.
1491 * If you are using C99 or earlier, this alignment is platform-dependent but will be the
1492 * same as what `realloc` provides. If you are using C11 or later, this is the value of
1493 * `alignof(max_align_t)`.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001494 *
1495 * The block address will never be `NULL` and the size will always be greater than zero.
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001496 * Reallocations of a block to size zero are converted into deallocations before reaching
1497 * the custom allocator. Reallocations of `NULL` to a non-zero size are converted into
1498 * regular allocations before reaching the custom allocator.
1499 *
1500 * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
1501 *
1502 * This function must not call any GLFW function.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001503 *
1504 * @param[in] block The address of the memory block to reallocate.
1505 * @param[in] size The new minimum size, in bytes, of the memory block.
1506 * @param[in] user The user-defined pointer from the allocator.
1507 * @return The address of the newly allocated or resized memory block, or
1508 * `NULL` if an error occurred.
1509 *
1510 * @pointer_lifetime The returned memory block must be valid at least until it
1511 * is deallocated.
1512 *
1513 * @reentrancy This function should not call any GLFW function.
1514 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001515 * @thread_safety This function must support being called from any thread that calls GLFW
1516 * functions.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001517 *
1518 * @sa @ref init_allocator
1519 * @sa @ref GLFWallocator
1520 *
1521 * @since Added in version 3.4.
1522 *
1523 * @ingroup init
1524 */
1525typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user);
1526
1527/*! @brief The function pointer type for memory deallocation callbacks.
1528 *
1529 * This is the function pointer type for memory deallocation callbacks.
1530 * A memory deallocation callback function has the following signature:
1531 * @code
1532 * void function_name(void* block, void* user)
1533 * @endcode
1534 *
1535 * This function may deallocate the specified memory block. This memory block
1536 * will have been allocated with the same allocator.
1537 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001538 * This function must support being called during @ref glfwInit but before the library is
1539 * flagged as initialized, as well as during @ref glfwTerminate after the library is no
1540 * longer flagged as initialized.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001541 *
1542 * The block address will never be `NULL`. Deallocations of `NULL` are filtered out
1543 * before reaching the custom allocator.
1544 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001545 * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY.
1546 *
1547 * This function must not call any GLFW function.
1548 *
Camilla Löwy22b586b2021-08-03 20:53:48 +02001549 * @param[in] block The address of the memory block to deallocate.
1550 * @param[in] user The user-defined pointer from the allocator.
1551 *
1552 * @pointer_lifetime The specified memory block will not be accessed by GLFW
1553 * after this function is called.
1554 *
1555 * @reentrancy This function should not call any GLFW function.
1556 *
Camilla Löwy2afd57b2024-01-31 01:45:02 +01001557 * @thread_safety This function must support being called from any thread that calls GLFW
1558 * functions.
Camilla Löwy22b586b2021-08-03 20:53:48 +02001559 *
1560 * @sa @ref init_allocator
1561 * @sa @ref GLFWallocator
1562 *
1563 * @since Added in version 3.4.
1564 *
1565 * @ingroup init
1566 */
1567typedef void (* GLFWdeallocatefun)(void* block, void* user);
1568
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001569/*! @brief The function pointer type for error 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 error callbacks. An error callback
1572 * function has the following signature:
1573 * @code
1574 * void callback_name(int error_code, const char* description)
1575 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001576 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001577 * @param[in] error_code An [error code](@ref errors). Future releases may add
1578 * more error codes.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001579 * @param[in] description A UTF-8 encoded string describing the error.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001580 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001581 * @pointer_lifetime The error description string is valid until the callback
1582 * function returns.
1583 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001584 * @sa @ref error_handling
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001585 * @sa @ref glfwSetErrorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001586 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001587 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001588 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02001589 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001590 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001591typedef void (* GLFWerrorfun)(int error_code, const char* description);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001592
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001593/*! @brief The function pointer type for window position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001594 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001595 * This is the function pointer type for window position callbacks. A window
1596 * position callback function has the following signature:
1597 * @code
1598 * void callback_name(GLFWwindow* window, int xpos, int ypos)
1599 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001600 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001601 * @param[in] window The window that was moved.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001602 * @param[in] xpos The new x-coordinate, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001603 * upper-left corner of the content area of the window.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001604 * @param[in] ypos The new y-coordinate, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001605 * upper-left corner of the content area of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001606 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001607 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001608 * @sa @ref glfwSetWindowPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001609 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001610 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001611 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001612 * @ingroup window
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001613 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001614typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01001615
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001616/*! @brief The function pointer type for window size callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001617 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001618 * This is the function pointer type for window size callbacks. A window size
1619 * callback function has the following signature:
1620 * @code
1621 * void callback_name(GLFWwindow* window, int width, int height)
1622 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001623 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02001624 * @param[in] window The window that was resized.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001625 * @param[in] width The new width, in screen coordinates, of the window.
1626 * @param[in] height The new height, in screen coordinates, of the window.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001627 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001628 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001629 * @sa @ref glfwSetWindowSizeCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001630 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001631 * @since Added in version 1.0.
1632 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001633 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001634 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001635 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001636typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001637
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001638/*! @brief The function pointer type for window close callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001639 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001640 * This is the function pointer type for window close callbacks. A window
1641 * close callback function has the following signature:
1642 * @code
1643 * void function_name(GLFWwindow* window)
1644 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001645 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001646 * @param[in] window The window that the user attempted to close.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001647 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001648 * @sa @ref window_close
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001649 * @sa @ref glfwSetWindowCloseCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001650 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001651 * @since Added in version 2.5.
1652 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001653 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001654 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001655 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001656typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001657
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001658/*! @brief The function pointer type for window content refresh callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001659 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001660 * This is the function pointer type for window content refresh callbacks.
1661 * A window content refresh callback function has the following signature:
1662 * @code
1663 * void function_name(GLFWwindow* window);
1664 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001665 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001666 * @param[in] window The window whose content needs to be refreshed.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001667 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001668 * @sa @ref window_refresh
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001669 * @sa @ref glfwSetWindowRefreshCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001670 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001671 * @since Added in version 2.5.
1672 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001673 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001674 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001675 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001676typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001677
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001678/*! @brief The function pointer type for window focus callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001679 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001680 * This is the function pointer type for window focus callbacks. A window
1681 * focus callback function has the following signature:
1682 * @code
1683 * void function_name(GLFWwindow* window, int focused)
1684 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001685 *
Camilla Berglund4188c262015-01-18 01:55:25 +01001686 * @param[in] window The window that gained or lost input focus.
Camilla Berglund0eccf752015-08-23 19:30:04 +02001687 * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
1688 * `GLFW_FALSE` if it lost it.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001689 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001690 * @sa @ref window_focus
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001691 * @sa @ref glfwSetWindowFocusCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001692 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001693 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001694 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001695 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001696 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001697typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001698
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001699/*! @brief The function pointer type for window iconify callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001700 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001701 * This is the function pointer type for window iconify callbacks. A window
1702 * iconify callback function has the following signature:
1703 * @code
1704 * void function_name(GLFWwindow* window, int iconified)
1705 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001706 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001707 * @param[in] window The window that was iconified or restored.
Camilla Berglund0eccf752015-08-23 19:30:04 +02001708 * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
1709 * `GLFW_FALSE` if it was restored.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001710 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001711 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001712 * @sa @ref glfwSetWindowIconifyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001713 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001714 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001715 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001716 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001717 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001718typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001719
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001720/*! @brief The function pointer type for window maximize callbacks.
Camilla Berglundc156b502016-06-16 13:09:28 +02001721 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001722 * This is the function pointer type for window maximize callbacks. A window
1723 * maximize callback function has the following signature:
1724 * @code
1725 * void function_name(GLFWwindow* window, int maximized)
1726 * @endcode
Camilla Berglundc156b502016-06-16 13:09:28 +02001727 *
1728 * @param[in] window The window that was maximized or restored.
Emmanuel Gil Peyrot1ed14892020-09-07 20:19:51 +02001729 * @param[in] maximized `GLFW_TRUE` if the window was maximized, or
Camilla Berglundc156b502016-06-16 13:09:28 +02001730 * `GLFW_FALSE` if it was restored.
1731 *
1732 * @sa @ref window_maximize
1733 * @sa glfwSetWindowMaximizeCallback
1734 *
1735 * @since Added in version 3.3.
1736 *
1737 * @ingroup window
1738 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001739typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized);
Camilla Berglundc156b502016-06-16 13:09:28 +02001740
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001741/*! @brief The function pointer type for framebuffer size callbacks.
Camilla Berglund34981632013-06-03 12:51:57 +02001742 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001743 * This is the function pointer type for framebuffer size callbacks.
1744 * A framebuffer size callback function has the following signature:
1745 * @code
1746 * void function_name(GLFWwindow* window, int width, int height)
1747 * @endcode
Camilla Berglund34981632013-06-03 12:51:57 +02001748 *
1749 * @param[in] window The window whose framebuffer was resized.
1750 * @param[in] width The new width, in pixels, of the framebuffer.
1751 * @param[in] height The new height, in pixels, of the framebuffer.
1752 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001753 * @sa @ref window_fbsize
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001754 * @sa @ref glfwSetFramebufferSizeCallback
Camilla Berglund34981632013-06-03 12:51:57 +02001755 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001756 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001757 *
Camilla Berglund34981632013-06-03 12:51:57 +02001758 * @ingroup window
1759 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001760typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height);
Camilla Berglund34981632013-06-03 12:51:57 +02001761
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001762/*! @brief The function pointer type for window content scale callbacks.
Camilla Löwy370eac32017-12-11 21:26:40 +01001763 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001764 * This is the function pointer type for window content scale callbacks.
1765 * A window content scale callback function has the following signature:
1766 * @code
1767 * void function_name(GLFWwindow* window, float xscale, float yscale)
1768 * @endcode
Camilla Löwy370eac32017-12-11 21:26:40 +01001769 *
1770 * @param[in] window The window whose content scale changed.
1771 * @param[in] xscale The new x-axis content scale of the window.
1772 * @param[in] yscale The new y-axis content scale of the window.
1773 *
1774 * @sa @ref window_scale
1775 * @sa @ref glfwSetWindowContentScaleCallback
1776 *
1777 * @since Added in version 3.3.
1778 *
1779 * @ingroup window
1780 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001781typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale);
Camilla Löwy370eac32017-12-11 21:26:40 +01001782
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001783/*! @brief The function pointer type for mouse button callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001784 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001785 * This is the function pointer type for mouse button callback functions.
1786 * A mouse button callback function has the following signature:
1787 * @code
1788 * void function_name(GLFWwindow* window, int button, int action, int mods)
1789 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001790 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001791 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001792 * @param[in] button The [mouse button](@ref buttons) that was pressed or
1793 * released.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001794 * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases
1795 * may add more actions.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +02001796 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1797 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001798 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001799 * @sa @ref input_mouse_button
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001800 * @sa @ref glfwSetMouseButtonCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001801 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001802 * @since Added in version 1.0.
1803 * @glfw3 Added window handle and modifier mask parameters.
Camilla Berglund810bab72015-12-13 17:38:14 +01001804 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001805 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001806 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001807typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001808
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001809/*! @brief The function pointer type for cursor position callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001810 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001811 * This is the function pointer type for cursor position callbacks. A cursor
1812 * position callback function has the following signature:
1813 * @code
1814 * void function_name(GLFWwindow* window, double xpos, double ypos);
1815 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001816 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001817 * @param[in] window The window that received the event.
Camilla Berglund95c44ab2016-02-17 14:52:01 +01001818 * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001819 * the content area.
Camilla Berglund95c44ab2016-02-17 14:52:01 +01001820 * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001821 * content area.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001822 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001823 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001824 * @sa @ref glfwSetCursorPosCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001825 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001826 * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
Camilla Berglund810bab72015-12-13 17:38:14 +01001827 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001828 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001829 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001830typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001831
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001832/*! @brief The function pointer type for cursor enter/leave callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001833 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001834 * This is the function pointer type for cursor enter/leave callbacks.
1835 * A cursor enter/leave callback function has the following signature:
1836 * @code
1837 * void function_name(GLFWwindow* window, int entered)
1838 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001839 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001840 * @param[in] window The window that received the event.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01001841 * @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
Camilla Berglund0eccf752015-08-23 19:30:04 +02001842 * area, or `GLFW_FALSE` if it left it.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001843 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001844 * @sa @ref cursor_enter
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001845 * @sa @ref glfwSetCursorEnterCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001846 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001847 * @since Added in version 3.0.
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 (* GLFWcursorenterfun)(GLFWwindow* window, int entered);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001852
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001853/*! @brief The function pointer type for scroll 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 scroll callbacks. A scroll callback
1856 * function has the following signature:
1857 * @code
1858 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
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.
mewmewcf2d2602013-06-06 19:49:23 +02001862 * @param[in] xoffset The scroll offset along the x-axis.
1863 * @param[in] yoffset The scroll offset along the y-axis.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001864 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001865 * @sa @ref scrolling
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001866 * @sa @ref glfwSetScrollCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001867 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001868 * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
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 (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001873
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001874/*! @brief The function pointer type for keyboard key callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001875 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001876 * This is the function pointer type for keyboard key callbacks. A keyboard
1877 * key callback function has the following signature:
1878 * @code
1879 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
1880 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001881 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001882 * @param[in] window The window that received the event.
Camilla Berglund71d2b572013-03-12 15:33:05 +01001883 * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
Camilla Löwy56a4cb02021-07-13 21:50:09 +02001884 * @param[in] scancode The platform-specific scancode of the key.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001885 * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. Future
1886 * releases may add more actions.
Camilla Berglund98cbf6f2013-05-23 14:42:33 +02001887 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1888 * held down.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001889 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001890 * @sa @ref input_key
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001891 * @sa @ref glfwSetKeyCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001892 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001893 * @since Added in version 1.0.
1894 * @glfw3 Added window handle, scancode and modifier mask parameters.
Camilla Berglund810bab72015-12-13 17:38:14 +01001895 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001896 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001897 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001898typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001899
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001900/*! @brief The function pointer type for Unicode character callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001901 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001902 * This is the function pointer type for Unicode character callbacks.
1903 * A Unicode character callback function has the following signature:
1904 * @code
1905 * void function_name(GLFWwindow* window, unsigned int codepoint)
1906 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001907 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001908 * @param[in] window The window that received the event.
Camilla Berglund2c920fb2013-10-10 19:41:56 +02001909 * @param[in] codepoint The Unicode code point of the character.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001910 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001911 * @sa @ref input_char
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001912 * @sa @ref glfwSetCharCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001913 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001914 * @since Added in version 2.4.
1915 * @glfw3 Added window handle parameter.
Camilla Berglund810bab72015-12-13 17:38:14 +01001916 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001917 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01001918 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001919typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
Camilla Berglund5f68e122012-11-27 17:07:28 +01001920
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001921/*! @brief The function pointer type for Unicode character with modifiers
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001922 * callbacks.
1923 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001924 * This is the function pointer type for Unicode character with modifiers
1925 * callbacks. It is called for each input character, regardless of what
1926 * modifier keys are held down. A Unicode character with modifiers callback
1927 * function has the following signature:
1928 * @code
1929 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
1930 * @endcode
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001931 *
1932 * @param[in] window The window that received the event.
1933 * @param[in] codepoint The Unicode code point of the character.
1934 * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
1935 * held down.
1936 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001937 * @sa @ref input_char
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001938 * @sa @ref glfwSetCharModsCallback
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001939 *
Camilla Löwyadebcc72017-11-14 23:28:12 +01001940 * @deprecated Scheduled for removal in version 4.0.
1941 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001942 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001943 *
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001944 * @ingroup input
1945 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001946typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
Camilla Berglund96b12ee2014-06-12 23:04:20 +02001947
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001948/*! @brief The function pointer type for path drop callbacks.
arturo89d07232013-07-10 11:42:14 +02001949 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001950 * This is the function pointer type for path drop callbacks. A path drop
1951 * callback function has the following signature:
1952 * @code
1953 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
1954 * @endcode
arturo89d07232013-07-10 11:42:14 +02001955 *
1956 * @param[in] window The window that received the event.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001957 * @param[in] path_count The number of dropped paths.
Camilla Berglund93855ae2015-01-27 23:04:22 +01001958 * @param[in] paths The UTF-8 encoded file and/or directory path names.
arturo89d07232013-07-10 11:42:14 +02001959 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001960 * @pointer_lifetime The path array and its strings are valid until the
1961 * callback function returns.
1962 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001963 * @sa @ref path_drop
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001964 * @sa @ref glfwSetDropCallback
arturo89d07232013-07-10 11:42:14 +02001965 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001966 * @since Added in version 3.1.
Camilla Berglund810bab72015-12-13 17:38:14 +01001967 *
arturo89d07232013-07-10 11:42:14 +02001968 * @ingroup input
1969 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001970typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
arturo89d07232013-07-10 11:42:14 +02001971
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001972/*! @brief The function pointer type for monitor configuration callbacks.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001973 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001974 * This is the function pointer type for monitor configuration callbacks.
1975 * A monitor callback function has the following signature:
1976 * @code
1977 * void function_name(GLFWmonitor* monitor, int event)
1978 * @endcode
Camilla Berglund8282a8f2013-04-10 23:01:12 +02001979 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01001980 * @param[in] monitor The monitor that was connected or disconnected.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001981 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
1982 * releases may add more events.
Camilla Berglunddba2d802013-01-17 23:06:56 +01001983 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01001984 * @sa @ref monitor_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02001985 * @sa @ref glfwSetMonitorCallback
Camilla Berglunde248fb62013-03-29 14:06:23 +01001986 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01001987 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01001988 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01001989 * @ingroup monitor
Camilla Berglund5f68e122012-11-27 17:07:28 +01001990 */
Camilla Löwy4e557432021-08-25 20:47:17 +02001991typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event);
Camilla Berglund897558f2011-03-07 13:34:58 +01001992
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001993/*! @brief The function pointer type for joystick configuration callbacks.
Camilla Berglund8a7fa302015-12-13 17:38:50 +01001994 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02001995 * This is the function pointer type for joystick configuration callbacks.
1996 * A joystick configuration callback function has the following signature:
1997 * @code
1998 * void function_name(int jid, int event)
1999 * @endcode
Camilla Berglund8a7fa302015-12-13 17:38:50 +01002000 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02002001 * @param[in] jid The joystick that was connected or disconnected.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002002 * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
2003 * releases may add more events.
Camilla Berglund8a7fa302015-12-13 17:38:50 +01002004 *
2005 * @sa @ref joystick_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002006 * @sa @ref glfwSetJoystickCallback
Camilla Berglund8a7fa302015-12-13 17:38:50 +01002007 *
2008 * @since Added in version 3.2.
2009 *
2010 * @ingroup input
2011 */
Camilla Löwy4e557432021-08-25 20:47:17 +02002012typedef void (* GLFWjoystickfun)(int jid, int event);
Camilla Berglund8a7fa302015-12-13 17:38:50 +01002013
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002014/*! @brief Video mode type.
2015 *
2016 * This describes a single video mode.
2017 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002018 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002019 * @sa @ref glfwGetVideoMode
2020 * @sa @ref glfwGetVideoModes
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002021 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002022 * @since Added in version 1.0.
2023 * @glfw3 Added refresh rate member.
Camilla Berglund810bab72015-12-13 17:38:14 +01002024 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002025 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002026 */
Systemclusterd0a0e372013-08-29 06:15:55 +02002027typedef struct GLFWvidmode
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02002028{
Camilla Berglund95835af2013-05-30 13:53:25 +02002029 /*! The width, in screen coordinates, of the video mode.
Camilla Berglundc1594112013-05-27 22:29:06 +02002030 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02002031 int width;
Camilla Berglund95835af2013-05-30 13:53:25 +02002032 /*! The height, in screen coordinates, of the video mode.
Camilla Berglundc1594112013-05-27 22:29:06 +02002033 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02002034 int height;
Camilla Berglundc1594112013-05-27 22:29:06 +02002035 /*! The bit depth of the red channel of the video mode.
2036 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02002037 int redBits;
Camilla Berglundc1594112013-05-27 22:29:06 +02002038 /*! The bit depth of the green channel of the video mode.
2039 */
Camilla Berglund5fd3fc72010-09-09 19:44:43 +02002040 int greenBits;
Camilla Berglundc1594112013-05-27 22:29:06 +02002041 /*! The bit depth of the blue channel of the video mode.
2042 */
Camilla Berglund2e8446f2013-04-11 01:31:00 +02002043 int blueBits;
Camilla Berglund731812c2013-05-30 15:52:42 +02002044 /*! The refresh rate, in Hz, of the video mode.
2045 */
2046 int refreshRate;
Camilla Berglund3249f812010-09-07 17:34:51 +02002047} GLFWvidmode;
2048
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002049/*! @brief Gamma ramp.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002050 *
2051 * This describes the gamma ramp for a monitor.
2052 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002053 * @sa @ref monitor_gamma
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002054 * @sa @ref glfwGetGammaRamp
2055 * @sa @ref glfwSetGammaRamp
Camilla Berglund8282a8f2013-04-10 23:01:12 +02002056 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002057 * @since Added in version 3.0.
Camilla Berglund810bab72015-12-13 17:38:14 +01002058 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002059 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002060 */
Systemclusterd0a0e372013-08-29 06:15:55 +02002061typedef struct GLFWgammaramp
Camilla Berglund2630d492010-10-13 04:04:43 +02002062{
Camilla Berglundc1594112013-05-27 22:29:06 +02002063 /*! An array of value describing the response of the red channel.
2064 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002065 unsigned short* red;
Camilla Berglundc1594112013-05-27 22:29:06 +02002066 /*! An array of value describing the response of the green channel.
2067 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002068 unsigned short* green;
Camilla Berglundc1594112013-05-27 22:29:06 +02002069 /*! An array of value describing the response of the blue channel.
2070 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002071 unsigned short* blue;
Camilla Berglundc1594112013-05-27 22:29:06 +02002072 /*! The number of elements in each array.
2073 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002074 unsigned int size;
Camilla Berglund2630d492010-10-13 04:04:43 +02002075} GLFWgammaramp;
2076
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01002077/*! @brief Image data.
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002078 *
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02002079 * This describes a single 2D image. See the documentation for each related
2080 * function what the expected pixel format is.
2081 *
Camilla Berglund9d71eb42015-11-05 09:24:16 +01002082 * @sa @ref cursor_custom
Camilla Berglundfe0317a2016-08-01 11:51:30 +02002083 * @sa @ref window_icon
Camilla Berglund810bab72015-12-13 17:38:14 +01002084 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002085 * @since Added in version 2.1.
2086 * @glfw3 Removed format and bytes-per-pixel members.
Camilla Löwy04116782018-11-05 17:37:49 +01002087 *
2088 * @ingroup window
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01002089 */
2090typedef struct GLFWimage
2091{
2092 /*! The width, in pixels, of this image.
2093 */
2094 int width;
2095 /*! The height, in pixels, of this image.
2096 */
2097 int height;
2098 /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
2099 */
2100 unsigned char* pixels;
2101} GLFWimage;
2102
Camilla Löwy953106e2017-06-18 15:13:25 +02002103/*! @brief Gamepad input state
2104 *
2105 * This describes the input state of a gamepad.
2106 *
2107 * @sa @ref gamepad
2108 * @sa @ref glfwGetGamepadState
2109 *
2110 * @since Added in version 3.3.
Camilla Löwy04116782018-11-05 17:37:49 +01002111 *
2112 * @ingroup input
Camilla Löwy953106e2017-06-18 15:13:25 +02002113 */
2114typedef struct GLFWgamepadstate
2115{
2116 /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
2117 * or `GLFW_RELEASE`.
2118 */
Camilla Löwy2d8d8f52017-07-17 21:18:15 +02002119 unsigned char buttons[15];
Camilla Löwy953106e2017-06-18 15:13:25 +02002120 /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
2121 * to 1.0 inclusive.
2122 */
2123 float axes[6];
2124} GLFWgamepadstate;
2125
Camilla Löwy2afd57b2024-01-31 01:45:02 +01002126/*! @brief Custom heap memory allocator.
2127 *
2128 * This describes a custom heap memory allocator for GLFW. To set an allocator, pass it
2129 * to @ref glfwInitAllocator before initializing the library.
Camilla Löwy22b586b2021-08-03 20:53:48 +02002130 *
2131 * @sa @ref init_allocator
2132 * @sa @ref glfwInitAllocator
2133 *
2134 * @since Added in version 3.4.
2135 *
2136 * @ingroup init
2137 */
2138typedef struct GLFWallocator
2139{
Camilla Löwy2afd57b2024-01-31 01:45:02 +01002140 /*! The memory allocation function. See @ref GLFWallocatefun for details about
2141 * allocation function.
2142 */
Camilla Löwy22b586b2021-08-03 20:53:48 +02002143 GLFWallocatefun allocate;
Camilla Löwy2afd57b2024-01-31 01:45:02 +01002144 /*! The memory reallocation function. See @ref GLFWreallocatefun for details about
2145 * reallocation function.
2146 */
Camilla Löwy22b586b2021-08-03 20:53:48 +02002147 GLFWreallocatefun reallocate;
Camilla Löwy2afd57b2024-01-31 01:45:02 +01002148 /*! The memory deallocation function. See @ref GLFWdeallocatefun for details about
2149 * deallocation function.
2150 */
Camilla Löwy22b586b2021-08-03 20:53:48 +02002151 GLFWdeallocatefun deallocate;
Camilla Löwy2afd57b2024-01-31 01:45:02 +01002152 /*! The user pointer for this custom allocator. This value will be passed to the
2153 * allocator functions.
2154 */
Camilla Löwy22b586b2021-08-03 20:53:48 +02002155 void* user;
2156} GLFWallocator;
2157
Camilla Berglund3249f812010-09-07 17:34:51 +02002158
2159/*************************************************************************
Camilla Berglund2fca5c52013-01-17 21:51:39 +01002160 * GLFW API functions
Camilla Berglund3249f812010-09-07 17:34:51 +02002161 *************************************************************************/
2162
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002163/*! @brief Initializes the GLFW library.
2164 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002165 * This function initializes the GLFW library. Before most GLFW functions can
Camilla Berglund4591ad22014-09-18 15:03:29 +02002166 * be used, GLFW must be initialized, and before an application terminates GLFW
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002167 * should be terminated in order to free any resources allocated during or
2168 * after initialization.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002169 *
Camilla Berglund23f61762013-03-12 19:53:29 +01002170 * If this function fails, it calls @ref glfwTerminate before returning. If it
Camilla Berglund4591ad22014-09-18 15:03:29 +02002171 * succeeds, you should call @ref glfwTerminate before the application exits.
Camilla Berglund23f61762013-03-12 19:53:29 +01002172 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002173 * Additional calls to this function after successful initialization but before
Camilla Berglund0eccf752015-08-23 19:30:04 +02002174 * termination will return `GLFW_TRUE` immediately.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002175 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002176 * The @ref GLFW_PLATFORM init hint controls which platforms are considered during
2177 * initialization. This also depends on which platforms the library was compiled to
2178 * support.
2179 *
Camilla Berglund0eccf752015-08-23 19:30:04 +02002180 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02002181 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002182 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002183 * @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref
2184 * GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01002185 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02002186 * @remark @macos This function will change the current directory of the
Camilla Berglund71d2b572013-03-12 15:33:05 +01002187 * application to the `Contents/Resources` subdirectory of the application's
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002188 * bundle, if present. This can be disabled with the @ref
2189 * GLFW_COCOA_CHDIR_RESOURCES init hint.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002190 *
Camilla Löwy72366ac2020-03-05 20:32:19 +01002191 * @remark @macos This function will create the main menu and dock icon for the
2192 * application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to
2193 * contain a menu bar. Otherwise a minimal menu bar is created manually with
2194 * common commands like Hide, Quit and About. The About entry opens a minimal
2195 * about dialog with information from the application's bundle. The menu bar
2196 * and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
2197 * hint.
2198 *
Camilla Löwy14e65332024-02-15 20:55:28 +01002199 * @remark __Wayland, X11:__ If the library was compiled with support for both
2200 * Wayland and X11, and the @ref GLFW_PLATFORM init hint is set to
2201 * `GLFW_ANY_PLATFORM`, the `XDG_SESSION_TYPE` environment variable affects
2202 * which platform is picked. If the environment variable is not set, or is set
2203 * to something other than `wayland` or `x11`, the regular detection mechanism
2204 * will be used instead.
2205 *
Camilla Löwy0bb605c2024-02-19 15:06:59 +01002206 * @remark @x11 This function will set the `LC_CTYPE` category of the
2207 * application locale according to the current environment if that category is
2208 * still "C". This is because the "C" locale breaks Unicode text input.
2209 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002210 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002211 *
2212 * @sa @ref intro_init
Camilla Löwy22b586b2021-08-03 20:53:48 +02002213 * @sa @ref glfwInitHint
2214 * @sa @ref glfwInitAllocator
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002215 * @sa @ref glfwTerminate
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002216 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002217 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002218 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002219 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002220 */
2221GLFWAPI int glfwInit(void);
2222
2223/*! @brief Terminates the GLFW library.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002224 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002225 * This function destroys all remaining windows and cursors, restores any
2226 * modified gamma ramps and frees any other allocated resources. Once this
2227 * function is called, you must again call @ref glfwInit successfully before
2228 * you will be able to use most GLFW functions.
Camilla Berglund23f61762013-03-12 19:53:29 +01002229 *
2230 * If GLFW has been successfully initialized, this function should be called
Camilla Berglund4591ad22014-09-18 15:03:29 +02002231 * before the application exits. If initialization fails, there is no need to
2232 * call this function, as it is called by @ref glfwInit before it returns
2233 * failure.
Camilla Berglund23f61762013-03-12 19:53:29 +01002234 *
A. Tombs7486e122020-05-22 14:37:58 +01002235 * This function has no effect if GLFW is not initialized.
2236 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002237 * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
2238 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002239 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002240 *
Camilla Berglund0df4e062015-12-13 14:07:27 +01002241 * @warning The contexts of any remaining windows must not be current on any
2242 * other thread when this function is called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002243 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002244 * @reentrancy This function must not be called from a callback.
Camilla Berglund20858762015-01-01 18:41:22 +01002245 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002246 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002247 *
2248 * @sa @ref intro_init
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002249 * @sa @ref glfwInit
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002250 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002251 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002252 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002253 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002254 */
Camilla Berglund9a716692010-09-08 16:40:43 +02002255GLFWAPI void glfwTerminate(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002256
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002257/*! @brief Sets the specified init hint to the desired value.
2258 *
Camilla Löwy61588012017-12-12 10:54:18 +01002259 * This function sets hints for the next initialization of GLFW.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002260 *
Camilla Löwy213dd2d2017-07-25 01:55:08 +02002261 * The values you set hints to are never reset by GLFW, but they only take
2262 * effect during initialization. Once GLFW has been initialized, any values
2263 * you set will be ignored until the library is terminated and initialized
2264 * again.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002265 *
Camilla Löwy213dd2d2017-07-25 01:55:08 +02002266 * Some hints are platform specific. These may be set on any platform but they
Camilla Löwy1be81a12017-10-22 16:27:17 +02002267 * will only affect their specific platform. Other platforms will ignore them.
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00002268 * Setting these hints requires no platform specific headers or functions.
Camilla Löwy6d9a58b2017-02-14 15:43:31 +01002269 *
2270 * @param[in] hint The [init hint](@ref init_hints) to set.
2271 * @param[in] value The new value of the init hint.
2272 *
2273 * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
2274 * GLFW_INVALID_VALUE.
2275 *
2276 * @remarks This function may be called before @ref glfwInit.
2277 *
2278 * @thread_safety This function must only be called from the main thread.
2279 *
2280 * @sa init_hints
2281 * @sa glfwInit
2282 *
2283 * @since Added in version 3.3.
2284 *
2285 * @ingroup init
2286 */
2287GLFWAPI void glfwInitHint(int hint, int value);
2288
Camilla Löwy22b586b2021-08-03 20:53:48 +02002289/*! @brief Sets the init allocator to the desired value.
2290 *
2291 * To use the default allocator, call this function with a `NULL` argument.
2292 *
2293 * If you specify an allocator struct, every member must be a valid function
Camilla Löwy2afd57b2024-01-31 01:45:02 +01002294 * pointer. If any member is `NULL`, this function will emit @ref
2295 * GLFW_INVALID_VALUE and the init allocator will be unchanged.
2296 *
2297 * The functions in the allocator must fulfil a number of requirements. See the
2298 * documentation for @ref GLFWallocatefun, @ref GLFWreallocatefun and @ref
2299 * GLFWdeallocatefun for details.
Camilla Löwy22b586b2021-08-03 20:53:48 +02002300 *
2301 * @param[in] allocator The allocator to use at the next initialization, or
2302 * `NULL` to use the default one.
2303 *
2304 * @errors Possible errors include @ref GLFW_INVALID_VALUE.
2305 *
2306 * @pointer_lifetime The specified allocator is copied before this function
2307 * returns.
2308 *
2309 * @thread_safety This function must only be called from the main thread.
2310 *
2311 * @sa @ref init_allocator
2312 * @sa @ref glfwInit
2313 *
2314 * @since Added in version 3.4.
2315 *
2316 * @ingroup init
2317 */
2318GLFWAPI void glfwInitAllocator(const GLFWallocator* allocator);
2319
Camilla Löwy76a5f782021-10-21 20:45:44 +02002320#if defined(VK_VERSION_1_0)
2321
2322/*! @brief Sets the desired Vulkan `vkGetInstanceProcAddr` function.
2323 *
2324 * This function sets the `vkGetInstanceProcAddr` function that GLFW will use for all
2325 * Vulkan related entry point queries.
2326 *
2327 * This feature is mostly useful on macOS, if your copy of the Vulkan loader is in
2328 * a location where GLFW cannot find it through dynamic loading, or if you are still
2329 * using the static library version of the loader.
2330 *
2331 * If set to `NULL`, GLFW will try to load the Vulkan loader dynamically by its standard
2332 * name and get this function from there. This is the default behavior.
2333 *
2334 * The standard name of the loader is `vulkan-1.dll` on Windows, `libvulkan.so.1` on
2335 * Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. If your code is
2336 * also loading it via these names then you probably don't need to use this function.
2337 *
2338 * The function address you set is never reset by GLFW, but it only takes effect during
2339 * initialization. Once GLFW has been initialized, any updates will be ignored until the
2340 * library is terminated and initialized again.
2341 *
2342 * @param[in] loader The address of the function to use, or `NULL`.
2343 *
2344 * @par Loader function signature
2345 * @code
2346 * PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance instance, const char* name)
2347 * @endcode
2348 * For more information about this function, see the
2349 * [Vulkan Registry](https://www.khronos.org/registry/vulkan/).
2350 *
2351 * @errors None.
2352 *
2353 * @remark This function may be called before @ref glfwInit.
2354 *
2355 * @thread_safety This function must only be called from the main thread.
2356 *
2357 * @sa @ref vulkan_loader
2358 * @sa @ref glfwInit
2359 *
2360 * @since Added in version 3.4.
2361 *
2362 * @ingroup init
2363 */
2364GLFWAPI void glfwInitVulkanLoader(PFN_vkGetInstanceProcAddr loader);
2365
2366#endif /*VK_VERSION_1_0*/
2367
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002368/*! @brief Retrieves the version of the GLFW library.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002369 *
2370 * This function retrieves the major, minor and revision numbers of the GLFW
2371 * library. It is intended for when you are using GLFW as a shared library and
2372 * want to ensure that you are using the minimum required version.
2373 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002374 * Any or all of the version arguments may be `NULL`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002375 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01002376 * @param[out] major Where to store the major version number, or `NULL`.
2377 * @param[out] minor Where to store the minor version number, or `NULL`.
2378 * @param[out] rev Where to store the revision number, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002379 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002380 * @errors None.
2381 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002382 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002383 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002384 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002385 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002386 * @sa @ref intro_version
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002387 * @sa @ref glfwGetVersionString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002388 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002389 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002390 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002391 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002392 */
Camilla Berglund9a716692010-09-08 16:40:43 +02002393GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002394
Camilla Berglund6f8084f2013-02-14 13:14:17 +01002395/*! @brief Returns a string describing the compile-time configuration.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002396 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002397 * This function returns the compile-time generated
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002398 * [version string](@ref intro_version_string) of the GLFW library binary. It describes
2399 * the version, platforms, compiler and any platform or operating system specific
2400 * compile-time options. It should not be confused with the OpenGL or OpenGL ES version
2401 * string, queried with `glGetString`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002402 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002403 * __Do not use the version string__ to parse the GLFW library version. The
Camilla Berglund386b6032016-02-10 13:48:49 +01002404 * @ref glfwGetVersion function provides the version of the running library
2405 * binary in numerical format.
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002406 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002407 * __Do not use the version string__ to parse what platforms are supported. The @ref
2408 * glfwPlatformSupported function lets you query platform support.
2409 *
Camilla Berglund386b6032016-02-10 13:48:49 +01002410 * @return The ASCII encoded GLFW version string.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002411 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002412 * @errors None.
2413 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002414 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002415 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002416 * @pointer_lifetime The returned string is static and compile-time generated.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002417 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002418 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002419 *
2420 * @sa @ref intro_version
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002421 * @sa @ref glfwGetVersion
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002422 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002423 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002424 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002425 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002426 */
Camilla Berglundd6fe4472010-09-13 18:05:59 +02002427GLFWAPI const char* glfwGetVersionString(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02002428
Camilla Löwy63506412017-05-01 19:20:57 +02002429/*! @brief Returns and clears the last error for the calling thread.
2430 *
Camilla Löwy2e9aff72017-07-09 14:46:39 +02002431 * This function returns and clears the [error code](@ref errors) of the last
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002432 * error that occurred on the calling thread, and optionally a UTF-8 encoded
2433 * human-readable description of it. If no error has occurred since the last
Camilla Löwy539a7282017-06-11 18:04:17 +02002434 * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
2435 * set to `NULL`.
Camilla Löwy63506412017-05-01 19:20:57 +02002436 *
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002437 * @param[in] description Where to store the error description pointer, or `NULL`.
Camilla Löwy539a7282017-06-11 18:04:17 +02002438 * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
2439 * (zero).
Camilla Löwy63506412017-05-01 19:20:57 +02002440 *
2441 * @errors None.
2442 *
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002443 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2444 * should not free it yourself. It is guaranteed to be valid only until the
2445 * next error occurs or the library is terminated.
2446 *
Camilla Löwy63506412017-05-01 19:20:57 +02002447 * @remark This function may be called before @ref glfwInit.
2448 *
2449 * @thread_safety This function may be called from any thread.
2450 *
2451 * @sa @ref error_handling
2452 * @sa @ref glfwSetErrorCallback
2453 *
2454 * @since Added in version 3.3.
2455 *
2456 * @ingroup init
2457 */
Camilla Löwy14a3fe02017-05-25 18:23:09 +02002458GLFWAPI int glfwGetError(const char** description);
Camilla Löwy63506412017-05-01 19:20:57 +02002459
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002460/*! @brief Sets the error callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002461 *
2462 * This function sets the error callback, which is called with an error code
2463 * and a human-readable description each time a GLFW error occurs.
2464 *
Camilla Löwy63506412017-05-01 19:20:57 +02002465 * The error code is set before the callback is called. Calling @ref
2466 * glfwGetError from the error callback will return the same value as the error
2467 * code argument.
2468 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002469 * The error callback is called on the thread where the error occurred. If you
2470 * are using GLFW from multiple threads, your error callback needs to be
2471 * written accordingly.
2472 *
2473 * Because the description string may have been generated specifically for that
2474 * error, it is not guaranteed to be valid after the callback has returned. If
2475 * you wish to use it after the callback returns, you need to make a copy.
2476 *
Camilla Berglund20858762015-01-01 18:41:22 +01002477 * Once set, the error callback remains set even after the library has been
2478 * terminated.
2479 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002480 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002481 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002482 * @return The previously set callback, or `NULL` if no callback was set.
2483 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002484 * @callback_signature
2485 * @code
2486 * void callback_name(int error_code, const char* description)
2487 * @endcode
2488 * For more information about the callback parameters, see the
2489 * [callback pointer type](@ref GLFWerrorfun).
2490 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002491 * @errors None.
2492 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002493 * @remark This function may be called before @ref glfwInit.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002494 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002495 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01002496 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002497 * @sa @ref error_handling
Camilla Löwy63506412017-05-01 19:20:57 +02002498 * @sa @ref glfwGetError
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002499 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002500 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002501 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002502 * @ingroup init
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002503 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002504GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
Camilla Berglundf5d74c42010-09-09 21:06:59 +02002505
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002506/*! @brief Returns the currently selected platform.
2507 *
2508 * This function returns the platform that was selected during initialization. The
2509 * returned value will be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
2510 * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
2511 *
2512 * @return The currently selected platform, or zero if an error occurred.
2513 *
2514 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2515 *
2516 * @thread_safety This function may be called from any thread.
2517 *
2518 * @sa @ref platform
2519 * @sa @ref glfwPlatformSupported
2520 *
2521 * @since Added in version 3.4.
2522 *
2523 * @ingroup init
2524 */
2525GLFWAPI int glfwGetPlatform(void);
2526
2527/*! @brief Returns whether the library includes support for the specified platform.
2528 *
2529 * This function returns whether the library was compiled with support for the specified
2530 * platform. The platform must be one of `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`,
2531 * `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`.
2532 *
2533 * @param[in] platform The platform to query.
2534 * @return `GLFW_TRUE` if the platform is supported, or `GLFW_FALSE` otherwise.
2535 *
2536 * @errors Possible errors include @ref GLFW_INVALID_ENUM.
2537 *
2538 * @remark This function may be called before @ref glfwInit.
2539 *
2540 * @thread_safety This function may be called from any thread.
2541 *
2542 * @sa @ref platform
2543 * @sa @ref glfwGetPlatform
2544 *
2545 * @since Added in version 3.4.
2546 *
2547 * @ingroup init
2548 */
2549GLFWAPI int glfwPlatformSupported(int platform);
2550
Camilla Berglund5f68e122012-11-27 17:07:28 +01002551/*! @brief Returns the currently connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002552 *
2553 * This function returns an array of handles for all currently connected
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002554 * monitors. The primary monitor is always first in the returned array. If no
2555 * monitors were found, this function returns `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002556 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002557 * @param[out] count Where to store the number of monitors in the returned
2558 * array. This is set to zero if an error occurred.
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002559 * @return An array of monitor handles, or `NULL` if no monitors were found or
2560 * if an [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002561 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002562 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2563 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002564 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2565 * should not free it yourself. It is guaranteed to be valid only until the
2566 * monitor configuration changes or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002567 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002568 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002569 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002570 * @sa @ref monitor_monitors
2571 * @sa @ref monitor_event
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002572 * @sa @ref glfwGetPrimaryMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002573 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002574 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002575 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002576 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002577 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002578GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002579
Camilla Berglund5f68e122012-11-27 17:07:28 +01002580/*! @brief Returns the primary monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002581 *
2582 * This function returns the primary monitor. This is usually the monitor
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002583 * where elements like the task bar or global menu bar are located.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002584 *
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002585 * @return The primary monitor, or `NULL` if no monitors were found or if an
2586 * [error](@ref error_handling) occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002587 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002588 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2589 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002590 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01002591 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002592 * @remark The primary monitor is always first in the array returned by @ref
Camilla Berglundf5cbdba2015-09-17 16:37:09 +02002593 * glfwGetMonitors.
2594 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002595 * @sa @ref monitor_monitors
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002596 * @sa @ref glfwGetMonitors
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002597 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002598 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002599 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002600 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002601 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002602GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002603
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002604/*! @brief Returns the position of the monitor's viewport on the virtual screen.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002605 *
2606 * This function returns the position, in screen coordinates, of the upper-left
2607 * corner of the specified monitor.
2608 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002609 * Any or all of the position arguments may be `NULL`. If an error occurs, all
2610 * non-`NULL` position arguments will be set to zero.
2611 *
Camilla Berglunddba2d802013-01-17 23:06:56 +01002612 * @param[in] monitor The monitor to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002613 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2614 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002615 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002616 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2617 * GLFW_PLATFORM_ERROR.
2618 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002619 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002620 *
2621 * @sa @ref monitor_properties
2622 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002623 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01002624 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002625 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002626 */
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002627GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
2628
luz.paz7105ff22019-08-12 06:52:31 -04002629/*! @brief Retrieves the work area of the monitor.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002630 *
2631 * This function returns the position, in screen coordinates, of the upper-left
Camilla Löwy01187432019-02-25 14:01:08 +01002632 * corner of the work area of the specified monitor along with the work area
2633 * size in screen coordinates. The work area is defined as the area of the
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002634 * monitor not occluded by the window system task bar where present. If no
Camilla Löwy01187432019-02-25 14:01:08 +01002635 * task bar exists then the work area is the monitor resolution in screen
2636 * coordinates.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002637 *
Camilla Löwy01187432019-02-25 14:01:08 +01002638 * Any or all of the position and size arguments may be `NULL`. If an error
2639 * occurs, all non-`NULL` position and size arguments will be set to zero.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002640 *
2641 * @param[in] monitor The monitor to query.
2642 * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
2643 * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
Doug Binks3fd70cc2018-09-08 17:16:07 +02002644 * @param[out] width Where to store the monitor width, or `NULL`.
2645 * @param[out] height Where to store the monitor height, or `NULL`.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002646 *
2647 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2648 * GLFW_PLATFORM_ERROR.
2649 *
2650 * @thread_safety This function must only be called from the main thread.
2651 *
Camilla Löwya43d1a42019-02-25 14:46:48 +01002652 * @sa @ref monitor_workarea
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002653 *
Doug Binks69076292018-09-08 17:24:20 +02002654 * @since Added in version 3.3.
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002655 *
2656 * @ingroup monitor
2657 */
Camilla Löwy01187432019-02-25 14:01:08 +01002658GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
Felipe Ferreira da Silvabe295cc2017-04-06 16:48:08 -03002659
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002660/*! @brief Returns the physical size of the monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002661 *
2662 * This function returns the size, in millimetres, of the display area of the
2663 * specified monitor.
2664 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02002665 * Some platforms do not provide accurate monitor size information, either
Camilla Löwy63397fb2024-02-14 01:36:35 +01002666 * because the monitor [EDID][] data is incorrect or because the driver does
2667 * not report it accurately.
2668 *
2669 * [EDID]: https://en.wikipedia.org/wiki/Extended_display_identification_data
Camilla Berglund4188c262015-01-18 01:55:25 +01002670 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002671 * Any or all of the size arguments may be `NULL`. If an error occurs, all
2672 * non-`NULL` size arguments will be set to zero.
2673 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002674 * @param[in] monitor The monitor to query.
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002675 * @param[out] widthMM Where to store the width, in millimetres, of the
2676 * monitor's display area, or `NULL`.
2677 * @param[out] heightMM Where to store the height, in millimetres, of the
2678 * monitor's display area, or `NULL`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002679 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002680 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2681 *
Camilla Löwy6a200532021-10-12 00:23:37 +02002682 * @remark @win32 On Windows 8 and earlier the physical size is calculated from
2683 * the current resolution and system DPI instead of querying the monitor EDID data.
Camilla Berglund0e205772014-03-24 11:58:35 +01002684 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002685 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002686 *
2687 * @sa @ref monitor_properties
2688 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002689 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002690 *
Camilla Berglundee5f30e2013-01-24 19:10:17 +01002691 * @ingroup monitor
2692 */
Camilla Berglundce8f97c2015-01-11 23:33:14 +01002693GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002694
Camilla Löwy16bf8722017-08-29 19:19:00 +02002695/*! @brief Retrieves the content scale for the specified monitor.
2696 *
2697 * This function retrieves the content scale for the specified monitor. The
2698 * content scale is the ratio between the current DPI and the platform's
Camilla Löwy422bf792019-04-01 18:36:30 +02002699 * default DPI. This is especially important for text and any UI elements. If
2700 * the pixel dimensions of your UI scaled by this look appropriate on your
2701 * machine then it should appear at a reasonable size on other machines
2702 * regardless of their DPI and scaling settings. This relies on the system DPI
2703 * and scaling settings being somewhat correct.
Camilla Löwy16bf8722017-08-29 19:19:00 +02002704 *
2705 * The content scale may depend on both the monitor resolution and pixel
2706 * density and on user settings. It may be very different from the raw DPI
2707 * calculated from the physical size and current resolution.
2708 *
2709 * @param[in] monitor The monitor to query.
2710 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
2711 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
2712 *
2713 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2714 * GLFW_PLATFORM_ERROR.
2715 *
Camilla Löwy2b3f9192024-02-08 22:08:31 +01002716 * @remark @wayland Fractional scaling information is not yet available for
2717 * monitors, so this function only returns integer content scales.
2718 *
Camilla Löwy16bf8722017-08-29 19:19:00 +02002719 * @thread_safety This function must only be called from the main thread.
2720 *
2721 * @sa @ref monitor_scale
2722 * @sa @ref glfwGetWindowContentScale
2723 *
2724 * @since Added in version 3.3.
2725 *
2726 * @ingroup monitor
2727 */
2728GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
2729
Camilla Berglund5f68e122012-11-27 17:07:28 +01002730/*! @brief Returns the name of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002731 *
2732 * This function returns a human-readable name, encoded as UTF-8, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02002733 * specified monitor. The name typically reflects the make and model of the
2734 * monitor and is not guaranteed to be unique among the connected monitors.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002735 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002736 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002737 * @return The UTF-8 encoded name of the monitor, or `NULL` if an
2738 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002739 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002740 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2741 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002742 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
2743 * should not free it yourself. It is valid until the specified monitor is
2744 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002745 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002746 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002747 *
2748 * @sa @ref monitor_properties
2749 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002750 * @since Added in version 3.0.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002751 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002752 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002753 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002754GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002755
Camilla Löwy7c2c7852017-12-07 16:19:57 +01002756/*! @brief Sets the user pointer of the specified monitor.
2757 *
2758 * This function sets the user-defined pointer of the specified monitor. The
2759 * current value is retained until the monitor is disconnected. The initial
2760 * value is `NULL`.
2761 *
2762 * This function may be called from the monitor callback, even for a monitor
2763 * that is being disconnected.
2764 *
2765 * @param[in] monitor The monitor whose pointer to set.
2766 * @param[in] pointer The new value.
2767 *
2768 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2769 *
2770 * @thread_safety This function may be called from any thread. Access is not
2771 * synchronized.
2772 *
2773 * @sa @ref monitor_userptr
2774 * @sa @ref glfwGetMonitorUserPointer
2775 *
2776 * @since Added in version 3.3.
2777 *
2778 * @ingroup monitor
2779 */
2780GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
2781
2782/*! @brief Returns the user pointer of the specified monitor.
2783 *
2784 * This function returns the current value of the user-defined pointer of the
2785 * specified monitor. The initial value is `NULL`.
2786 *
2787 * This function may be called from the monitor callback, even for a monitor
2788 * that is being disconnected.
2789 *
2790 * @param[in] monitor The monitor whose pointer to return.
2791 *
2792 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2793 *
2794 * @thread_safety This function may be called from any thread. Access is not
2795 * synchronized.
2796 *
2797 * @sa @ref monitor_userptr
2798 * @sa @ref glfwSetMonitorUserPointer
2799 *
2800 * @since Added in version 3.3.
2801 *
2802 * @ingroup monitor
2803 */
2804GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
2805
Camilla Berglund5f68e122012-11-27 17:07:28 +01002806/*! @brief Sets the monitor configuration callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002807 *
2808 * This function sets the monitor configuration callback, or removes the
2809 * currently set callback. This is called when a monitor is connected to or
2810 * disconnected from the system.
2811 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002812 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01002813 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002814 * @return The previously set callback, or `NULL` if no callback was set or the
2815 * library had not been [initialized](@ref intro_init).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002816 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002817 * @callback_signature
2818 * @code
2819 * void function_name(GLFWmonitor* monitor, int event)
2820 * @endcode
2821 * For more information about the callback parameters, see the
2822 * [function pointer type](@ref GLFWmonitorfun).
2823 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002824 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
2825 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002826 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002827 *
2828 * @sa @ref monitor_event
2829 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002830 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002831 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002832 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002833 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02002834GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
Marcel Metzbeacbb32011-05-07 10:53:50 +02002835
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002836/*! @brief Returns the available video modes for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002837 *
2838 * This function returns an array of all video modes supported by the specified
Camilla Berglund948cc042013-04-16 02:02:22 +02002839 * monitor. The returned array is sorted in ascending order, first by color
Camilla Löwy0e9ec772021-04-22 23:07:50 +02002840 * bit depth (the sum of all channel depths), then by resolution area (the
2841 * product of width and height), then resolution width and finally by refresh
2842 * rate.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002843 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002844 * @param[in] monitor The monitor to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02002845 * @param[out] count Where to store the number of video modes in the returned
2846 * array. This is set to zero if an error occurred.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002847 * @return An array of video modes, or `NULL` if an
2848 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002849 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002850 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2851 * GLFW_PLATFORM_ERROR.
2852 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002853 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2854 * should not free it yourself. It is valid until the specified monitor is
2855 * disconnected, this function is called again for that monitor or the library
2856 * is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002857 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002858 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002859 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002860 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002861 * @sa @ref glfwGetVideoMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002862 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002863 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01002864 * @glfw3 Changed to return an array of modes for a specific monitor.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002865 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002866 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002867 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01002868GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002869
Camilla Berglund5f68e122012-11-27 17:07:28 +01002870/*! @brief Returns the current mode of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002871 *
Camilla Berglund948cc042013-04-16 02:02:22 +02002872 * This function returns the current video mode of the specified monitor. If
Camilla Berglund4591ad22014-09-18 15:03:29 +02002873 * you have created a full screen window for that monitor, the return value
2874 * will depend on whether that window is iconified.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002875 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01002876 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002877 * @return The current mode of the monitor, or `NULL` if an
2878 * [error](@ref error_handling) occurred.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002879 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01002880 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
2881 * GLFW_PLATFORM_ERROR.
2882 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002883 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
2884 * should not free it yourself. It is valid until the specified monitor is
2885 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002886 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002887 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002888 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002889 * @sa @ref monitor_modes
Camilla Berglund7e9e3212016-09-14 20:17:26 +02002890 * @sa @ref glfwGetVideoModes
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002891 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002892 * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002893 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002894 * @ingroup monitor
Camilla Berglund41bc0d12012-11-27 16:55:04 +01002895 */
Camilla Berglundce1e84d2013-05-22 22:16:43 +02002896GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
Camilla Berglund3249f812010-09-07 17:34:51 +02002897
Camilla Berglund92a71e02013-02-12 13:50:41 +01002898/*! @brief Generates a gamma ramp and sets it for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002899 *
Camilla Löwy3531c322018-12-17 17:40:18 +01002900 * This function generates an appropriately sized gamma ramp from the specified
2901 * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
2902 * a finite number greater than zero.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002903 *
Camilla Löwyce161c22016-12-06 01:14:23 +01002904 * The software controlled gamma ramp is applied _in addition_ to the hardware
2905 * gamma correction, which today is usually an approximation of sRGB gamma.
2906 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2907 * the default (usually sRGB-like) behavior.
2908 *
2909 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2910 * GLFW_SRGB_CAPABLE hint.
2911 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002912 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01002913 * @param[in] gamma The desired exponent.
Camilla Berglunddba2d802013-01-17 23:06:56 +01002914 *
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002915 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
2916 * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01002917 *
luz.paz7105ff22019-08-12 06:52:31 -04002918 * @remark @wayland Gamma handling is a privileged protocol, this function
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002919 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01002920 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002921 * @thread_safety This function must only be called from the main thread.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02002922 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002923 * @sa @ref monitor_gamma
2924 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002925 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01002926 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002927 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002928 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01002929GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002930
Camilla Berglund4591ad22014-09-18 15:03:29 +02002931/*! @brief Returns the current gamma ramp for the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002932 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002933 * This function returns the current gamma ramp of the specified monitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002934 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002935 * @param[in] monitor The monitor to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002936 * @return The current gamma ramp, or `NULL` if an
2937 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002938 *
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002939 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
2940 * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01002941 *
luz.paz7105ff22019-08-12 06:52:31 -04002942 * @remark @wayland Gamma handling is a privileged protocol, this function
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002943 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
Emmanuel Gil Peyrot9c513342017-11-17 12:17:43 +00002944 * returning `NULL`.
linkmauvebc8b0482016-10-16 15:52:39 +01002945 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002946 * @pointer_lifetime The returned structure and its arrays are allocated and
2947 * freed by GLFW. You should not free them yourself. They are valid until the
2948 * specified monitor is disconnected, this function is called again for that
2949 * monitor or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01002950 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002951 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002952 *
2953 * @sa @ref monitor_gamma
2954 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002955 * @since Added in version 3.0.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02002956 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002957 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002958 */
Camilla Berglund5d308db2013-05-19 15:46:44 +02002959GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002960
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002961/*! @brief Sets the current gamma ramp for the specified monitor.
2962 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02002963 * This function sets the current gamma ramp for the specified monitor. The
2964 * original gamma ramp for that monitor is saved by GLFW the first time this
2965 * function is called and is restored by @ref glfwTerminate.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002966 *
Camilla Löwyce161c22016-12-06 01:14:23 +01002967 * The software controlled gamma ramp is applied _in addition_ to the hardware
2968 * gamma correction, which today is usually an approximation of sRGB gamma.
2969 * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
2970 * the default (usually sRGB-like) behavior.
2971 *
2972 * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
2973 * GLFW_SRGB_CAPABLE hint.
2974 *
Camilla Berglund92a71e02013-02-12 13:50:41 +01002975 * @param[in] monitor The monitor whose gamma ramp to set.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002976 * @param[in] ramp The gamma ramp to use.
Camilla Berglund8954af62013-02-20 19:44:52 +01002977 *
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002978 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
2979 * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01002980 *
Camilla Löwy3531c322018-12-17 17:40:18 +01002981 * @remark The size of the specified gamma ramp should match the size of the
2982 * current ramp for that monitor.
Camilla Berglund76fff4d2015-03-10 19:02:28 +01002983 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002984 * @remark @win32 The gamma ramp size must be 256.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01002985 *
luz.paz7105ff22019-08-12 06:52:31 -04002986 * @remark @wayland Gamma handling is a privileged protocol, this function
Camilla Löwyb2b087c2022-09-20 16:17:22 +02002987 * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01002988 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002989 * @pointer_lifetime The specified gamma ramp is copied before this function
2990 * returns.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002991 *
Camilla Berglund951a9582016-01-31 21:32:14 +01002992 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002993 *
2994 * @sa @ref monitor_gamma
2995 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01002996 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02002997 *
Camilla Berglundf5f55e32013-06-17 12:56:36 +02002998 * @ingroup monitor
Camilla Berglundbce2cd62012-11-22 16:38:24 +01002999 */
Camilla Berglund92a71e02013-02-12 13:50:41 +01003000GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
Camilla Berglund2630d492010-10-13 04:04:43 +02003001
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003002/*! @brief Resets all window hints to their default values.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003003 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003004 * This function resets all window hints to their
Camilla Berglunde248fb62013-03-29 14:06:23 +01003005 * [default values](@ref window_hints_values).
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003006 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003007 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3008 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003009 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003010 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003011 * @sa @ref window_hints
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003012 * @sa @ref glfwWindowHint
Camilla Löwy61588012017-12-12 10:54:18 +01003013 * @sa @ref glfwWindowHintString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003014 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003015 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003016 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003017 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003018 */
Camilla Berglund5df4df62012-10-22 02:59:05 +02003019GLFWAPI void glfwDefaultWindowHints(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003020
3021/*! @brief Sets the specified window hint to the desired value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003022 *
Camilla Berglunded9e4032012-12-23 15:59:09 +01003023 * This function sets hints for the next call to @ref glfwCreateWindow. The
Camilla Löwy61588012017-12-12 10:54:18 +01003024 * hints, once set, retain their values until changed by a call to this
3025 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
3026 *
3027 * Only integer value hints can be set with this function. String value hints
3028 * are set with @ref glfwWindowHintString.
Camilla Berglunded9e4032012-12-23 15:59:09 +01003029 *
Camilla Berglundd6e0a432016-02-09 07:41:48 +01003030 * This function does not check whether the specified hint values are valid.
3031 * If you set hints to invalid values this will instead be reported by the next
3032 * call to @ref glfwCreateWindow.
3033 *
Camilla Löwy61588012017-12-12 10:54:18 +01003034 * Some hints are platform specific. These may be set on any platform but they
3035 * will only affect their specific platform. Other platforms will ignore them.
3036 * Setting these hints requires no platform specific headers or functions.
3037 *
Camilla Berglundd0649e62016-01-27 03:25:21 +01003038 * @param[in] hint The [window hint](@ref window_hints) to set.
3039 * @param[in] value The new value of the window hint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003040 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003041 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3042 * GLFW_INVALID_ENUM.
3043 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003044 * @thread_safety This function must only be called from the main thread.
Camilla Berglund401033c2013-03-12 19:17:07 +01003045 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003046 * @sa @ref window_hints
Camilla Löwy61588012017-12-12 10:54:18 +01003047 * @sa @ref glfwWindowHintString
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003048 * @sa @ref glfwDefaultWindowHints
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003049 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003050 * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003051 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003052 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003053 */
Camilla Berglundd0649e62016-01-27 03:25:21 +01003054GLFWAPI void glfwWindowHint(int hint, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003055
Camilla Löwy61588012017-12-12 10:54:18 +01003056/*! @brief Sets the specified window hint to the desired value.
3057 *
3058 * This function sets hints for the next call to @ref glfwCreateWindow. The
3059 * hints, once set, retain their values until changed by a call to this
3060 * function or @ref glfwDefaultWindowHints, or until the library is terminated.
3061 *
3062 * Only string type hints can be set with this function. Integer value hints
3063 * are set with @ref glfwWindowHint.
3064 *
3065 * This function does not check whether the specified hint values are valid.
3066 * If you set hints to invalid values this will instead be reported by the next
3067 * call to @ref glfwCreateWindow.
3068 *
3069 * Some hints are platform specific. These may be set on any platform but they
3070 * will only affect their specific platform. Other platforms will ignore them.
3071 * Setting these hints requires no platform specific headers or functions.
3072 *
3073 * @param[in] hint The [window hint](@ref window_hints) to set.
3074 * @param[in] value The new value of the window hint.
3075 *
3076 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3077 * GLFW_INVALID_ENUM.
3078 *
3079 * @pointer_lifetime The specified string is copied before this function
3080 * returns.
3081 *
3082 * @thread_safety This function must only be called from the main thread.
3083 *
3084 * @sa @ref window_hints
3085 * @sa @ref glfwWindowHint
3086 * @sa @ref glfwDefaultWindowHints
3087 *
3088 * @since Added in version 3.3.
3089 *
3090 * @ingroup window
3091 */
3092GLFWAPI void glfwWindowHintString(int hint, const char* value);
3093
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003094/*! @brief Creates a window and its associated context.
3095 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003096 * This function creates a window and its associated OpenGL or OpenGL ES
3097 * context. Most of the options controlling how the window and its context
3098 * should be created are specified with [window hints](@ref window_hints).
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003099 *
3100 * Successful creation does not change which context is current. Before you
Camilla Berglund4591ad22014-09-18 15:03:29 +02003101 * can use the newly created context, you need to
3102 * [make it current](@ref context_current). For information about the `share`
3103 * parameter, see @ref context_sharing.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003104 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003105 * The created window, framebuffer and context may differ from what you
3106 * requested, as not all parameters and hints are
Camilla Berglundfa0cbd92013-04-11 01:07:07 +02003107 * [hard constraints](@ref window_hints_hard). This includes the size of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003108 * window, especially for full screen windows. To query the actual attributes
Camilla Berglunde8bceaa2015-04-07 14:37:42 +02003109 * of the created window, framebuffer and context, see @ref
3110 * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003111 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003112 * To create a full screen window, you need to specify the monitor the window
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003113 * will cover. If no monitor is specified, the window will be windowed mode.
3114 * Unless you have a way for the user to choose a specific monitor, it is
3115 * recommended that you pick the primary monitor. For more information on how
3116 * to query connected monitors, see @ref monitor_monitors.
Camilla Berglund4b7ae492013-07-07 12:06:59 +02003117 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02003118 * For full screen windows, the specified size becomes the resolution of the
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003119 * window's _desired video mode_. As long as a full screen window is not
3120 * iconified, the supported video mode most closely matching the desired video
3121 * mode is set for the specified monitor. For more information about full
3122 * screen windows, including the creation of so called _windowed full screen_
3123 * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
Camilla Berglund95654cf2014-10-02 17:35:10 +02003124 *
Camilla Berglund999f3552016-08-17 16:48:22 +02003125 * Once you have created the window, you can switch it between windowed and
Camilla Berglunde83be1d2016-11-08 12:19:06 +01003126 * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
3127 * OpenGL or OpenGL ES context.
Camilla Berglund999f3552016-08-17 16:48:22 +02003128 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003129 * By default, newly created windows use the placement recommended by the
Camilla Löwy0f9a9572021-10-26 14:25:03 +02003130 * window system. To create the window at a specific position, set the @ref
3131 * GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints before creation. To
3132 * restore the default behavior, set either or both hints back to
3133 * `GLFW_ANY_POSITION`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003134 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003135 * As long as at least one full screen window is not iconified, the screensaver
3136 * is prohibited from starting.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003137 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003138 * Window systems put limits on window sizes. Very large or very small window
3139 * dimensions may be overridden by the window system on creation. Check the
Camilla Berglund95654cf2014-10-02 17:35:10 +02003140 * actual [size](@ref window_size) after creation.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003141 *
Camilla Berglund4188c262015-01-18 01:55:25 +01003142 * The [swap interval](@ref buffer_swap) is not set during window creation and
Camilla Berglund4591ad22014-09-18 15:03:29 +02003143 * the initial value may vary depending on driver settings and defaults.
3144 *
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003145 * @param[in] width The desired width, in screen coordinates, of the window.
3146 * This must be greater than zero.
3147 * @param[in] height The desired height, in screen coordinates, of the window.
3148 * This must be greater than zero.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003149 * @param[in] title The initial, UTF-8 encoded window title.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003150 * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
Camilla Berglund41bc0d12012-11-27 16:55:04 +01003151 * windowed mode.
Camilla Berglund71d2b572013-03-12 15:33:05 +01003152 * @param[in] share The window whose context to share resources with, or `NULL`
3153 * to not share resources.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003154 * @return The handle of the created window, or `NULL` if an
3155 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003156 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003157 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3158 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
Camilla Löwy73948e62024-01-04 20:07:27 +01003159 * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
3160 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01003161 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003162 * @remark @win32 Window creation will fail if the Microsoft GDI software
3163 * OpenGL implementation is the only one available.
Camilla Berglund07db5da2013-09-26 19:15:36 +02003164 *
Camilla Berglund20bce152016-05-30 16:04:37 +02003165 * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
3166 * will be set as the initial icon for the window. If no such icon is present,
Camilla Löwyd73ab0b2017-11-16 10:08:38 +01003167 * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
3168 * see @ref glfwSetWindowIcon.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003169 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003170 * @remark @win32 The context to share resources with must not be current on
3171 * any other thread.
Camilla Berglundb19fb4c2014-12-27 21:14:41 +01003172 *
Camilla Löwy82978bb2019-10-18 13:21:59 +02003173 * @remark @macos The OS only supports core profile contexts for OpenGL
3174 * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or
3175 * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
3176 * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all
3177 * on macOS.
Camilla Löwyfd127d52016-12-03 19:32:00 +01003178 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02003179 * @remark @macos The GLFW window has no icon, as it is not a document
Camilla Berglund71d2b572013-03-12 15:33:05 +01003180 * window, but the dock icon will be the same as the application bundle's icon.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003181 * For more information on bundles, see the
Camilla Löwy63397fb2024-02-14 01:36:35 +01003182 * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
3183 *
3184 * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003185 *
Camilla Löwy8b574032024-04-07 19:26:01 +02003186 * @remark @macos The window frame will not be rendered at full resolution on
3187 * Retina displays unless the
Camilla Löwya9cc7c72024-02-07 20:04:14 +01003188 * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint)
Camilla Löwy58ceab52016-12-07 00:41:54 +01003189 * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
3190 * application bundle's `Info.plist`. For more information, see
Camilla Löwy63397fb2024-02-14 01:36:35 +01003191 * [High Resolution Guidelines for OS X][hidpi-guide] in the Mac Developer
3192 * Library. The GLFW test and example programs use a custom `Info.plist`
3193 * template for this, which can be found as `CMake/Info.plist.in` in the source
3194 * tree.
3195 *
3196 * [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
Camilla Berglund821f3e62015-03-16 22:39:14 +01003197 *
Camilla Löwy46613152017-01-01 19:41:50 +01003198 * @remark @macos When activating frame autosaving with
Camilla Löwy9da22852017-12-12 16:45:38 +01003199 * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
luz.paz7105ff22019-08-12 06:52:31 -04003200 * window size and position may be overridden by previously saved values.
Camilla Löwy46613152017-01-01 19:41:50 +01003201 *
Camilla Löwybafece42024-02-16 16:04:49 +01003202 * @remark @wayland GLFW uses [libdecor][] where available to create its window
3203 * decorations. This in turn uses server-side XDG decorations where available
3204 * and provides high quality client-side decorations on compositors like GNOME.
3205 * If both XDG decorations and libdecor are unavailable, GLFW falls back to
3206 * a very simple set of window decorations that only support moving, resizing
3207 * and the window manager's right-click menu.
3208 *
3209 * [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor
3210 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003211 * @remark @x11 Some window managers will not respect the placement of
Camilla Berglunde8e05d42014-04-23 13:30:11 +02003212 * initially hidden windows.
Camilla Berglund3af1c412013-09-19 21:37:01 +02003213 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003214 * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
3215 * a window to reach its requested state. This means you may not be able to
3216 * query the final size, position or other attributes directly after window
3217 * creation.
Camilla Berglund20ed0a12015-08-12 21:31:54 +02003218 *
Camilla Löwy61588012017-12-12 10:54:18 +01003219 * @remark @x11 The class part of the `WM_CLASS` window property will by
3220 * default be set to the window title passed to this function. The instance
3221 * part will use the contents of the `RESOURCE_NAME` environment variable, if
Camilla Löwy422bf792019-04-01 18:36:30 +02003222 * present and not empty, or fall back to the window title. Set the
3223 * [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
3224 * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
3225 * override this.
Camilla Löwy213dd2d2017-07-25 01:55:08 +02003226 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003227 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003228 *
3229 * @sa @ref window_creation
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003230 * @sa @ref glfwDestroyWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003231 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003232 * @since Added in version 3.0. Replaces `glfwOpenWindow`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003233 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003234 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003235 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003236GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003237
3238/*! @brief Destroys the specified window and its context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003239 *
3240 * This function destroys the specified window and its context. On calling
3241 * this function, no further callbacks will be called for that window.
3242 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003243 * If the context of the specified window is current on the main thread, it is
3244 * detached before being destroyed.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003245 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003246 * @param[in] window The window to destroy.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003247 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003248 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3249 * GLFW_PLATFORM_ERROR.
3250 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003251 * @note The context of the specified window must not be current on any other
3252 * thread when this function is called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003253 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003254 * @reentrancy This function must not be called from a callback.
Camilla Berglund44372b82014-12-17 01:31:36 +01003255 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003256 * @thread_safety This function must only be called from the main thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003257 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003258 * @sa @ref window_creation
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003259 * @sa @ref glfwCreateWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003260 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003261 * @since Added in version 3.0. Replaces `glfwCloseWindow`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003262 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003263 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003264 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003265GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003266
Camilla Berglund64afb192013-03-06 23:29:37 +01003267/*! @brief Checks the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003268 *
3269 * This function returns the value of the close flag of the specified window.
3270 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01003271 * @param[in] window The window to query.
Camilla Berglund64afb192013-03-06 23:29:37 +01003272 * @return The value of the close flag.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003273 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003274 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3275 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003276 * @thread_safety This function may be called from any thread. Access is not
3277 * synchronized.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003278 *
3279 * @sa @ref window_close
3280 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003281 * @since Added in version 3.0.
Camilla Berglund6632cc72013-07-11 02:00:48 +02003282 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01003283 * @ingroup window
3284 */
3285GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
3286
Camilla Berglund64afb192013-03-06 23:29:37 +01003287/*! @brief Sets the close flag of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003288 *
3289 * This function sets the value of the close flag of the specified window.
3290 * This can be used to override the user's attempt to close the window, or
3291 * to signal that it should be closed.
3292 *
Camilla Berglund64afb192013-03-06 23:29:37 +01003293 * @param[in] window The window whose flag to change.
Camilla Berglund6fadf372013-03-01 13:45:12 +01003294 * @param[in] value The new value.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003295 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003296 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3297 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003298 * @thread_safety This function may be called from any thread. Access is not
3299 * synchronized.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003300 *
3301 * @sa @ref window_close
3302 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003303 * @since Added in version 3.0.
Camilla Berglund6632cc72013-07-11 02:00:48 +02003304 *
Camilla Berglund6fadf372013-03-01 13:45:12 +01003305 * @ingroup window
Camilla Berglund6fadf372013-03-01 13:45:12 +01003306 */
3307GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
3308
Camilla Löwyc8372cd2024-02-16 13:45:22 +01003309/*! @brief Returns the title of the specified window.
Doug Binks95d464b2024-02-07 19:26:52 +00003310 *
Camilla Löwyc8372cd2024-02-16 13:45:22 +01003311 * This function returns the window title, encoded as UTF-8, of the specified
3312 * window. This is the title set previously by @ref glfwCreateWindow
3313 * or @ref glfwSetWindowTitle.
Doug Binks95d464b2024-02-07 19:26:52 +00003314 *
3315 * @param[in] window The window to query.
Camilla Löwyc8372cd2024-02-16 13:45:22 +01003316 * @return The UTF-8 encoded window title, or `NULL` if an
3317 * [error](@ref error_handling) occurred.
Doug Binks95d464b2024-02-07 19:26:52 +00003318 *
Camilla Löwyc8372cd2024-02-16 13:45:22 +01003319 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
3320 *
3321 * @remark The returned title is currently a copy of the title last set by @ref
3322 * glfwCreateWindow or @ref glfwSetWindowTitle. It does not include any
3323 * additional text which may be appended by the platform or another program.
Doug Binks95d464b2024-02-07 19:26:52 +00003324 *
3325 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
3326 * should not free it yourself. It is valid until the next call to @ref
Camilla Löwyc8372cd2024-02-16 13:45:22 +01003327 * glfwGetWindowTitle or @ref glfwSetWindowTitle, or until the library is
3328 * terminated.
Doug Binks95d464b2024-02-07 19:26:52 +00003329 *
3330 * @thread_safety This function must only be called from the main thread.
3331 *
3332 * @sa @ref window_title
3333 * @sa @ref glfwSetWindowTitle
3334 *
Camilla Löwyc8372cd2024-02-16 13:45:22 +01003335 * @since Added in version 3.4.
3336 *
Doug Binks95d464b2024-02-07 19:26:52 +00003337 * @ingroup window
3338 */
3339GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window);
3340
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003341/*! @brief Sets the title of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003342 *
3343 * This function sets the window title, encoded as UTF-8, of the specified
3344 * window.
3345 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003346 * @param[in] window The window whose title to change.
3347 * @param[in] title The UTF-8 encoded window title.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003348 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003349 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3350 * GLFW_PLATFORM_ERROR.
3351 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02003352 * @remark @macos The window title will not be updated until the next time you
Camilla Berglund951a9582016-01-31 21:32:14 +01003353 * process events.
Camilla Berglund6412dcb2015-04-07 21:52:29 +02003354 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003355 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003356 *
3357 * @sa @ref window_title
Camilla Löwyc8372cd2024-02-16 13:45:22 +01003358 * @sa @ref glfwGetWindowTitle
Camilla Berglund4591ad22014-09-18 15:03:29 +02003359 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003360 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003361 * @glfw3 Added window handle parameter.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003362 *
3363 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003364 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003365GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003366
Camilla Berglundb823f712016-03-07 14:55:30 +01003367/*! @brief Sets the icon for the specified window.
3368 *
3369 * This function sets the icon of the specified window. If passed an array of
3370 * candidate images, those of or closest to the sizes desired by the system are
3371 * selected. If no images are specified, the window reverts to its default
3372 * icon.
3373 *
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02003374 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
3375 * bits per channel with the red channel first. They are arranged canonically
3376 * as packed sequential rows, starting from the top-left corner.
3377 *
Camilla Berglundb823f712016-03-07 14:55:30 +01003378 * The desired image sizes varies depending on platform and system settings.
3379 * The selected images will be rescaled as needed. Good sizes include 16x16,
3380 * 32x32 and 48x48.
3381 *
3382 * @param[in] window The window whose icon to set.
3383 * @param[in] count The number of images in the specified array, or zero to
3384 * revert to the default window icon.
3385 * @param[in] images The images to create the icon from. This is ignored if
3386 * count is zero.
3387 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003388 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy66a48822022-03-15 21:22:49 +01003389 * GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
3390 * GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundb823f712016-03-07 14:55:30 +01003391 *
3392 * @pointer_lifetime The specified image data is copied before this function
3393 * returns.
3394 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003395 * @remark @macos Regular windows do not have icons on macOS. This function
3396 * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
Camilla Berglund20bce152016-05-30 16:04:37 +02003397 * the application bundle's icon. For more information on bundles, see the
Camilla Löwy63397fb2024-02-14 01:36:35 +01003398 * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
3399 *
3400 * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
Camilla Berglundb823f712016-03-07 14:55:30 +01003401 *
Emmanuel Gil Peyrota1620042017-12-03 04:19:15 +01003402 * @remark @wayland There is no existing protocol to change an icon, the
3403 * window will thus inherit the one defined in the application's desktop file.
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003404 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01003405 *
Camilla Berglundb823f712016-03-07 14:55:30 +01003406 * @thread_safety This function must only be called from the main thread.
3407 *
3408 * @sa @ref window_icon
3409 *
3410 * @since Added in version 3.2.
3411 *
3412 * @ingroup window
3413 */
3414GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
3415
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003416/*! @brief Retrieves the position of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003417 *
3418 * This function retrieves the position, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003419 * upper-left corner of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003420 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003421 * Any or all of the position arguments may be `NULL`. If an error occurs, all
3422 * non-`NULL` position arguments will be set to zero.
3423 *
Camilla Berglund7c193232013-01-24 19:30:31 +01003424 * @param[in] window The window to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003425 * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003426 * the content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003427 * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003428 * the content area, or `NULL`.
Camilla Berglund7c193232013-01-24 19:30:31 +01003429 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003430 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3431 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01003432 *
linkmauvebc8b0482016-10-16 15:52:39 +01003433 * @remark @wayland There is no way for an application to retrieve the global
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003434 * position of its windows. This function will emit @ref
3435 * GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01003436 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003437 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003438 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003439 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003440 * @sa @ref glfwSetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003441 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003442 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003443 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003444 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01003445 */
3446GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
3447
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003448/*! @brief Sets the position of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003449 *
3450 * This function sets the position, in screen coordinates, of the upper-left
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003451 * corner of the content area of the specified windowed mode window. If the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003452 * window is a full screen window, this function does nothing.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003453 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01003454 * __Do not use this function__ to move an already visible window unless you
3455 * have very good reasons for doing so, as it will confuse and annoy the user.
3456 *
3457 * The window manager may put limits on what positions are allowed. GLFW
3458 * cannot and should not override these limits.
3459 *
Camilla Berglund7c193232013-01-24 19:30:31 +01003460 * @param[in] window The window to query.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003461 * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
3462 * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
Camilla Berglund7c193232013-01-24 19:30:31 +01003463 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003464 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3465 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01003466 *
linkmauvebc8b0482016-10-16 15:52:39 +01003467 * @remark @wayland There is no way for an application to set the global
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003468 * position of its windows. This function will emit @ref
3469 * GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01003470 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003471 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003472 *
3473 * @sa @ref window_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003474 * @sa @ref glfwGetWindowPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003475 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003476 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003477 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003478 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003479 * @ingroup window
Camilla Berglund7c193232013-01-24 19:30:31 +01003480 */
Camilla Berglund52f718d2013-02-12 12:01:12 +01003481GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
Camilla Berglund7c193232013-01-24 19:30:31 +01003482
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003483/*! @brief Retrieves the size of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003484 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003485 * This function retrieves the size, in screen coordinates, of the content area
Camilla Berglund521fa7d2013-09-26 20:02:19 +02003486 * of the specified window. If you wish to retrieve the size of the
Camilla Berglundce8f97c2015-01-11 23:33:14 +01003487 * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003488 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003489 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3490 * non-`NULL` size arguments will be set to zero.
3491 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003492 * @param[in] window The window whose size to retrieve.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003493 * @param[out] width Where to store the width, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003494 * content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003495 * @param[out] height Where to store the height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003496 * content area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003497 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003498 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3499 * GLFW_PLATFORM_ERROR.
3500 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003501 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003502 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003503 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003504 * @sa @ref glfwSetWindowSize
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003505 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003506 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003507 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003508 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003509 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003510 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003511GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003512
Camilla Berglundd84772d2014-02-13 02:57:59 +01003513/*! @brief Sets the size limits of the specified window.
3514 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003515 * This function sets the size limits of the content area of the specified
Emmanuel Gil Peyrotf0f5d9f2016-04-09 00:42:58 +01003516 * window. If the window is full screen, the size limits only take effect
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003517 * once it is made windowed. If the window is not resizable, this function
3518 * does nothing.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003519 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003520 * The size limits are applied immediately to a windowed mode window and may
3521 * cause it to be resized.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003522 *
Camilla Berglund12a69562016-05-04 16:28:08 +02003523 * The maximum dimensions must be greater than or equal to the minimum
3524 * dimensions and all must be greater than or equal to zero.
3525 *
Camilla Berglundd84772d2014-02-13 02:57:59 +01003526 * @param[in] window The window to set limits for.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003527 * @param[in] minwidth The minimum width, in screen coordinates, of the content
Camilla Berglundd84772d2014-02-13 02:57:59 +01003528 * area, or `GLFW_DONT_CARE`.
3529 * @param[in] minheight The minimum height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003530 * content area, or `GLFW_DONT_CARE`.
3531 * @param[in] maxwidth The maximum width, in screen coordinates, of the content
Camilla Berglundd84772d2014-02-13 02:57:59 +01003532 * area, or `GLFW_DONT_CARE`.
3533 * @param[in] maxheight The maximum height, in screen coordinates, of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003534 * content area, or `GLFW_DONT_CARE`.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003535 *
Camilla Berglund12a69562016-05-04 16:28:08 +02003536 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3537 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01003538 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003539 * @remark If you set size limits and an aspect ratio that conflict, the
Camilla Berglundd84772d2014-02-13 02:57:59 +01003540 * results are undefined.
3541 *
linkmauvebc8b0482016-10-16 15:52:39 +01003542 * @remark @wayland The size limits will not be applied until the window is
3543 * actually resized, either by the user or by the compositor.
3544 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003545 * @thread_safety This function must only be called from the main thread.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003546 *
3547 * @sa @ref window_sizelimits
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003548 * @sa @ref glfwSetWindowAspectRatio
Camilla Berglundd84772d2014-02-13 02:57:59 +01003549 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003550 * @since Added in version 3.2.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003551 *
3552 * @ingroup window
3553 */
3554GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
3555
3556/*! @brief Sets the aspect ratio of the specified window.
3557 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003558 * This function sets the required aspect ratio of the content area of the
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003559 * specified window. If the window is full screen, the aspect ratio only takes
3560 * effect once it is made windowed. If the window is not resizable, this
Camilla Berglundd84772d2014-02-13 02:57:59 +01003561 * function does nothing.
3562 *
Camilla Berglundaf5b82a2015-10-19 16:01:42 +02003563 * The aspect ratio is specified as a numerator and a denominator and both
3564 * values must be greater than zero. For example, the common 16:9 aspect ratio
3565 * is specified as 16 and 9, respectively.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003566 *
Camilla Berglundaf5b82a2015-10-19 16:01:42 +02003567 * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
3568 * ratio limit is disabled.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003569 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003570 * The aspect ratio is applied immediately to a windowed mode window and may
3571 * cause it to be resized.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003572 *
3573 * @param[in] window The window to set limits for.
3574 * @param[in] numer The numerator of the desired aspect ratio, or
3575 * `GLFW_DONT_CARE`.
3576 * @param[in] denom The denominator of the desired aspect ratio, or
3577 * `GLFW_DONT_CARE`.
3578 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003579 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3580 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
3581 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003582 * @remark If you set size limits and an aspect ratio that conflict, the
Camilla Berglundd84772d2014-02-13 02:57:59 +01003583 * results are undefined.
3584 *
linkmauvebc8b0482016-10-16 15:52:39 +01003585 * @remark @wayland The aspect ratio will not be applied until the window is
3586 * actually resized, either by the user or by the compositor.
3587 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003588 * @thread_safety This function must only be called from the main thread.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003589 *
3590 * @sa @ref window_sizelimits
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003591 * @sa @ref glfwSetWindowSizeLimits
Camilla Berglundd84772d2014-02-13 02:57:59 +01003592 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003593 * @since Added in version 3.2.
Camilla Berglundd84772d2014-02-13 02:57:59 +01003594 *
3595 * @ingroup window
3596 */
3597GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
3598
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003599/*! @brief Sets the size of the content area of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003600 *
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003601 * This function sets the size, in screen coordinates, of the content area of
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003602 * the specified window.
3603 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003604 * For full screen windows, this function updates the resolution of its desired
3605 * video mode and switches to the video mode closest to it, without affecting
3606 * the window's context. As the context is unaffected, the bit depths of the
3607 * framebuffer remain unchanged.
3608 *
3609 * If you wish to update the refresh rate of the desired video mode in addition
3610 * to its resolution, see @ref glfwSetWindowMonitor.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003611 *
Camilla Berglundce8f97c2015-01-11 23:33:14 +01003612 * The window manager may put limits on what sizes are allowed. GLFW cannot
3613 * and should not override these limits.
3614 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003615 * @param[in] window The window to resize.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003616 * @param[in] width The desired width, in screen coordinates, of the window
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003617 * content area.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01003618 * @param[in] height The desired height, in screen coordinates, of the window
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01003619 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003620 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003621 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3622 * GLFW_PLATFORM_ERROR.
3623 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003624 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003625 *
3626 * @sa @ref window_size
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003627 * @sa @ref glfwGetWindowSize
3628 * @sa @ref glfwSetWindowMonitor
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003629 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003630 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01003631 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003632 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003633 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003634 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003635GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003636
Camilla Berglund34981632013-06-03 12:51:57 +02003637/*! @brief Retrieves the size of the framebuffer of the specified window.
3638 *
3639 * This function retrieves the size, in pixels, of the framebuffer of the
Camilla Berglund521fa7d2013-09-26 20:02:19 +02003640 * specified window. If you wish to retrieve the size of the window in screen
3641 * coordinates, see @ref glfwGetWindowSize.
Camilla Berglund34981632013-06-03 12:51:57 +02003642 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003643 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3644 * non-`NULL` size arguments will be set to zero.
3645 *
Camilla Berglund34981632013-06-03 12:51:57 +02003646 * @param[in] window The window whose framebuffer to query.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02003647 * @param[out] width Where to store the width, in pixels, of the framebuffer,
3648 * or `NULL`.
3649 * @param[out] height Where to store the height, in pixels, of the framebuffer,
3650 * or `NULL`.
Camilla Berglund34981632013-06-03 12:51:57 +02003651 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003652 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3653 * GLFW_PLATFORM_ERROR.
3654 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003655 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01003656 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003657 * @sa @ref window_fbsize
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003658 * @sa @ref glfwSetFramebufferSizeCallback
Camilla Berglund34981632013-06-03 12:51:57 +02003659 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003660 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003661 *
Camilla Berglund34981632013-06-03 12:51:57 +02003662 * @ingroup window
3663 */
3664GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
3665
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003666/*! @brief Retrieves the size of the frame of the window.
3667 *
3668 * This function retrieves the size, in screen coordinates, of each edge of the
3669 * frame of the specified window. This size includes the title bar, if the
3670 * window has one. The size of the frame may vary depending on the
3671 * [window-related hints](@ref window_hints_wnd) used to create it.
3672 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003673 * Because this function retrieves the size of each window frame edge and not
3674 * the offset along a particular coordinate axis, the retrieved values will
3675 * always be zero or positive.
3676 *
3677 * Any or all of the size arguments may be `NULL`. If an error occurs, all
3678 * non-`NULL` size arguments will be set to zero.
3679 *
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003680 * @param[in] window The window whose frame size to query.
3681 * @param[out] left Where to store the size, in screen coordinates, of the left
Camilla Berglund4591ad22014-09-18 15:03:29 +02003682 * edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02003683 * @param[out] top Where to store the size, in screen coordinates, of the top
Camilla Berglund4591ad22014-09-18 15:03:29 +02003684 * edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02003685 * @param[out] right Where to store the size, in screen coordinates, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003686 * right edge of the window frame, or `NULL`.
Camilla Berglundeaff0f72014-04-07 16:27:32 +02003687 * @param[out] bottom Where to store the size, in screen coordinates, of the
Camilla Berglund4591ad22014-09-18 15:03:29 +02003688 * bottom edge of the window frame, or `NULL`.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003689 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003690 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3691 * GLFW_PLATFORM_ERROR.
3692 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003693 * @thread_safety This function must only be called from the main thread.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003694 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003695 * @sa @ref window_size
3696 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003697 * @since Added in version 3.1.
Camilla Berglundeb3f75e2014-03-25 21:30:13 +01003698 *
3699 * @ingroup window
3700 */
3701GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
3702
Camilla Löwy16bf8722017-08-29 19:19:00 +02003703/*! @brief Retrieves the content scale for the specified window.
3704 *
3705 * This function retrieves the content scale for the specified window. The
3706 * content scale is the ratio between the current DPI and the platform's
Camilla Löwy422bf792019-04-01 18:36:30 +02003707 * default DPI. This is especially important for text and any UI elements. If
3708 * the pixel dimensions of your UI scaled by this look appropriate on your
3709 * machine then it should appear at a reasonable size on other machines
3710 * regardless of their DPI and scaling settings. This relies on the system DPI
3711 * and scaling settings being somewhat correct.
Camilla Löwy16bf8722017-08-29 19:19:00 +02003712 *
Camilla Löwy56a4cb02021-07-13 21:50:09 +02003713 * On platforms where each monitors can have its own content scale, the window
Camilla Löwy16bf8722017-08-29 19:19:00 +02003714 * content scale will depend on which monitor the system considers the window
3715 * to be on.
3716 *
3717 * @param[in] window The window to query.
3718 * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
3719 * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
3720 *
3721 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3722 * GLFW_PLATFORM_ERROR.
3723 *
3724 * @thread_safety This function must only be called from the main thread.
3725 *
3726 * @sa @ref window_scale
Camilla Löwy370eac32017-12-11 21:26:40 +01003727 * @sa @ref glfwSetWindowContentScaleCallback
Camilla Löwy16bf8722017-08-29 19:19:00 +02003728 * @sa @ref glfwGetMonitorContentScale
3729 *
3730 * @since Added in version 3.3.
3731 *
3732 * @ingroup window
3733 */
3734GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
3735
Camilla Löwy11e47f02017-09-25 23:14:45 +02003736/*! @brief Returns the opacity of the whole window.
3737 *
3738 * This function returns the opacity of the window, including any decorations.
3739 *
3740 * The opacity (or alpha) value is a positive finite number between zero and
3741 * one, where zero is fully transparent and one is fully opaque. If the system
3742 * does not support whole window transparency, this function always returns one.
3743 *
3744 * The initial opacity value for newly created windows is one.
3745 *
3746 * @param[in] window The window to query.
3747 * @return The opacity value of the specified window.
3748 *
3749 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3750 * GLFW_PLATFORM_ERROR.
3751 *
3752 * @thread_safety This function must only be called from the main thread.
3753 *
3754 * @sa @ref window_transparency
3755 * @sa @ref glfwSetWindowOpacity
3756 *
3757 * @since Added in version 3.3.
3758 *
3759 * @ingroup window
3760 */
3761GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
3762
3763/*! @brief Sets the opacity of the whole window.
3764 *
3765 * This function sets the opacity of the window, including any decorations.
3766 *
3767 * The opacity (or alpha) value is a positive finite number between zero and
3768 * one, where zero is fully transparent and one is fully opaque.
3769 *
3770 * The initial opacity value for newly created windows is one.
3771 *
3772 * A window created with framebuffer transparency may not use whole window
3773 * transparency. The results of doing this are undefined.
3774 *
3775 * @param[in] window The window to set the opacity for.
3776 * @param[in] opacity The desired opacity of the specified window.
3777 *
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02003778 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
3779 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
3780 *
3781 * @remark @wayland There is no way to set an opacity factor for a window.
3782 * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
Camilla Löwy11e47f02017-09-25 23:14:45 +02003783 *
3784 * @thread_safety This function must only be called from the main thread.
3785 *
3786 * @sa @ref window_transparency
3787 * @sa @ref glfwGetWindowOpacity
3788 *
3789 * @since Added in version 3.3.
3790 *
3791 * @ingroup window
3792 */
3793GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
3794
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003795/*! @brief Iconifies the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003796 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003797 * This function iconifies (minimizes) the specified window if it was
3798 * previously restored. If the window is already iconified, this function does
3799 * nothing.
3800 *
Camilla Löwy2796e612022-06-24 19:29:29 +02003801 * If the specified window is a full screen window, GLFW restores the original
3802 * video mode of the monitor. The window's desired video mode is set again
3803 * when the window is restored.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003804 *
3805 * @param[in] window The window to iconify.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003806 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003807 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3808 * GLFW_PLATFORM_ERROR.
3809 *
Emmanuel Gil Peyrot599fb3d2019-03-01 18:46:06 +01003810 * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
3811 * be able to restore it. This is a design decision of the xdg-shell
Emmanuel Gil Peyrota1620042017-12-03 04:19:15 +01003812 * protocol.
linkmauvebc8b0482016-10-16 15:52:39 +01003813 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003814 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003815 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003816 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003817 * @sa @ref glfwRestoreWindow
3818 * @sa @ref glfwMaximizeWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003819 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003820 * @since Added in version 2.1.
Camilla Berglund951a9582016-01-31 21:32:14 +01003821 * @glfw3 Added window handle parameter.
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 glfwIconifyWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003826
3827/*! @brief Restores the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003828 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003829 * This function restores the specified window if it was previously iconified
Camilla Berglunda10caa42015-10-13 12:50:59 +02003830 * (minimized) or maximized. If the window is already restored, this function
3831 * does nothing.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003832 *
Camilla Löwy2796e612022-06-24 19:29:29 +02003833 * If the specified window is an iconified full screen window, its desired
3834 * video mode is set again for its monitor when the window is restored.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003835 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003836 * @param[in] window The window to restore.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003837 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003838 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3839 * GLFW_PLATFORM_ERROR.
3840 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003841 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003842 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003843 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003844 * @sa @ref glfwIconifyWindow
3845 * @sa @ref glfwMaximizeWindow
Camilla Berglunde248fb62013-03-29 14:06:23 +01003846 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003847 * @since Added in version 2.1.
Camilla Berglund951a9582016-01-31 21:32:14 +01003848 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003849 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01003850 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003851 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003852GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003853
Camilla Berglunda10caa42015-10-13 12:50:59 +02003854/*! @brief Maximizes the specified window.
3855 *
3856 * This function maximizes the specified window if it was previously not
3857 * maximized. If the window is already maximized, this function does nothing.
3858 *
3859 * If the specified window is a full screen window, this function does nothing.
3860 *
3861 * @param[in] window The window to maximize.
3862 *
Camilla Berglundf5b71f52016-05-27 14:20:39 +02003863 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3864 * GLFW_PLATFORM_ERROR.
3865 *
Camilla Berglunda10caa42015-10-13 12:50:59 +02003866 * @par Thread Safety
3867 * This function may only be called from the main thread.
3868 *
3869 * @sa @ref window_iconify
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003870 * @sa @ref glfwIconifyWindow
3871 * @sa @ref glfwRestoreWindow
Camilla Berglunda10caa42015-10-13 12:50:59 +02003872 *
3873 * @since Added in GLFW 3.2.
3874 *
3875 * @ingroup window
3876 */
3877GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
3878
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003879/*! @brief Makes the specified window visible.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003880 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003881 * This function makes the specified window visible if it was previously
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003882 * hidden. If the window is already visible or is in full screen mode, this
Camilla Berglund1e9383d2012-11-23 11:41:53 +01003883 * function does nothing.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003884 *
Doug Binks0be4f3f2018-05-29 14:51:36 +01003885 * By default, windowed mode windows are focused when shown
3886 * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
3887 * to change this behavior for all newly created windows, or change the
3888 * behavior for an existing window with @ref glfwSetWindowAttrib.
3889 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003890 * @param[in] window The window to make visible.
3891 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003892 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3893 * GLFW_PLATFORM_ERROR.
3894 *
Camilla Löwy8edbc492021-12-27 01:31:38 +01003895 * @remark @wayland Because Wayland wants every frame of the desktop to be
3896 * complete, this function does not immediately make the window visible.
3897 * Instead it will become visible the next time the window framebuffer is
3898 * updated after this call.
3899 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003900 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003901 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003902 * @sa @ref window_hide
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003903 * @sa @ref glfwHideWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003904 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003905 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003906 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003907 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003908 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003909GLFWAPI void glfwShowWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003910
3911/*! @brief Hides the specified window.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003912 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003913 * This function hides the specified window if it was previously visible. If
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003914 * the window is already hidden or is in full screen mode, this function does
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003915 * nothing.
3916 *
3917 * @param[in] window The window to hide.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003918 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01003919 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3920 * GLFW_PLATFORM_ERROR.
3921 *
Camilla Berglund951a9582016-01-31 21:32:14 +01003922 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01003923 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02003924 * @sa @ref window_hide
Camilla Berglund7e9e3212016-09-14 20:17:26 +02003925 * @sa @ref glfwShowWindow
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003926 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01003927 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02003928 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01003929 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003930 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01003931GLFWAPI void glfwHideWindow(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01003932
Camilla Berglundbaf57442016-02-21 15:42:49 +01003933/*! @brief Brings the specified window to front and sets input focus.
3934 *
3935 * This function brings the specified window to front and sets input focus.
3936 * The window should already be visible and not iconified.
3937 *
3938 * By default, both windowed and full screen mode windows are focused when
Camilla Löwyce161c22016-12-06 01:14:23 +01003939 * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
3940 * disable this behavior.
Camilla Berglundbaf57442016-02-21 15:42:49 +01003941 *
Doug Binks0be4f3f2018-05-29 14:51:36 +01003942 * Also by default, windowed mode windows are focused when shown
3943 * with @ref glfwShowWindow. Set the
3944 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
3945 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003946 * __Do not use this function__ to steal focus from other applications unless
3947 * you are certain that is what the user wants. Focus stealing can be
3948 * extremely disruptive.
3949 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003950 * For a less disruptive way of getting the user's attention, see
3951 * [attention requests](@ref window_attention).
3952 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003953 * @param[in] window The window to give input focus.
3954 *
Camilla Löwya3601982024-02-09 03:55:14 +01003955 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3956 * GLFW_PLATFORM_ERROR.
Camilla Berglundbaf57442016-02-21 15:42:49 +01003957 *
Camilla Löwya3601982024-02-09 03:55:14 +01003958 * @remark @wayland The compositor will likely ignore focus requests unless
3959 * another window created by the same application already has input focus.
linkmauvebc8b0482016-10-16 15:52:39 +01003960 *
Camilla Berglundbaf57442016-02-21 15:42:49 +01003961 * @thread_safety This function must only be called from the main thread.
3962 *
3963 * @sa @ref window_focus
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003964 * @sa @ref window_attention
Camilla Berglundbaf57442016-02-21 15:42:49 +01003965 *
3966 * @since Added in version 3.2.
3967 *
3968 * @ingroup window
3969 */
3970GLFWAPI void glfwFocusWindow(GLFWwindow* window);
3971
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003972/*! @brief Requests user attention to the specified window.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003973 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003974 * This function requests user attention to the specified window. On
3975 * platforms where this is not supported, attention is requested to the
3976 * application as a whole.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003977 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003978 * Once the user has given attention, usually by focusing the window or
3979 * application, the system will end the request automatically.
3980 *
3981 * @param[in] window The window to request attention to.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003982 *
3983 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
3984 * GLFW_PLATFORM_ERROR.
3985 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003986 * @remark @macos Attention is requested to the application as a whole, not the
3987 * specific window.
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003988 *
3989 * @thread_safety This function must only be called from the main thread.
3990 *
Camilla Löwybaa9cd82017-05-11 14:36:56 +02003991 * @sa @ref window_attention
3992 *
Felipe Ferreira da Silva412eb6a2017-03-21 10:02:57 -03003993 * @since Added in version 3.3.
3994 *
3995 * @ingroup window
3996 */
3997GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
3998
Camilla Berglund8282a8f2013-04-10 23:01:12 +02003999/*! @brief Returns the monitor that the window uses for full screen mode.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004000 *
4001 * This function returns the handle of the monitor that the specified window is
Camilla Berglund8282a8f2013-04-10 23:01:12 +02004002 * in full screen on.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004003 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01004004 * @param[in] window The window to query.
Camilla Berglund999f3552016-08-17 16:48:22 +02004005 * @return The monitor, or `NULL` if the window is in windowed mode or an
4006 * [error](@ref error_handling) occurred.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004007 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004008 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4009 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004010 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004011 *
4012 * @sa @ref window_monitor
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004013 * @sa @ref glfwSetWindowMonitor
Camilla Berglund4591ad22014-09-18 15:03:29 +02004014 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004015 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004016 *
Camilla Berglund5f68e122012-11-27 17:07:28 +01004017 * @ingroup window
Camilla Berglund41bc0d12012-11-27 16:55:04 +01004018 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004019GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
Camilla Berglund41bc0d12012-11-27 16:55:04 +01004020
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004021/*! @brief Sets the mode, monitor, video mode and placement of a window.
4022 *
4023 * This function sets the monitor that the window uses for full screen mode or,
4024 * if the monitor is `NULL`, makes it windowed mode.
4025 *
4026 * When setting a monitor, this function updates the width, height and refresh
4027 * rate of the desired video mode and switches to the video mode closest to it.
4028 * The window position is ignored when setting a monitor.
4029 *
4030 * When the monitor is `NULL`, the position, width and height are used to
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004031 * place the window content area. The refresh rate is ignored when no monitor
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004032 * is specified.
4033 *
4034 * If you only wish to update the resolution of a full screen window or the
4035 * size of a windowed mode window, see @ref glfwSetWindowSize.
4036 *
4037 * When a window transitions from full screen to windowed mode, this function
4038 * restores any previous window settings such as whether it is decorated,
linkmauvebc8b0482016-10-16 15:52:39 +01004039 * floating, resizable, has size or aspect ratio limits, etc.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004040 *
4041 * @param[in] window The window whose monitor, size or video mode to set.
4042 * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
4043 * @param[in] xpos The desired x-coordinate of the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004044 * content area.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004045 * @param[in] ypos The desired y-coordinate of the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004046 * content area.
4047 * @param[in] width The desired with, in screen coordinates, of the content
4048 * area or video mode.
4049 * @param[in] height The desired height, in screen coordinates, of the content
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004050 * area or video mode.
Camilla Berglund325729d2016-05-22 14:25:04 +02004051 * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
4052 * or `GLFW_DONT_CARE`.
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004053 *
4054 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4055 * GLFW_PLATFORM_ERROR.
4056 *
Camilla Berglundec171612016-10-28 06:20:20 +02004057 * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
4058 * affected by any resizing or mode switching, although you may need to update
4059 * your viewport if the framebuffer size has changed.
4060 *
linkmauvebc8b0482016-10-16 15:52:39 +01004061 * @remark @wayland The desired window position is ignored, as there is no way
4062 * for an application to set this property.
4063 *
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004064 * @thread_safety This function must only be called from the main thread.
4065 *
4066 * @sa @ref window_monitor
4067 * @sa @ref window_full_screen
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004068 * @sa @ref glfwGetWindowMonitor
4069 * @sa @ref glfwSetWindowSize
Camilla Berglund6570d0c2016-02-23 12:26:42 +01004070 *
4071 * @since Added in version 3.2.
4072 *
4073 * @ingroup window
4074 */
4075GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
4076
Camilla Berglundad1f6f02013-05-27 15:30:32 +02004077/*! @brief Returns an attribute of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004078 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004079 * This function returns the value of an attribute of the specified window or
4080 * its OpenGL or OpenGL ES context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004081 *
Camilla Berglund1e9383d2012-11-23 11:41:53 +01004082 * @param[in] window The window to query.
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02004083 * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
4084 * return.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004085 * @return The value of the attribute, or zero if an
4086 * [error](@ref error_handling) occurred.
Camilla Berglund1e9383d2012-11-23 11:41:53 +01004087 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004088 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4089 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
4090 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004091 * @remark Framebuffer related hints are not window attributes. See @ref
Camilla Berglund59abeeb2015-04-07 14:34:12 +02004092 * window_attribs_fb for more information.
4093 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004094 * @remark Zero is a valid value for many window and context related
Camilla Berglund59abeeb2015-04-07 14:34:12 +02004095 * attributes so you cannot use a return value of zero as an indication of
4096 * errors. However, this function should not fail as long as it is passed
4097 * valid arguments and the library has been [initialized](@ref intro_init).
4098 *
Camilla Löwy2796e612022-06-24 19:29:29 +02004099 * @remark @wayland The Wayland protocol provides no way to check whether a
4100 * window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`.
4101 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004102 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004103 *
4104 * @sa @ref window_attribs
Camilla Löwy9e560992016-09-30 01:52:22 +02004105 * @sa @ref glfwSetWindowAttrib
Camilla Berglund4591ad22014-09-18 15:03:29 +02004106 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004107 * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
Camilla Berglund4188c262015-01-18 01:55:25 +01004108 * `glfwGetGLVersion`.
Camilla Berglund0e205772014-03-24 11:58:35 +01004109 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004110 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004111 */
Camilla Berglundad1f6f02013-05-27 15:30:32 +02004112GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004113
Camilla Löwy9e560992016-09-30 01:52:22 +02004114/*! @brief Sets an attribute of the specified window.
4115 *
4116 * This function sets the value of an attribute of the specified window.
4117 *
4118 * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
4119 * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
Doug Binks0be4f3f2018-05-29 14:51:36 +01004120 * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
4121 * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
4122 * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
Rokas Kupstysd285a9f2019-09-30 15:44:43 +03004123 * [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
Camilla Löwy9e560992016-09-30 01:52:22 +02004124 *
4125 * Some of these attributes are ignored for full screen windows. The new
4126 * value will take effect if the window is later made windowed.
4127 *
4128 * Some of these attributes are ignored for windowed mode windows. The new
4129 * value will take effect if the window is later made full screen.
4130 *
4131 * @param[in] window The window to set the attribute for.
4132 * @param[in] attrib A supported window attribute.
4133 * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
4134 *
4135 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy97b9e492022-09-20 17:03:30 +02004136 * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
Camilla Löwya12311e2024-01-31 00:49:53 +01004137 * GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Löwy9e560992016-09-30 01:52:22 +02004138 *
4139 * @remark Calling @ref glfwGetWindowAttrib will always return the latest
4140 * value, even if that value is ignored by the current mode of the window.
4141 *
Camilla Löwya12311e2024-01-31 00:49:53 +01004142 * @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is
4143 * not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE.
4144 *
Camilla Löwy9e560992016-09-30 01:52:22 +02004145 * @thread_safety This function must only be called from the main thread.
4146 *
4147 * @sa @ref window_attribs
4148 * @sa @ref glfwGetWindowAttrib
4149 *
4150 * @since Added in version 3.3.
4151 *
4152 * @ingroup window
4153 */
4154GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
4155
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004156/*! @brief Sets the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004157 *
4158 * This function sets the user-defined pointer of the specified window. The
4159 * current value is retained until the window is destroyed. The initial value
4160 * is `NULL`.
4161 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004162 * @param[in] window The window whose pointer to set.
4163 * @param[in] pointer The new value.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004164 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004165 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4166 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004167 * @thread_safety This function may be called from any thread. Access is not
4168 * synchronized.
Camilla Berglund0e205772014-03-24 11:58:35 +01004169 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004170 * @sa @ref window_userptr
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004171 * @sa @ref glfwGetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004172 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004173 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004174 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004175 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004176 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004177GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004178
4179/*! @brief Returns the user pointer of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004180 *
4181 * This function returns the current value of the user-defined pointer of the
4182 * specified window. The initial value is `NULL`.
4183 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004184 * @param[in] window The window whose pointer to return.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004185 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004186 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4187 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004188 * @thread_safety This function may be called from any thread. Access is not
4189 * synchronized.
Camilla Berglund0e205772014-03-24 11:58:35 +01004190 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004191 * @sa @ref window_userptr
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004192 * @sa @ref glfwSetWindowUserPointer
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004193 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004194 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004195 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004196 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004197 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004198GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004199
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004200/*! @brief Sets the position callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004201 *
4202 * This function sets the position callback of the specified window, which is
Camilla Löwy2867ca12017-10-29 16:27:15 +01004203 * called when the window is moved. The callback is provided with the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004204 * position, in screen coordinates, of the upper-left corner of the content
4205 * area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004206 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004207 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004208 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004209 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004210 * @return The previously set callback, or `NULL` if no callback was set or the
4211 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004212 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004213 * @callback_signature
4214 * @code
4215 * void function_name(GLFWwindow* window, int xpos, int ypos)
4216 * @endcode
4217 * For more information about the callback parameters, see the
4218 * [function pointer type](@ref GLFWwindowposfun).
4219 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004220 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4221 *
linkmauvebc8b0482016-10-16 15:52:39 +01004222 * @remark @wayland This callback will never be called, as there is no way for
4223 * an application to know its global position.
4224 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004225 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004226 *
4227 * @sa @ref window_pos
4228 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004229 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004230 *
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004231 * @ingroup window
4232 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004233GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
Camilla Berglund1a3d47d2012-11-30 13:56:42 +01004234
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004235/*! @brief Sets the size callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004236 *
4237 * This function sets the size callback of the specified window, which is
4238 * called when the window is resized. The callback is provided with the size,
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004239 * in screen coordinates, of the content area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004240 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004241 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004242 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004243 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004244 * @return The previously set callback, or `NULL` if no callback was set or the
4245 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004246 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004247 * @callback_signature
4248 * @code
4249 * void function_name(GLFWwindow* window, int width, int height)
4250 * @endcode
4251 * For more information about the callback parameters, see the
4252 * [function pointer type](@ref GLFWwindowsizefun).
4253 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004254 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4255 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004256 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004257 *
4258 * @sa @ref window_size
4259 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004260 * @since Added in version 1.0.
4261 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01004262 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004263 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004264 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004265GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004266
4267/*! @brief Sets the close callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004268 *
4269 * This function sets the close callback of the specified window, which is
4270 * called when the user attempts to close the window, for example by clicking
4271 * the close widget in the title bar.
4272 *
4273 * The close flag is set before this callback is called, but you can modify it
4274 * at any time with @ref glfwSetWindowShouldClose.
4275 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004276 * The close callback is not triggered by @ref glfwDestroyWindow.
4277 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004278 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004279 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004280 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004281 * @return The previously set callback, or `NULL` if no callback was set or the
4282 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004283 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004284 * @callback_signature
4285 * @code
4286 * void function_name(GLFWwindow* window)
4287 * @endcode
4288 * For more information about the callback parameters, see the
4289 * [function pointer type](@ref GLFWwindowclosefun).
4290 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004291 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4292 *
Camilla Berglund8d6f2652016-10-20 00:50:54 +02004293 * @remark @macos Selecting Quit from the application menu will trigger the
4294 * close callback for all windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004295 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004296 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004297 *
4298 * @sa @ref window_close
4299 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004300 * @since Added in version 2.5.
4301 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01004302 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004303 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004304 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004305GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004306
4307/*! @brief Sets the refresh callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004308 *
4309 * This function sets the refresh callback of the specified window, which is
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004310 * called when the content area of the window needs to be redrawn, for example
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004311 * if the window has been exposed after having been covered by another window.
4312 *
linkmauvebc8b0482016-10-16 15:52:39 +01004313 * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
4314 * the window contents are saved off-screen, this callback may be called only
4315 * very infrequently or never at all.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02004316 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004317 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004318 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004319 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004320 * @return The previously set callback, or `NULL` if no callback was set or the
4321 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004322 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004323 * @callback_signature
4324 * @code
4325 * void function_name(GLFWwindow* window);
4326 * @endcode
4327 * For more information about the callback parameters, see the
4328 * [function pointer type](@ref GLFWwindowrefreshfun).
4329 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004330 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4331 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004332 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004333 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004334 * @sa @ref window_refresh
4335 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004336 * @since Added in version 2.5.
4337 * @glfw3 Added window handle parameter and return value.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01004338 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004339 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004340 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004341GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004342
4343/*! @brief Sets the focus callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004344 *
4345 * This function sets the focus callback of the specified window, which is
Camilla Berglund4188c262015-01-18 01:55:25 +01004346 * called when the window gains or loses input focus.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004347 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004348 * After the focus callback is called for a window that lost input focus,
4349 * synthetic key and mouse button release events will be generated for all such
4350 * that had been pressed. For more information, see @ref glfwSetKeyCallback
4351 * and @ref glfwSetMouseButtonCallback.
Camilla Berglund4538a522013-04-24 19:49:46 +02004352 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004353 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004354 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004355 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004356 * @return The previously set callback, or `NULL` if no callback was set or the
4357 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004358 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004359 * @callback_signature
4360 * @code
4361 * void function_name(GLFWwindow* window, int focused)
4362 * @endcode
4363 * For more information about the callback parameters, see the
4364 * [function pointer type](@ref GLFWwindowfocusfun).
4365 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004366 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4367 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004368 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004369 *
4370 * @sa @ref window_focus
4371 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004372 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004373 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004374 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004375 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004376GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004377
4378/*! @brief Sets the iconify callback for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004379 *
4380 * This function sets the iconification callback of the specified window, which
4381 * is called when the window is iconified or restored.
4382 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004383 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004384 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004385 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004386 * @return The previously set callback, or `NULL` if no callback was set or the
4387 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02004388 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004389 * @callback_signature
4390 * @code
4391 * void function_name(GLFWwindow* window, int iconified)
4392 * @endcode
4393 * For more information about the callback parameters, see the
4394 * [function pointer type](@ref GLFWwindowiconifyfun).
4395 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004396 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4397 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004398 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004399 *
4400 * @sa @ref window_iconify
4401 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004402 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004403 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004404 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004405 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004406GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
Camilla Berglund135194a2010-09-09 18:15:32 +02004407
Camilla Berglundc156b502016-06-16 13:09:28 +02004408/*! @brief Sets the maximize callback for the specified window.
4409 *
4410 * This function sets the maximization callback of the specified window, which
4411 * is called when the window is maximized or restored.
4412 *
4413 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004414 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglundc156b502016-06-16 13:09:28 +02004415 * callback.
4416 * @return The previously set callback, or `NULL` if no callback was set or the
4417 * library had not been [initialized](@ref intro_init).
4418 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004419 * @callback_signature
4420 * @code
4421 * void function_name(GLFWwindow* window, int maximized)
4422 * @endcode
4423 * For more information about the callback parameters, see the
4424 * [function pointer type](@ref GLFWwindowmaximizefun).
4425 *
Camilla Berglundc156b502016-06-16 13:09:28 +02004426 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4427 *
4428 * @thread_safety This function must only be called from the main thread.
4429 *
4430 * @sa @ref window_maximize
4431 *
4432 * @since Added in version 3.3.
4433 *
4434 * @ingroup window
4435 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004436GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
Camilla Berglundc156b502016-06-16 13:09:28 +02004437
Camilla Berglund34981632013-06-03 12:51:57 +02004438/*! @brief Sets the framebuffer resize callback for the specified window.
4439 *
4440 * This function sets the framebuffer resize callback of the specified window,
4441 * which is called when the framebuffer of the specified window is resized.
4442 *
4443 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004444 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund34981632013-06-03 12:51:57 +02004445 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004446 * @return The previously set callback, or `NULL` if no callback was set or the
4447 * library had not been [initialized](@ref intro_init).
Camilla Berglund34981632013-06-03 12:51:57 +02004448 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004449 * @callback_signature
4450 * @code
4451 * void function_name(GLFWwindow* window, int width, int height)
4452 * @endcode
4453 * For more information about the callback parameters, see the
4454 * [function pointer type](@ref GLFWframebuffersizefun).
4455 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004456 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4457 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004458 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004459 *
4460 * @sa @ref window_fbsize
4461 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004462 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01004463 *
Camilla Berglund34981632013-06-03 12:51:57 +02004464 * @ingroup window
4465 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004466GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
Camilla Berglund34981632013-06-03 12:51:57 +02004467
Camilla Löwy370eac32017-12-11 21:26:40 +01004468/*! @brief Sets the window content scale callback for the specified window.
4469 *
4470 * This function sets the window content scale callback of the specified window,
4471 * which is called when the content scale of the specified window changes.
4472 *
4473 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004474 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Löwy370eac32017-12-11 21:26:40 +01004475 * callback.
4476 * @return The previously set callback, or `NULL` if no callback was set or the
4477 * library had not been [initialized](@ref intro_init).
4478 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004479 * @callback_signature
4480 * @code
4481 * void function_name(GLFWwindow* window, float xscale, float yscale)
4482 * @endcode
4483 * For more information about the callback parameters, see the
4484 * [function pointer type](@ref GLFWwindowcontentscalefun).
4485 *
Camilla Löwy370eac32017-12-11 21:26:40 +01004486 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4487 *
4488 * @thread_safety This function must only be called from the main thread.
4489 *
4490 * @sa @ref window_scale
4491 * @sa @ref glfwGetWindowContentScale
4492 *
4493 * @since Added in version 3.3.
4494 *
4495 * @ingroup window
4496 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02004497GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
Camilla Löwy370eac32017-12-11 21:26:40 +01004498
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004499/*! @brief Processes all pending events.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004500 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004501 * This function processes only those events that are already in the event
4502 * queue and then returns immediately. Processing events will cause the window
4503 * and input callbacks associated with those events to be called.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004504 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004505 * On some platforms, a window move, resize or menu operation will cause event
4506 * processing to block. This is due to how event processing is designed on
4507 * those platforms. You can use the
4508 * [window refresh callback](@ref window_refresh) to redraw the contents of
4509 * your window when necessary during such operations.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004510 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004511 * Do not assume that callbacks you set will _only_ be called in response to
4512 * event processing functions like this one. While it is necessary to poll for
4513 * events, window systems that require GLFW to register callbacks of its own
4514 * can pass events to GLFW in response to many window system function calls.
4515 * GLFW will pass those events on to the application callbacks before
4516 * returning.
Camilla Berglund401033c2013-03-12 19:17:07 +01004517 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004518 * Event processing is not required for joystick input to work.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01004519 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004520 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4521 * GLFW_PLATFORM_ERROR.
4522 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004523 * @reentrancy This function must not be called from a callback.
Camilla Berglundb48128f2013-02-14 18:49:03 +01004524 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004525 * @thread_safety This function must only be called from the main thread.
Camilla Berglund948cc042013-04-16 02:02:22 +02004526 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004527 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004528 * @sa @ref glfwWaitEvents
4529 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004530 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004531 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004532 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004533 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004534 */
Camilla Berglund9a716692010-09-08 16:40:43 +02004535GLFWAPI void glfwPollEvents(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004536
Camilla Berglund4591ad22014-09-18 15:03:29 +02004537/*! @brief Waits until events are queued and processes them.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004538 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004539 * This function puts the calling thread to sleep until at least one event is
4540 * available in the event queue. Once one or more events are available,
4541 * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
4542 * are processed and the function then returns immediately. Processing events
4543 * will cause the window and input callbacks associated with those events to be
4544 * called.
Camilla Berglund948cc042013-04-16 02:02:22 +02004545 *
4546 * Since not all events are associated with callbacks, this function may return
4547 * without a callback having been called even if you are monitoring all
4548 * callbacks.
4549 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004550 * On some platforms, a window move, resize or menu operation will cause event
4551 * processing to block. This is due to how event processing is designed on
4552 * those platforms. You can use the
4553 * [window refresh callback](@ref window_refresh) to redraw the contents of
4554 * your window when necessary during such operations.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004555 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004556 * Do not assume that callbacks you set will _only_ be called in response to
4557 * event processing functions like this one. While it is necessary to poll for
4558 * events, window systems that require GLFW to register callbacks of its own
4559 * can pass events to GLFW in response to many window system function calls.
4560 * GLFW will pass those events on to the application callbacks before
4561 * returning.
Camilla Berglund4188c262015-01-18 01:55:25 +01004562 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004563 * Event processing is not required for joystick input to work.
Camilla Berglund9ad1d972012-11-22 19:08:30 +01004564 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004565 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4566 * GLFW_PLATFORM_ERROR.
4567 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004568 * @reentrancy This function must not be called from a callback.
Camilla Berglund44372b82014-12-17 01:31:36 +01004569 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004570 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004571 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004572 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004573 * @sa @ref glfwPollEvents
4574 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004575 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004576 * @since Added in version 2.5.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004577 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004578 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004579 */
Camilla Berglund9a716692010-09-08 16:40:43 +02004580GLFWAPI void glfwWaitEvents(void);
Camilla Berglund135194a2010-09-09 18:15:32 +02004581
Camilla Berglund56208952016-02-02 21:11:16 +01004582/*! @brief Waits with timeout until events are queued and processes them.
4583 *
4584 * This function puts the calling thread to sleep until at least one event is
4585 * available in the event queue, or until the specified timeout is reached. If
4586 * one or more events are available, it behaves exactly like @ref
4587 * glfwPollEvents, i.e. the events in the queue are processed and the function
4588 * then returns immediately. Processing events will cause the window and input
4589 * callbacks associated with those events to be called.
4590 *
4591 * The timeout value must be a positive finite number.
4592 *
4593 * Since not all events are associated with callbacks, this function may return
4594 * without a callback having been called even if you are monitoring all
4595 * callbacks.
4596 *
4597 * On some platforms, a window move, resize or menu operation will cause event
4598 * processing to block. This is due to how event processing is designed on
4599 * those platforms. You can use the
4600 * [window refresh callback](@ref window_refresh) to redraw the contents of
4601 * your window when necessary during such operations.
4602 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004603 * Do not assume that callbacks you set will _only_ be called in response to
4604 * event processing functions like this one. While it is necessary to poll for
4605 * events, window systems that require GLFW to register callbacks of its own
4606 * can pass events to GLFW in response to many window system function calls.
4607 * GLFW will pass those events on to the application callbacks before
4608 * returning.
Camilla Berglund56208952016-02-02 21:11:16 +01004609 *
Camilla Berglund56208952016-02-02 21:11:16 +01004610 * Event processing is not required for joystick input to work.
4611 *
4612 * @param[in] timeout The maximum amount of time, in seconds, to wait.
4613 *
Sylvain Boilard3b255af2018-09-13 16:23:44 +02004614 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy8e313d92018-12-13 20:33:17 +01004615 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Sylvain Boilard3b255af2018-09-13 16:23:44 +02004616 *
Camilla Berglund56208952016-02-02 21:11:16 +01004617 * @reentrancy This function must not be called from a callback.
4618 *
4619 * @thread_safety This function must only be called from the main thread.
4620 *
4621 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004622 * @sa @ref glfwPollEvents
4623 * @sa @ref glfwWaitEvents
Camilla Berglund56208952016-02-02 21:11:16 +01004624 *
4625 * @since Added in version 3.2.
4626 *
4627 * @ingroup window
4628 */
4629GLFWAPI void glfwWaitEventsTimeout(double timeout);
4630
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004631/*! @brief Posts an empty event to the event queue.
4632 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004633 * This function posts an empty event from the current thread to the event
Camilla Berglund73abf8a2016-07-06 13:06:59 +02004634 * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004635 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004636 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4637 * GLFW_PLATFORM_ERROR.
4638 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004639 * @thread_safety This function may be called from any thread.
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004640 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004641 * @sa @ref events
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004642 * @sa @ref glfwWaitEvents
4643 * @sa @ref glfwWaitEventsTimeout
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004644 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004645 * @since Added in version 3.1.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004646 *
Camilla Berglund1ccc2322014-02-10 18:16:58 +01004647 * @ingroup window
4648 */
4649GLFWAPI void glfwPostEmptyEvent(void);
4650
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004651/*! @brief Returns the value of an input option for the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004652 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02004653 * This function returns the value of an input option for the specified window.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004654 * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
Nathan Poirier9e29f552018-12-14 03:08:25 +01004655 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
Camilla Löwy1155c832019-02-11 19:10:20 +01004656 * @ref GLFW_RAW_MOUSE_MOTION.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004657 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004658 * @param[in] window The window to query.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004659 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
Camilla Löwy1155c832019-02-11 19:10:20 +01004660 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4661 * `GLFW_RAW_MOUSE_MOTION`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004662 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004663 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4664 * GLFW_INVALID_ENUM.
4665 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004666 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004667 *
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004668 * @sa @ref glfwSetInputMode
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004669 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004670 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004671 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004672 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004673 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004674GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004675
4676/*! @brief Sets an input option for the specified window.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004677 *
4678 * This function sets an input mode option for the specified window. The mode
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004679 * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
Grzesiek11bf945f12024-02-29 15:50:50 +00004680 * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS
4681 * @ref GLFW_RAW_MOUSE_MOTION, or @ref GLFW_UNLIMITED_MOUSE_BUTTONS.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004682 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004683 * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004684 * modes:
Camilla Berglund13ccf7d2013-04-07 13:46:38 +02004685 * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004686 * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
4687 * content area of the window but does not restrict the cursor from leaving.
Camilla Berglunda18b1872013-12-05 03:27:12 +01004688 * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
4689 * and unlimited cursor movement. This is useful for implementing for
4690 * example 3D camera controls.
Camilla Löwy488008e2019-12-03 17:58:20 +01004691 * - `GLFW_CURSOR_CAPTURED` makes the cursor visible and confines it to the
4692 * content area of the window.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004693 *
Camilla Berglund0eccf752015-08-23 19:30:04 +02004694 * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
4695 * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
Camilla Berglund95654cf2014-10-02 17:35:10 +02004696 * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
4697 * the next time it is called even if the key had been released before the
4698 * call. This is useful when you are only interested in whether keys have been
4699 * pressed but not when or in which order.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004700 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004701 * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
Camilla Berglund0eccf752015-08-23 19:30:04 +02004702 * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
4703 * If sticky mouse buttons are enabled, a mouse button press will ensure that
4704 * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
4705 * if the mouse button had been released before the call. This is useful when
4706 * you are only interested in whether mouse buttons have been pressed but not
4707 * when or in which order.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004708 *
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004709 * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
4710 * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
4711 * callbacks that receive modifier bits will also have the @ref
4712 * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
4713 * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
4714 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004715 * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
4716 * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
4717 * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02004718 * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
Camilla Löwy1155c832019-02-11 19:10:20 +01004719 * glfwRawMouseMotionSupported to check for support.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004720 *
Grzesiek11bf945f12024-02-29 15:50:50 +00004721 * If the mode is `GLFW_UNLIMITED_MOUSE_BUTTONS`, the value must be either
4722 * `GLFW_TRUE` to disable the mouse button limit when calling the mouse button
4723 * callback, or `GLFW_FALSE` to limit the mouse buttons sent to the callback
4724 * to the mouse button token values up to `GLFW_MOUSE_BUTTON_LAST`.
4725 *
Camilla Berglund95654cf2014-10-02 17:35:10 +02004726 * @param[in] window The window whose input mode to set.
Camilla Löwy0e8c4ea2017-11-29 20:42:37 +01004727 * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
Camilla Löwy1155c832019-02-11 19:10:20 +01004728 * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
4729 * `GLFW_RAW_MOUSE_MOTION`.
Camilla Berglund95654cf2014-10-02 17:35:10 +02004730 * @param[in] value The new value of the specified input mode.
Camilla Berglund39fe1f12013-03-12 19:39:36 +01004731 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004732 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy9a87c2a2020-05-20 18:02:58 +02004733 * GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
4734 * GLFW_FEATURE_UNAVAILABLE (see above).
Camilla Berglundf51cf812016-02-05 00:51:40 +01004735 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004736 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004737 *
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004738 * @sa @ref glfwGetInputMode
Camilla Berglunde248fb62013-03-29 14:06:23 +01004739 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004740 * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004741 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01004742 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004743 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004744GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004745
Camilla Löwy1155c832019-02-11 19:10:20 +01004746/*! @brief Returns whether raw mouse motion is supported.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004747 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004748 * This function returns whether raw mouse motion is supported on the current
4749 * system. This status does not change after GLFW has been initialized so you
4750 * only need to check this once. If you attempt to enable raw motion on
4751 * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004752 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004753 * Raw mouse motion is closer to the actual motion of the mouse across
4754 * a surface. It is not affected by the scaling and acceleration applied to
4755 * the motion of the desktop cursor. That processing is suitable for a cursor
4756 * while raw motion is better for controlling for example a 3D camera. Because
4757 * of this, raw mouse motion is only provided when the cursor is disabled.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004758 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004759 * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
4760 * or `GLFW_FALSE` otherwise.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004761 *
4762 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
4763 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004764 * @thread_safety This function must only be called from the main thread.
Nathan Poirier9e29f552018-12-14 03:08:25 +01004765 *
Camilla Löwy1155c832019-02-11 19:10:20 +01004766 * @sa @ref raw_mouse_motion
Nathan Poirier9e29f552018-12-14 03:08:25 +01004767 * @sa @ref glfwSetInputMode
4768 *
4769 * @since Added in version 3.3.
4770 *
4771 * @ingroup input
4772 */
Camilla Löwy1155c832019-02-11 19:10:20 +01004773GLFWAPI int glfwRawMouseMotionSupported(void);
Nathan Poirier9e29f552018-12-14 03:08:25 +01004774
Camilla Löwy9558b852017-04-04 18:05:36 +02004775/*! @brief Returns the layout-specific name of the specified printable key.
Camilla Berglund9c315412015-07-02 14:24:50 +02004776 *
Camilla Löwy9558b852017-04-04 18:05:36 +02004777 * This function returns the name of the specified printable key, encoded as
4778 * UTF-8. This is typically the character that key would produce without any
4779 * modifier keys, intended for displaying key bindings to the user. For dead
4780 * keys, it is typically the diacritic it would add to a character.
Camilla Berglund9c315412015-07-02 14:24:50 +02004781 *
Camilla Löwy071a0492017-02-28 22:29:10 +01004782 * __Do not use this function__ for [text input](@ref input_char). You will
4783 * break text input for many languages even if it happens to work for yours.
Camilla Berglund70ffae72016-02-22 11:54:56 +01004784 *
Camilla Löwy071a0492017-02-28 22:29:10 +01004785 * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
4786 * otherwise the scancode is ignored. If you specify a non-printable key, or
4787 * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
4788 * function returns `NULL` but does not emit an error.
4789 *
4790 * This behavior allows you to always pass in the arguments in the
Camilla Berglund70ffae72016-02-22 11:54:56 +01004791 * [key callback](@ref input_key) without modification.
4792 *
4793 * The printable keys are:
4794 * - `GLFW_KEY_APOSTROPHE`
4795 * - `GLFW_KEY_COMMA`
4796 * - `GLFW_KEY_MINUS`
4797 * - `GLFW_KEY_PERIOD`
4798 * - `GLFW_KEY_SLASH`
4799 * - `GLFW_KEY_SEMICOLON`
4800 * - `GLFW_KEY_EQUAL`
4801 * - `GLFW_KEY_LEFT_BRACKET`
4802 * - `GLFW_KEY_RIGHT_BRACKET`
4803 * - `GLFW_KEY_BACKSLASH`
4804 * - `GLFW_KEY_WORLD_1`
4805 * - `GLFW_KEY_WORLD_2`
4806 * - `GLFW_KEY_0` to `GLFW_KEY_9`
4807 * - `GLFW_KEY_A` to `GLFW_KEY_Z`
4808 * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
4809 * - `GLFW_KEY_KP_DECIMAL`
4810 * - `GLFW_KEY_KP_DIVIDE`
4811 * - `GLFW_KEY_KP_MULTIPLY`
4812 * - `GLFW_KEY_KP_SUBTRACT`
4813 * - `GLFW_KEY_KP_ADD`
4814 * - `GLFW_KEY_KP_EQUAL`
Camilla Berglund9c315412015-07-02 14:24:50 +02004815 *
Camilla Löwy071a0492017-02-28 22:29:10 +01004816 * Names for printable keys depend on keyboard layout, while names for
4817 * non-printable keys are the same across layouts but depend on the application
4818 * language and should be localized along with other user interface text.
4819 *
Camilla Berglund9c315412015-07-02 14:24:50 +02004820 * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
4821 * @param[in] scancode The scancode of the key to query.
Camilla Löwy9558b852017-04-04 18:05:36 +02004822 * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
Camilla Berglund9c315412015-07-02 14:24:50 +02004823 *
Camilla Löwy557a6332023-12-05 15:53:42 +01004824 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
4825 * GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01004826 *
Camilla Löwy56ca0cb2019-08-22 21:31:46 +02004827 * @remark The contents of the returned string may change when a keyboard
4828 * layout change event is received.
4829 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004830 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
Camilla Löwy56ca0cb2019-08-22 21:31:46 +02004831 * should not free it yourself. It is valid until the library is terminated.
Camilla Berglund9c315412015-07-02 14:24:50 +02004832 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004833 * @thread_safety This function must only be called from the main thread.
Camilla Berglund9c315412015-07-02 14:24:50 +02004834 *
4835 * @sa @ref input_key_name
4836 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004837 * @since Added in version 3.2.
Camilla Berglund9c315412015-07-02 14:24:50 +02004838 *
4839 * @ingroup input
4840 */
4841GLFWAPI const char* glfwGetKeyName(int key, int scancode);
4842
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004843/*! @brief Returns the platform-specific scancode of the specified key.
Michael Stockere745b0d2016-08-11 19:11:40 +02004844 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004845 * This function returns the platform-specific scancode of the specified key.
Michael Stockere745b0d2016-08-11 19:11:40 +02004846 *
Camilla Löwy9959dc62023-12-04 20:06:10 +01004847 * If the specified [key token](@ref keys) corresponds to a physical key not
4848 * supported on the current platform then this method will return `-1`.
4849 * Calling this function with anything other than a key token will return `-1`
4850 * and generate a @ref GLFW_INVALID_ENUM error.
Michael Stockere745b0d2016-08-11 19:11:40 +02004851 *
Camilla Löwy9959dc62023-12-04 20:06:10 +01004852 * @param[in] key Any [key token](@ref keys).
4853 * @return The platform-specific scancode for the key, or `-1` if the key is
4854 * not supported on the current platform or an [error](@ref error_handling)
4855 * occurred.
Michael Stockere745b0d2016-08-11 19:11:40 +02004856 *
Camilla Löwy9959dc62023-12-04 20:06:10 +01004857 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4858 * GLFW_INVALID_ENUM.
Michael Stockere745b0d2016-08-11 19:11:40 +02004859 *
4860 * @thread_safety This function may be called from any thread.
4861 *
Camilla Löwy766a9dc2016-12-06 23:26:53 +01004862 * @sa @ref input_key
Michael Stockere745b0d2016-08-11 19:11:40 +02004863 *
4864 * @since Added in version 3.3.
4865 *
4866 * @ingroup input
4867 */
Camilla Berglundbb3cb8f2016-09-06 15:40:31 +02004868GLFWAPI int glfwGetKeyScancode(int key);
Michael Stockere745b0d2016-08-11 19:11:40 +02004869
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004870/*! @brief Returns the last reported state of a keyboard key for the specified
4871 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004872 *
4873 * This function returns the last state reported for the specified key to the
4874 * specified window. The returned state is one of `GLFW_PRESS` or
Camilla Löwyaa80d242022-06-28 23:19:30 +02004875 * `GLFW_RELEASE`. The action `GLFW_REPEAT` is only reported to the key callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004876 *
Camilla Löwy46393072017-02-20 13:45:11 +01004877 * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
Camilla Berglund4591ad22014-09-18 15:03:29 +02004878 * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
4879 * that key has already been released.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004880 *
4881 * The key functions deal with physical keys, with [key tokens](@ref keys)
4882 * named after their use on the standard US keyboard layout. If you want to
4883 * input text, use the Unicode character callback instead.
4884 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02004885 * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
4886 * used with this function.
4887 *
Camilla Berglund9c315412015-07-02 14:24:50 +02004888 * __Do not use this function__ to implement [text input](@ref input_char).
4889 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004890 * @param[in] window The desired window.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004891 * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
4892 * not a valid key for this function.
Camilla Berglund71d2b572013-03-12 15:33:05 +01004893 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004894 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004895 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4896 * GLFW_INVALID_ENUM.
4897 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004898 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004899 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004900 * @sa @ref input_key
4901 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004902 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01004903 * @glfw3 Added window handle parameter.
Camilla Berglund11615fc2013-05-30 17:19:12 +02004904 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004905 * @ingroup input
4906 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004907GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004908
4909/*! @brief Returns the last reported state of a mouse button for the specified
4910 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004911 *
4912 * This function returns the last state reported for the specified mouse button
Camilla Berglund4591ad22014-09-18 15:03:29 +02004913 * to the specified window. The returned state is one of `GLFW_PRESS` or
Camilla Berglundce8f97c2015-01-11 23:33:14 +01004914 * `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004915 *
Camilla Löwy46393072017-02-20 13:45:11 +01004916 * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
Coşku Başf4764f72018-08-06 18:13:24 +03004917 * returns `GLFW_PRESS` the first time you call it for a mouse button that was
4918 * pressed, even if that mouse button has already been released.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004919 *
Grzesiek11bf945f12024-02-29 15:50:50 +00004920 * The @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode does not effect the
4921 * limit on buttons which can be polled with this function.
4922 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004923 * @param[in] window The desired window.
Grzesiek11bf945f12024-02-29 15:50:50 +00004924 * @param[in] button The desired [mouse button token](@ref buttons).
Camilla Berglund71d2b572013-03-12 15:33:05 +01004925 * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004926 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004927 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4928 * GLFW_INVALID_ENUM.
4929 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004930 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004931 *
4932 * @sa @ref input_mouse_button
4933 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004934 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01004935 * @glfw3 Added window handle parameter.
Camilla Berglund0e205772014-03-24 11:58:35 +01004936 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004937 * @ingroup input
4938 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01004939GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004940
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004941/*! @brief Retrieves the position of the cursor relative to the content area of
Camilla Berglundd4591452014-02-11 18:24:01 +01004942 * the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004943 *
Camilla Berglundd4591452014-02-11 18:24:01 +01004944 * This function returns the position of the cursor, in screen coordinates,
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004945 * relative to the upper-left corner of the content area of the specified
Camilla Berglundd4591452014-02-11 18:24:01 +01004946 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004947 *
Camilla Berglund6df692b2013-04-26 17:20:31 +02004948 * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
4949 * position is unbounded and limited only by the minimum and maximum values of
4950 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02004951 *
Camilla Berglund3ec29252013-04-25 18:03:15 +02004952 * The coordinate can be converted to their integer equivalents with the
4953 * `floor` function. Casting directly to an integer type works for positive
4954 * coordinates, but fails for negative ones.
4955 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02004956 * Any or all of the position arguments may be `NULL`. If an error occurs, all
4957 * non-`NULL` position arguments will be set to zero.
4958 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004959 * @param[in] window The desired window.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004960 * @param[out] xpos Where to store the cursor x-coordinate, relative to the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004961 * left edge of the content area, or `NULL`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02004962 * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004963 * top edge of the content area, or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004964 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01004965 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
4966 * GLFW_PLATFORM_ERROR.
4967 *
Camilla Berglund951a9582016-01-31 21:32:14 +01004968 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01004969 *
Camilla Berglund4188c262015-01-18 01:55:25 +01004970 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02004971 * @sa @ref glfwSetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004972 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01004973 * @since Added in version 3.0. Replaces `glfwGetMousePos`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02004974 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004975 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004976 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02004977GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004978
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004979/*! @brief Sets the position of the cursor, relative to the content area of the
Camilla Berglund6d9d8562013-09-28 22:12:50 +02004980 * window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004981 *
Camilla Berglund6d9d8562013-09-28 22:12:50 +02004982 * This function sets the position, in screen coordinates, of the cursor
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004983 * relative to the upper-left corner of the content area of the specified
Camilla Berglund4188c262015-01-18 01:55:25 +01004984 * window. The window must have input focus. If the window does not have
4985 * input focus when this function is called, it fails silently.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01004986 *
Camilla Berglund20858762015-01-01 18:41:22 +01004987 * __Do not use this function__ to implement things like camera controls. GLFW
4988 * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
4989 * cursor, transparently re-centers it and provides unconstrained cursor
4990 * motion. See @ref glfwSetInputMode for more information.
4991 *
4992 * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
4993 * unconstrained and limited only by the minimum and maximum values of
Camilla Berglund6df692b2013-04-26 17:20:31 +02004994 * a `double`.
Camilla Berglund948cc042013-04-16 02:02:22 +02004995 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004996 * @param[in] window The desired window.
4997 * @param[in] xpos The desired x-coordinate, relative to the left edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01004998 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01004999 * @param[in] ypos The desired y-coordinate, relative to the top edge of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01005000 * content area.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005001 *
Camilla Löwy97b9e492022-09-20 17:03:30 +02005002 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5003 * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
Camilla Berglundf51cf812016-02-05 00:51:40 +01005004 *
linkmauvebc8b0482016-10-16 15:52:39 +01005005 * @remark @wayland This function will only work when the cursor mode is
Camilla Löwy97b9e492022-09-20 17:03:30 +02005006 * `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE.
linkmauvebc8b0482016-10-16 15:52:39 +01005007 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005008 * @thread_safety This function must only be called from the main thread.
Camilla Berglund0e205772014-03-24 11:58:35 +01005009 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005010 * @sa @ref cursor_pos
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005011 * @sa @ref glfwGetCursorPos
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005012 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005013 * @since Added in version 3.0. Replaces `glfwSetMousePos`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005014 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005015 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005016 */
Camilla Berglund129e94d2013-04-04 16:16:21 +02005017GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005018
Camilla Berglund2a1375e2014-09-02 16:52:16 +02005019/*! @brief Creates a custom cursor.
urraka40c04a72013-12-04 10:19:22 -03005020 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005021 * Creates a new custom cursor image that can be set for a window with @ref
5022 * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
5023 * Any remaining cursors are destroyed by @ref glfwTerminate.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005024 *
Camilla Berglund85a01bf2015-08-17 21:04:19 +02005025 * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
Camilla Löwybeaeb0d2017-06-06 18:17:58 +02005026 * bits per channel with the red channel first. They are arranged canonically
5027 * as packed sequential rows, starting from the top-left corner.
Camilla Berglund4188c262015-01-18 01:55:25 +01005028 *
5029 * The cursor hotspot is specified in pixels, relative to the upper-left corner
5030 * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
5031 * points to the right and the Y-axis points down.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005032 *
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01005033 * @param[in] image The desired cursor image.
Camilla Berglund4188c262015-01-18 01:55:25 +01005034 * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
5035 * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
Camilla Berglund4188c262015-01-18 01:55:25 +01005036 * @return The handle of the created cursor, or `NULL` if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02005037 * [error](@ref error_handling) occurred.
urraka40c04a72013-12-04 10:19:22 -03005038 *
Camilla Löwy66a48822022-03-15 21:22:49 +01005039 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5040 * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01005041 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005042 * @pointer_lifetime The specified image data is copied before this function
5043 * returns.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005044 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005045 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005046 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005047 * @sa @ref cursor_object
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005048 * @sa @ref glfwDestroyCursor
5049 * @sa @ref glfwCreateStandardCursor
Camilla Berglund4591ad22014-09-18 15:03:29 +02005050 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005051 * @since Added in version 3.1.
urraka40c04a72013-12-04 10:19:22 -03005052 *
5053 * @ingroup input
5054 */
Camilla Berglund8fa9cc02014-02-23 16:43:17 +01005055GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
urraka40c04a72013-12-04 10:19:22 -03005056
Camilla Berglund2a1375e2014-09-02 16:52:16 +02005057/*! @brief Creates a cursor with a standard shape.
5058 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02005059 * Returns a cursor with a standard shape, that can be set for a window with
5060 * @ref glfwSetCursor. The images for these cursors come from the system
5061 * cursor theme and their exact appearance will vary between platforms.
5062 *
5063 * Most of these shapes are guaranteed to exist on every supported platform but
5064 * a few may not be present. See the table below for details.
5065 *
5066 * Cursor shape | Windows | macOS | X11 | Wayland
5067 * ------------------------------ | ------- | ----- | ------ | -------
5068 * @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes
5069 * @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes
5070 * @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes
5071 * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes
5072 * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes
5073 * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes
5074 * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
5075 * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
5076 * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes
5077 * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe<sup>2</sup> | Maybe<sup>2</sup>
5078 *
5079 * 1) This uses a private system API and may fail in the future.
5080 *
5081 * 2) This uses a newer standard that not all cursor themes support.
5082 *
5083 * If the requested shape is not available, this function emits a @ref
5084 * GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02005085 *
5086 * @param[in] shape One of the [standard shapes](@ref shapes).
Camilla Berglund2a1375e2014-09-02 16:52:16 +02005087 * @return A new cursor ready to use or `NULL` if an
5088 * [error](@ref error_handling) occurred.
5089 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005090 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02005091 * GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
5092 * GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01005093 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005094 * @thread_safety This function must only be called from the main thread.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02005095 *
Camilla Löwy7dbdd2e2019-05-07 20:40:37 +02005096 * @sa @ref cursor_standard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005097 * @sa @ref glfwCreateCursor
Camilla Berglund2a1375e2014-09-02 16:52:16 +02005098 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005099 * @since Added in version 3.1.
Camilla Berglund2a1375e2014-09-02 16:52:16 +02005100 *
5101 * @ingroup input
5102 */
5103GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
5104
urraka40c04a72013-12-04 10:19:22 -03005105/*! @brief Destroys a cursor.
5106 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005107 * This function destroys a cursor previously created with @ref
5108 * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
5109 * glfwTerminate.
urraka40c04a72013-12-04 10:19:22 -03005110 *
Camilla Löwy46393072017-02-20 13:45:11 +01005111 * If the specified cursor is current for any window, that window will be
5112 * reverted to the default cursor. This does not affect the cursor mode.
5113 *
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005114 * @param[in] cursor The cursor object to destroy.
urraka40c04a72013-12-04 10:19:22 -03005115 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005116 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5117 * GLFW_PLATFORM_ERROR.
5118 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005119 * @reentrancy This function must not be called from a callback.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005120 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005121 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005122 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005123 * @sa @ref cursor_object
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005124 * @sa @ref glfwCreateCursor
Camilla Berglund4591ad22014-09-18 15:03:29 +02005125 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005126 * @since Added in version 3.1.
urraka40c04a72013-12-04 10:19:22 -03005127 *
5128 * @ingroup input
5129 */
5130GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
5131
Camilla Berglund4188c262015-01-18 01:55:25 +01005132/*! @brief Sets the cursor for the window.
urraka40c04a72013-12-04 10:19:22 -03005133 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005134 * This function sets the cursor image to be used when the cursor is over the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01005135 * content area of the specified window. The set cursor will only be visible
Camilla Berglund4188c262015-01-18 01:55:25 +01005136 * when the [cursor mode](@ref cursor_mode) of the window is
5137 * `GLFW_CURSOR_NORMAL`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005138 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005139 * On some platforms, the set cursor may not be visible unless the window also
5140 * has input focus.
5141 *
5142 * @param[in] window The window to set the cursor for.
5143 * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
5144 * arrow cursor.
urraka40c04a72013-12-04 10:19:22 -03005145 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005146 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5147 * GLFW_PLATFORM_ERROR.
5148 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005149 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005150 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005151 * @sa @ref cursor_object
Camilla Berglund4591ad22014-09-18 15:03:29 +02005152 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005153 * @since Added in version 3.1.
Camilla Berglund0e205772014-03-24 11:58:35 +01005154 *
urraka40c04a72013-12-04 10:19:22 -03005155 * @ingroup input
5156 */
5157GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
5158
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005159/*! @brief Sets the key callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005160 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005161 * This function sets the key callback of the specified window, which is called
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005162 * when a key is pressed, repeated or released.
5163 *
Camilla Berglund948cc042013-04-16 02:02:22 +02005164 * The key functions deal with physical keys, with layout independent
5165 * [key tokens](@ref keys) named after their values in the standard US keyboard
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005166 * layout. If you want to input text, use the
5167 * [character callback](@ref glfwSetCharCallback) instead.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005168 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005169 * When a window loses input focus, it will generate synthetic key release
Camilla Löwy9959dc62023-12-04 20:06:10 +01005170 * events for all pressed keys with associated key tokens. You can tell these
5171 * events from user-generated events by the fact that the synthetic ones are
5172 * generated after the focus loss event has been processed, i.e. after the
Camilla Berglund4188c262015-01-18 01:55:25 +01005173 * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
Camilla Berglund4538a522013-04-24 19:49:46 +02005174 *
Camilla Berglund11615fc2013-05-30 17:19:12 +02005175 * The scancode of a key is specific to that platform or sometimes even to that
5176 * machine. Scancodes are intended to allow users to bind keys that don't have
5177 * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
Camilla Berglund4591ad22014-09-18 15:03:29 +02005178 * state is not saved and so it cannot be queried with @ref glfwGetKey.
Camilla Berglund11615fc2013-05-30 17:19:12 +02005179 *
5180 * Sometimes GLFW needs to generate synthetic key events, in which case the
5181 * scancode may be zero.
5182 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005183 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005184 * @param[in] callback The new key callback, or `NULL` to remove the currently
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005185 * set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005186 * @return The previously set callback, or `NULL` if no callback was set or the
5187 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005188 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005189 * @callback_signature
5190 * @code
5191 * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
5192 * @endcode
5193 * For more information about the callback parameters, see the
5194 * [function pointer type](@ref GLFWkeyfun).
5195 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005196 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5197 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005198 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005199 *
5200 * @sa @ref input_key
5201 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005202 * @since Added in version 1.0.
5203 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01005204 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005205 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005206 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005207GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005208
5209/*! @brief Sets the Unicode character callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005210 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005211 * This function sets the character callback of the specified window, which is
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005212 * called when a Unicode character is input.
5213 *
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005214 * The character callback is intended for Unicode text input. As it deals with
5215 * characters, it is keyboard layout dependent, whereas the
5216 * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
5217 * to physical keys, as a key may produce zero, one or more characters. If you
5218 * want to know whether a specific physical key was pressed or released, see
5219 * the key callback instead.
5220 *
5221 * The character callback behaves as system text input normally does and will
5222 * not be called if modifier keys are held down that would prevent normal text
Camilla Berglund8d6f2652016-10-20 00:50:54 +02005223 * input on that platform, for example a Super (Command) key on macOS or Alt key
Camilla Löwy86e7bf42018-12-25 22:11:23 +01005224 * on Windows.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005225 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005226 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005227 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005228 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005229 * @return The previously set callback, or `NULL` if no callback was set or the
5230 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005231 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005232 * @callback_signature
5233 * @code
5234 * void function_name(GLFWwindow* window, unsigned int codepoint)
5235 * @endcode
5236 * For more information about the callback parameters, see the
5237 * [function pointer type](@ref GLFWcharfun).
5238 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005239 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5240 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005241 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005242 *
5243 * @sa @ref input_char
5244 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005245 * @since Added in version 2.4.
5246 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01005247 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005248 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005249 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005250GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005251
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005252/*! @brief Sets the Unicode character with modifiers callback.
5253 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005254 * This function sets the character with modifiers callback of the specified
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005255 * window, which is called when a Unicode character is input regardless of what
5256 * modifier keys are used.
5257 *
5258 * The character with modifiers callback is intended for implementing custom
5259 * Unicode character input. For regular Unicode text input, see the
5260 * [character callback](@ref glfwSetCharCallback). Like the character
5261 * callback, the character with modifiers callback deals with characters and is
5262 * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
5263 * a key may produce zero, one or more characters. If you want to know whether
5264 * a specific physical key was pressed or released, see the
5265 * [key callback](@ref glfwSetKeyCallback) instead.
5266 *
5267 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005268 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005269 * callback.
5270 * @return The previously set callback, or `NULL` if no callback was set or an
Camilla Berglund999f3552016-08-17 16:48:22 +02005271 * [error](@ref error_handling) occurred.
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005272 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005273 * @callback_signature
5274 * @code
5275 * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
5276 * @endcode
5277 * For more information about the callback parameters, see the
5278 * [function pointer type](@ref GLFWcharmodsfun).
5279 *
Camilla Löwyadebcc72017-11-14 23:28:12 +01005280 * @deprecated Scheduled for removal in version 4.0.
5281 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005282 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5283 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005284 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005285 *
5286 * @sa @ref input_char
5287 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005288 * @since Added in version 3.1.
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005289 *
5290 * @ingroup input
5291 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005292GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
Camilla Berglund96b12ee2014-06-12 23:04:20 +02005293
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005294/*! @brief Sets the mouse button callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005295 *
5296 * This function sets the mouse button callback of the specified window, which
5297 * is called when a mouse button is pressed or released.
5298 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005299 * When a window loses input focus, it will generate synthetic mouse button
Grzesiek11bf945f12024-02-29 15:50:50 +00005300 * release events for all pressed mouse buttons with associated button tokens.
5301 * You can tell these events from user-generated events by the fact that the
5302 * synthetic ones are generated after the focus loss event has been processed,
5303 * i.e. after the [window focus callback](@ref glfwSetWindowFocusCallback) has
5304 * been called.
5305 *
5306 * The reported `button` value can be higher than `GLFW_MOUSE_BUTTON_LAST` if
5307 * the button does not have an associated [button token](@ref buttons) and the
5308 * @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set.
Camilla Berglund4538a522013-04-24 19:49:46 +02005309 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005310 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005311 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005312 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005313 * @return The previously set callback, or `NULL` if no callback was set or the
5314 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005315 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005316 * @callback_signature
5317 * @code
5318 * void function_name(GLFWwindow* window, int button, int action, int mods)
5319 * @endcode
5320 * For more information about the callback parameters, see the
5321 * [function pointer type](@ref GLFWmousebuttonfun).
5322 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005323 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5324 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005325 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005326 *
5327 * @sa @ref input_mouse_button
5328 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005329 * @since Added in version 1.0.
5330 * @glfw3 Added window handle parameter and return value.
Camilla Berglund0e205772014-03-24 11:58:35 +01005331 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005332 * @ingroup input
5333 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005334GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005335
5336/*! @brief Sets the cursor position callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005337 *
5338 * This function sets the cursor position callback of the specified window,
5339 * which is called when the cursor is moved. The callback is provided with the
Camilla Berglund6d9d8562013-09-28 22:12:50 +02005340 * position, in screen coordinates, relative to the upper-left corner of the
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01005341 * content area of the window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005342 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005343 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005344 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005345 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005346 * @return The previously set callback, or `NULL` if no callback was set or the
5347 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005348 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005349 * @callback_signature
5350 * @code
5351 * void function_name(GLFWwindow* window, double xpos, double ypos);
5352 * @endcode
5353 * For more information about the callback parameters, see the
5354 * [function pointer type](@ref GLFWcursorposfun).
5355 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005356 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5357 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005358 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005359 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005360 * @sa @ref cursor_pos
Camilla Berglund4591ad22014-09-18 15:03:29 +02005361 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005362 * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
Camilla Berglund0e205772014-03-24 11:58:35 +01005363 *
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005364 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005365 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005366GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005367
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005368/*! @brief Sets the cursor enter/leave callback.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005369 *
5370 * This function sets the cursor boundary crossing callback of the specified
Camilla Löwyd5ab3e92019-01-22 20:54:16 +01005371 * window, which is called when the cursor enters or leaves the content area of
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005372 * the window.
5373 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005374 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005375 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglunddba2d802013-01-17 23:06:56 +01005376 * callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005377 * @return The previously set callback, or `NULL` if no callback was set or the
5378 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005379 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005380 * @callback_signature
5381 * @code
5382 * void function_name(GLFWwindow* window, int entered)
5383 * @endcode
5384 * For more information about the callback parameters, see the
5385 * [function pointer type](@ref GLFWcursorenterfun).
5386 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005387 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5388 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005389 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005390 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005391 * @sa @ref cursor_enter
Camilla Berglund4591ad22014-09-18 15:03:29 +02005392 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005393 * @since Added in version 3.0.
Camilla Berglund0e205772014-03-24 11:58:35 +01005394 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005395 * @ingroup input
5396 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005397GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005398
5399/*! @brief Sets the scroll callback.
Camilla Berglunde248fb62013-03-29 14:06:23 +01005400 *
5401 * This function sets the scroll callback of the specified window, which is
5402 * called when a scrolling device is used, such as a mouse wheel or scrolling
5403 * area of a touchpad.
5404 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005405 * The scroll callback receives all scrolling input, like that from a mouse
5406 * wheel or a touchpad scrolling area.
5407 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01005408 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005409 * @param[in] callback The new scroll callback, or `NULL` to remove the
5410 * currently set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005411 * @return The previously set callback, or `NULL` if no callback was set or the
5412 * library had not been [initialized](@ref intro_init).
Camilla Berglund11a27de2013-04-08 21:21:21 +02005413 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005414 * @callback_signature
5415 * @code
5416 * void function_name(GLFWwindow* window, double xoffset, double yoffset)
5417 * @endcode
5418 * For more information about the callback parameters, see the
5419 * [function pointer type](@ref GLFWscrollfun).
5420 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005421 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5422 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005423 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005424 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005425 * @sa @ref scrolling
Camilla Berglund4591ad22014-09-18 15:03:29 +02005426 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005427 * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
Camilla Berglund0e205772014-03-24 11:58:35 +01005428 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01005429 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005430 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005431GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
Camilla Berglund3249f812010-09-07 17:34:51 +02005432
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005433/*! @brief Sets the path drop callback.
arturo89d07232013-07-10 11:42:14 +02005434 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005435 * This function sets the path drop callback of the specified window, which is
5436 * called when one or more dragged paths are dropped on the window.
arturo89d07232013-07-10 11:42:14 +02005437 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005438 * Because the path array and its strings may have been generated specifically
5439 * for that event, they are not guaranteed to be valid after the callback has
5440 * returned. If you wish to use them after the callback returns, you need to
5441 * make a deep copy.
arturo89d07232013-07-10 11:42:14 +02005442 *
5443 * @param[in] window The window whose callback to set.
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005444 * @param[in] callback The new file drop callback, or `NULL` to remove the
Camilla Berglund5c8121e2014-03-29 21:35:21 +01005445 * currently set callback.
Camilla Berglunde8e05d42014-04-23 13:30:11 +02005446 * @return The previously set callback, or `NULL` if no callback was set or the
5447 * library had not been [initialized](@ref intro_init).
arturo89d07232013-07-10 11:42:14 +02005448 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005449 * @callback_signature
5450 * @code
5451 * void function_name(GLFWwindow* window, int path_count, const char* paths[])
5452 * @endcode
5453 * For more information about the callback parameters, see the
5454 * [function pointer type](@ref GLFWdropfun).
5455 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005456 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5457 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005458 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005459 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005460 * @sa @ref path_drop
Camilla Berglund4591ad22014-09-18 15:03:29 +02005461 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005462 * @since Added in version 3.1.
Camilla Berglund0e205772014-03-24 11:58:35 +01005463 *
arturo89d07232013-07-10 11:42:14 +02005464 * @ingroup input
5465 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005466GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
arturo89d07232013-07-10 11:42:14 +02005467
Camilla Berglundfdd45182013-05-27 15:13:09 +02005468/*! @brief Returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005469 *
Camilla Berglundfdd45182013-05-27 15:13:09 +02005470 * This function returns whether the specified joystick is present.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005471 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005472 * There is no need to call this function before other functions that accept
5473 * a joystick ID, as they all check for presence before performing any other
5474 * work.
5475 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005476 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund0eccf752015-08-23 19:30:04 +02005477 * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005478 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005479 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5480 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5481 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005482 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005483 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005484 * @sa @ref joystick
Camilla Berglund4591ad22014-09-18 15:03:29 +02005485 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005486 * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
Camilla Berglund0e205772014-03-24 11:58:35 +01005487 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005488 * @ingroup input
5489 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005490GLFWAPI int glfwJoystickPresent(int jid);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005491
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02005492/*! @brief Returns the values of all axes of the specified joystick.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005493 *
5494 * This function returns the values of all axes of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005495 * Each element in the array is a value between -1.0 and 1.0.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005496 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005497 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005498 * but will not generate an error. This can be used instead of first calling
5499 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01005500 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005501 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005502 * @param[out] count Where to store the number of axis values in the returned
Camilla Berglund999f3552016-08-17 16:48:22 +02005503 * array. This is set to zero if the joystick is not present or an error
5504 * occurred.
5505 * @return An array of axis values, or `NULL` if the joystick is not present or
5506 * an [error](@ref error_handling) occurred.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02005507 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005508 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5509 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5510 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005511 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5512 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01005513 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01005514 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005515 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02005516 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005517 * @sa @ref joystick_axis
Camilla Berglund4591ad22014-09-18 15:03:29 +02005518 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005519 * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005520 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005521 * @ingroup input
5522 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005523GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005524
Camilla Berglunde93bade2013-06-16 02:33:33 +02005525/*! @brief Returns the state of all buttons of the specified joystick.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005526 *
Camilla Berglunde93bade2013-06-16 02:33:33 +02005527 * This function returns the state of all buttons of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005528 * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
Camilla Berglund5fd409b2013-06-05 17:53:13 +02005529 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005530 * For backward compatibility with earlier versions that did not have @ref
5531 * glfwGetJoystickHats, the button array also includes all hats, each
5532 * represented as four buttons. The hats are in the same order as returned by
5533 * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
5534 * _left_. To disable these extra buttons, set the @ref
5535 * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
5536 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005537 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005538 * but will not generate an error. This can be used instead of first calling
5539 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01005540 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005541 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005542 * @param[out] count Where to store the number of button states in the returned
Camilla Berglund999f3552016-08-17 16:48:22 +02005543 * array. This is set to zero if the joystick is not present or an error
5544 * occurred.
5545 * @return An array of button states, or `NULL` if the joystick is not present
5546 * or an [error](@ref error_handling) occurred.
Camilla Berglund7f2eb7b2013-04-24 19:25:42 +02005547 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005548 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5549 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5550 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005551 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5552 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01005553 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01005554 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005555 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02005556 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005557 * @sa @ref joystick_button
Camilla Berglund4591ad22014-09-18 15:03:29 +02005558 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005559 * @since Added in version 2.2.
Camilla Berglund951a9582016-01-31 21:32:14 +01005560 * @glfw3 Changed to return a dynamic array.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005561 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005562 * @ingroup input
5563 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005564GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
Camilla Berglund3249f812010-09-07 17:34:51 +02005565
IntellectualKitty368dec72016-11-25 20:56:24 -07005566/*! @brief Returns the state of all hats of the specified joystick.
5567 *
5568 * This function returns the state of all hats of the specified joystick.
Camilla Löwy798d7c62017-03-01 23:27:20 +01005569 * Each element in the array is one of the following values:
IntellectualKitty368dec72016-11-25 20:56:24 -07005570 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005571 * Name | Value
Camilla Löwybb2ca1d2018-11-27 21:49:19 +01005572 * ---- | -----
Camilla Löwy798d7c62017-03-01 23:27:20 +01005573 * `GLFW_HAT_CENTERED` | 0
5574 * `GLFW_HAT_UP` | 1
5575 * `GLFW_HAT_RIGHT` | 2
5576 * `GLFW_HAT_DOWN` | 4
5577 * `GLFW_HAT_LEFT` | 8
5578 * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
5579 * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
5580 * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
5581 * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
IntellectualKitty368dec72016-11-25 20:56:24 -07005582 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005583 * The diagonal directions are bitwise combinations of the primary (up, right,
5584 * down and left) directions and you can test for these individually by ANDing
5585 * it with the corresponding direction.
IntellectualKitty368dec72016-11-25 20:56:24 -07005586 *
Camilla Löwy798d7c62017-03-01 23:27:20 +01005587 * @code
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00005588 * if (hats[2] & GLFW_HAT_RIGHT)
5589 * {
5590 * // State of hat 2 could be right-up, right or right-down
5591 * }
Camilla Löwy798d7c62017-03-01 23:27:20 +01005592 * @endcode
IntellectualKitty368dec72016-11-25 20:56:24 -07005593 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005594 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005595 * but will not generate an error. This can be used instead of first calling
5596 * @ref glfwJoystickPresent.
IntellectualKitty368dec72016-11-25 20:56:24 -07005597 *
5598 * @param[in] jid The [joystick](@ref joysticks) to query.
5599 * @param[out] count Where to store the number of hat states in the returned
5600 * array. This is set to zero if the joystick is not present or an error
5601 * occurred.
5602 * @return An array of hat states, or `NULL` if the joystick is not present
5603 * or an [error](@ref error_handling) occurred.
5604 *
5605 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5606 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5607 *
IntellectualKitty368dec72016-11-25 20:56:24 -07005608 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
5609 * should not free it yourself. It is valid until the specified joystick is
5610 * disconnected, this function is called again for that joystick or the library
5611 * is terminated.
5612 *
5613 * @thread_safety This function must only be called from the main thread.
5614 *
5615 * @sa @ref joystick_hat
5616 *
5617 * @since Added in version 3.3.
5618 *
5619 * @ingroup input
5620 */
5621GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
5622
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01005623/*! @brief Returns the name of the specified joystick.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005624 *
5625 * This function returns the name, encoded as UTF-8, of the specified joystick.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005626 * The returned string is allocated and freed by GLFW. You should not free it
5627 * yourself.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005628 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005629 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005630 * but will not generate an error. This can be used instead of first calling
5631 * @ref glfwJoystickPresent.
Camilla Berglund386b6032016-02-10 13:48:49 +01005632 *
Camilla Berglundefc6b352016-10-10 03:24:07 +02005633 * @param[in] jid The [joystick](@ref joysticks) to query.
Camilla Berglund71d2b572013-03-12 15:33:05 +01005634 * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
Camilla Berglund999f3552016-08-17 16:48:22 +02005635 * is not present or an [error](@ref error_handling) occurred.
Camilla Berglundd4a08b12012-12-02 17:13:41 +01005636 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005637 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5638 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5639 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005640 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5641 * should not free it yourself. It is valid until the specified joystick is
Camilla Löwy68014782017-02-01 04:36:38 +01005642 * disconnected or the library is terminated.
Camilla Berglund0e205772014-03-24 11:58:35 +01005643 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005644 * @thread_safety This function must only be called from the main thread.
Camilla Berglundc3bb5c92013-06-05 16:04:04 +02005645 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005646 * @sa @ref joystick_name
Camilla Berglund4591ad22014-09-18 15:03:29 +02005647 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005648 * @since Added in version 3.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005649 *
5650 * @ingroup input
Camilla Berglund7d9b5c02012-12-02 16:55:09 +01005651 */
Camilla Berglundefc6b352016-10-10 03:24:07 +02005652GLFWAPI const char* glfwGetJoystickName(int jid);
Camilla Berglund3249f812010-09-07 17:34:51 +02005653
luz.paz7105ff22019-08-12 06:52:31 -04005654/*! @brief Returns the SDL compatible GUID of the specified joystick.
Camilla Löwy5b7281b2017-07-23 16:34:11 +02005655 *
5656 * This function returns the SDL compatible GUID, as a UTF-8 encoded
5657 * hexadecimal string, of the specified joystick. The returned string is
5658 * allocated and freed by GLFW. You should not free it yourself.
5659 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005660 * The GUID is what connects a joystick to a gamepad mapping. A connected
5661 * joystick will always have a GUID even if there is no gamepad mapping
5662 * assigned to it.
5663 *
Camilla Löwy5b7281b2017-07-23 16:34:11 +02005664 * If the specified joystick is not present this function will return `NULL`
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005665 * but will not generate an error. This can be used instead of first calling
5666 * @ref glfwJoystickPresent.
Camilla Löwy5b7281b2017-07-23 16:34:11 +02005667 *
5668 * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
5669 * uniquely identify the make and model of a joystick but does not identify
5670 * a specific unit, e.g. all wired Xbox 360 controllers will have the same
5671 * GUID on that platform. The GUID for a unit may vary between platforms
5672 * depending on what hardware information the platform specific APIs provide.
5673 *
5674 * @param[in] jid The [joystick](@ref joysticks) to query.
5675 * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
5676 * is not present or an [error](@ref error_handling) occurred.
5677 *
5678 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5679 * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
5680 *
5681 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5682 * should not free it yourself. It is valid until the specified joystick is
5683 * disconnected or the library is terminated.
5684 *
5685 * @thread_safety This function must only be called from the main thread.
5686 *
5687 * @sa @ref gamepad
5688 *
5689 * @since Added in version 3.3.
5690 *
5691 * @ingroup input
5692 */
5693GLFWAPI const char* glfwGetJoystickGUID(int jid);
5694
Camilla Löwy7c2c7852017-12-07 16:19:57 +01005695/*! @brief Sets the user pointer of the specified joystick.
5696 *
5697 * This function sets the user-defined pointer of the specified joystick. The
5698 * current value is retained until the joystick is disconnected. The initial
5699 * value is `NULL`.
5700 *
5701 * This function may be called from the joystick callback, even for a joystick
5702 * that is being disconnected.
5703 *
Camilla Löwyd222a402018-02-25 20:37:31 +01005704 * @param[in] jid The joystick whose pointer to set.
Camilla Löwy7c2c7852017-12-07 16:19:57 +01005705 * @param[in] pointer The new value.
5706 *
5707 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5708 *
5709 * @thread_safety This function may be called from any thread. Access is not
5710 * synchronized.
5711 *
5712 * @sa @ref joystick_userptr
5713 * @sa @ref glfwGetJoystickUserPointer
5714 *
5715 * @since Added in version 3.3.
5716 *
5717 * @ingroup input
5718 */
5719GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
5720
5721/*! @brief Returns the user pointer of the specified joystick.
5722 *
5723 * This function returns the current value of the user-defined pointer of the
5724 * specified joystick. The initial value is `NULL`.
5725 *
5726 * This function may be called from the joystick callback, even for a joystick
5727 * that is being disconnected.
5728 *
Camilla Löwyd222a402018-02-25 20:37:31 +01005729 * @param[in] jid The joystick whose pointer to return.
Camilla Löwy7c2c7852017-12-07 16:19:57 +01005730 *
5731 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5732 *
5733 * @thread_safety This function may be called from any thread. Access is not
5734 * synchronized.
5735 *
5736 * @sa @ref joystick_userptr
5737 * @sa @ref glfwSetJoystickUserPointer
5738 *
5739 * @since Added in version 3.3.
5740 *
5741 * @ingroup input
5742 */
5743GLFWAPI void* glfwGetJoystickUserPointer(int jid);
5744
Camilla Löwy953106e2017-06-18 15:13:25 +02005745/*! @brief Returns whether the specified joystick has a gamepad mapping.
5746 *
5747 * This function returns whether the specified joystick is both present and has
5748 * a gamepad mapping.
5749 *
5750 * If the specified joystick is present but does not have a gamepad mapping
5751 * this function will return `GLFW_FALSE` but will not generate an error. Call
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005752 * @ref glfwJoystickPresent to check if a joystick is present regardless of
5753 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02005754 *
5755 * @param[in] jid The [joystick](@ref joysticks) to query.
5756 * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
5757 * or `GLFW_FALSE` otherwise.
5758 *
5759 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5760 * GLFW_INVALID_ENUM.
5761 *
5762 * @thread_safety This function must only be called from the main thread.
5763 *
5764 * @sa @ref gamepad
5765 * @sa @ref glfwGetGamepadState
5766 *
5767 * @since Added in version 3.3.
5768 *
5769 * @ingroup input
5770 */
5771GLFWAPI int glfwJoystickIsGamepad(int jid);
5772
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005773/*! @brief Sets the joystick configuration callback.
5774 *
5775 * This function sets the joystick configuration callback, or removes the
5776 * currently set callback. This is called when a joystick is connected to or
5777 * disconnected from the system.
5778 *
Camilla Löwya46c95c2017-02-01 04:55:46 +01005779 * For joystick connection and disconnection events to be delivered on all
5780 * platforms, you need to call one of the [event processing](@ref events)
5781 * functions. Joystick disconnection may also be detected and the callback
5782 * called by joystick functions. The function will then return whatever it
Camilla Löwy953106e2017-06-18 15:13:25 +02005783 * returns if the joystick is not present.
Camilla Löwya46c95c2017-02-01 04:55:46 +01005784 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005785 * @param[in] callback The new callback, or `NULL` to remove the currently set
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005786 * callback.
5787 * @return The previously set callback, or `NULL` if no callback was set or the
5788 * library had not been [initialized](@ref intro_init).
5789 *
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005790 * @callback_signature
5791 * @code
5792 * void function_name(int jid, int event)
5793 * @endcode
5794 * For more information about the callback parameters, see the
5795 * [function pointer type](@ref GLFWjoystickfun).
5796 *
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005797 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5798 *
5799 * @thread_safety This function must only be called from the main thread.
5800 *
5801 * @sa @ref joystick_event
5802 *
5803 * @since Added in version 3.2.
5804 *
5805 * @ingroup input
5806 */
Camilla Löwy51bb76c2019-05-24 01:52:49 +02005807GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
Camilla Berglund8a7fa302015-12-13 17:38:50 +01005808
Camilla Löwy953106e2017-06-18 15:13:25 +02005809/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
5810 *
5811 * This function parses the specified ASCII encoded string and updates the
5812 * internal list with any gamepad mappings it finds. This string may
5813 * contain either a single gamepad mapping or many mappings separated by
5814 * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
5815 * source file including empty lines and comments.
5816 *
5817 * See @ref gamepad_mapping for a description of the format.
5818 *
5819 * If there is already a gamepad mapping for a given GUID in the internal list,
5820 * it will be replaced by the one passed to this function. If the library is
5821 * terminated and re-initialized the internal list will revert to the built-in
5822 * default.
5823 *
5824 * @param[in] string The string containing the gamepad mappings.
5825 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
5826 * [error](@ref error_handling) occurred.
5827 *
5828 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5829 * GLFW_INVALID_VALUE.
5830 *
5831 * @thread_safety This function must only be called from the main thread.
5832 *
5833 * @sa @ref gamepad
5834 * @sa @ref glfwJoystickIsGamepad
5835 * @sa @ref glfwGetGamepadName
5836 *
5837 * @since Added in version 3.3.
5838 *
5839 * @ingroup input
5840 */
5841GLFWAPI int glfwUpdateGamepadMappings(const char* string);
5842
5843/*! @brief Returns the human-readable gamepad name for the specified joystick.
5844 *
5845 * This function returns the human-readable name of the gamepad from the
5846 * gamepad mapping assigned to the specified joystick.
5847 *
5848 * If the specified joystick is not present or does not have a gamepad mapping
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005849 * this function will return `NULL` but will not generate an error. Call
5850 * @ref glfwJoystickPresent to check whether it is present regardless of
5851 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02005852 *
5853 * @param[in] jid The [joystick](@ref joysticks) to query.
5854 * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
5855 * joystick is not present, does not have a mapping or an
5856 * [error](@ref error_handling) occurred.
5857 *
InKryptionc19f36b2021-12-05 17:51:43 +01005858 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
5859 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005860 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5861 * should not free it yourself. It is valid until the specified joystick is
5862 * disconnected, the gamepad mappings are updated or the library is terminated.
5863 *
5864 * @thread_safety This function must only be called from the main thread.
5865 *
5866 * @sa @ref gamepad
5867 * @sa @ref glfwJoystickIsGamepad
5868 *
5869 * @since Added in version 3.3.
5870 *
5871 * @ingroup input
5872 */
5873GLFWAPI const char* glfwGetGamepadName(int jid);
5874
5875/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
5876 *
luz.paz7105ff22019-08-12 06:52:31 -04005877 * This function retrieves the state of the specified joystick remapped to
Camilla Löwy953106e2017-06-18 15:13:25 +02005878 * an Xbox-like gamepad.
5879 *
Camilla Löwy5bc1c382017-08-04 01:00:36 +02005880 * If the specified joystick is not present or does not have a gamepad mapping
5881 * this function will return `GLFW_FALSE` but will not generate an error. Call
5882 * @ref glfwJoystickPresent to check whether it is present regardless of
5883 * whether it has a mapping.
Camilla Löwy953106e2017-06-18 15:13:25 +02005884 *
5885 * The Guide button may not be available for input as it is often hooked by the
5886 * system or the Steam client.
5887 *
5888 * Not all devices have all the buttons or axes provided by @ref
5889 * GLFWgamepadstate. Unavailable buttons and axes will always report
Camilla Löwy34d20b02018-03-03 22:24:26 +01005890 * `GLFW_RELEASE` and 0.0 respectively.
Camilla Löwy953106e2017-06-18 15:13:25 +02005891 *
5892 * @param[in] jid The [joystick](@ref joysticks) to query.
5893 * @param[out] state The gamepad input state of the joystick.
5894 * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
5895 * connected, it has no gamepad mapping or an [error](@ref error_handling)
5896 * occurred.
5897 *
5898 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5899 * GLFW_INVALID_ENUM.
5900 *
Camilla Löwye1495c02018-08-09 13:57:10 +02005901 * @thread_safety This function must only be called from the main thread.
5902 *
Camilla Löwy953106e2017-06-18 15:13:25 +02005903 * @sa @ref gamepad
5904 * @sa @ref glfwUpdateGamepadMappings
5905 * @sa @ref glfwJoystickIsGamepad
5906 *
5907 * @since Added in version 3.3.
5908 *
5909 * @ingroup input
5910 */
5911GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
5912
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005913/*! @brief Sets the clipboard to the specified string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005914 *
5915 * This function sets the system clipboard to the specified, UTF-8 encoded
Camilla Berglund4591ad22014-09-18 15:03:29 +02005916 * string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005917 *
Camilla Löwy31cbb202017-11-04 21:11:58 +01005918 * @param[in] window Deprecated. Any valid window or `NULL`.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005919 * @param[in] string A UTF-8 encoded string.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005920 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005921 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
5922 * GLFW_PLATFORM_ERROR.
5923 *
Camilla Löwy29885c62020-01-17 03:25:54 +01005924 * @remark @win32 The clipboard on Windows has a single global lock for reading and
5925 * writing. GLFW tries to acquire it a few times, which is almost always enough. If it
5926 * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
5927 * It is safe to try this multiple times.
5928 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005929 * @pointer_lifetime The specified string is copied before this function
5930 * returns.
Camilla Berglunda3ff29a2012-12-02 15:47:10 +01005931 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005932 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005933 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005934 * @sa @ref clipboard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005935 * @sa @ref glfwGetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005936 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005937 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005938 *
Camilla Berglund8d170c72014-09-09 16:26:57 +02005939 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005940 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005941GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005942
Camilla Berglund4591ad22014-09-18 15:03:29 +02005943/*! @brief Returns the contents of the clipboard as a string.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005944 *
5945 * This function returns the contents of the system clipboard, if it contains
Camilla Berglundcf9079c2015-09-16 18:51:49 +02005946 * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
Camilla Berglund0b650532015-09-16 16:27:28 +02005947 * if its contents cannot be converted, `NULL` is returned and a @ref
5948 * GLFW_FORMAT_UNAVAILABLE error is generated.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005949 *
Camilla Löwy31cbb202017-11-04 21:11:58 +01005950 * @param[in] window Deprecated. Any valid window or `NULL`.
Camilla Berglund71d2b572013-03-12 15:33:05 +01005951 * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
Camilla Berglund4591ad22014-09-18 15:03:29 +02005952 * if an [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005953 *
InKryptionbb193322021-11-22 23:32:29 +00005954 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
5955 * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
Camilla Berglundf51cf812016-02-05 00:51:40 +01005956 *
Camilla Löwy29885c62020-01-17 03:25:54 +01005957 * @remark @win32 The clipboard on Windows has a single global lock for reading and
5958 * writing. GLFW tries to acquire it a few times, which is almost always enough. If it
5959 * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
5960 * It is safe to try this multiple times.
5961 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005962 * @pointer_lifetime The returned string is allocated and freed by GLFW. You
5963 * should not free it yourself. It is valid until the next call to @ref
Camilla Berglund6be821c2014-10-06 23:18:33 +02005964 * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
5965 * is terminated.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005966 *
Camilla Berglund951a9582016-01-31 21:32:14 +01005967 * @thread_safety This function must only be called from the main thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005968 *
Camilla Berglund4188c262015-01-18 01:55:25 +01005969 * @sa @ref clipboard
Camilla Berglund7e9e3212016-09-14 20:17:26 +02005970 * @sa @ref glfwSetClipboardString
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005971 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01005972 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02005973 *
Camilla Berglund8d170c72014-09-09 16:26:57 +02005974 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005975 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01005976GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
Ralph Eastwood31c91542011-09-21 10:09:47 +01005977
Camilla Löwybb6945a2019-05-20 17:13:09 +02005978/*! @brief Returns the GLFW time.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005979 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02005980 * This function returns the current GLFW time, in seconds. Unless the time
5981 * has been set using @ref glfwSetTime it measures time elapsed since GLFW was
5982 * initialized.
5983 *
5984 * This function and @ref glfwSetTime are helper functions on top of @ref
5985 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01005986 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02005987 * The resolution of the timer is system dependent, but is usually on the order
5988 * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
Camilla Löwy56a4cb02021-07-13 21:50:09 +02005989 * time source on each operating system.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005990 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02005991 * @return The current time, in seconds, or zero if an
Camilla Berglund4591ad22014-09-18 15:03:29 +02005992 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005993 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01005994 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
5995 *
Camilla Berglund20bce152016-05-30 16:04:37 +02005996 * @thread_safety This function may be called from any thread. Reading and
Camilla Löwybb6945a2019-05-20 17:13:09 +02005997 * writing of the internal base time is not atomic, so it needs to be
Camilla Berglund20bce152016-05-30 16:04:37 +02005998 * externally synchronized with calls to @ref glfwSetTime.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01005999 *
Camilla Berglund4188c262015-01-18 01:55:25 +01006000 * @sa @ref time
Camilla Berglund4591ad22014-09-18 15:03:29 +02006001 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006002 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006003 *
6004 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006005 */
Camilla Berglund9a716692010-09-08 16:40:43 +02006006GLFWAPI double glfwGetTime(void);
Camilla Berglund3249f812010-09-07 17:34:51 +02006007
Camilla Löwybb6945a2019-05-20 17:13:09 +02006008/*! @brief Sets the GLFW time.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006009 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02006010 * This function sets the current GLFW time, in seconds. The value must be
6011 * a positive finite number less than or equal to 18446744073.0, which is
6012 * approximately 584.5 years.
6013 *
6014 * This function and @ref glfwGetTime are helper functions on top of @ref
6015 * glfwGetTimerFrequency and @ref glfwGetTimerValue.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006016 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006017 * @param[in] time The new value, in seconds.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006018 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006019 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6020 * GLFW_INVALID_VALUE.
6021 *
Camilla Löwybb6945a2019-05-20 17:13:09 +02006022 * @remark The upper limit of GLFW time is calculated as
Camilla Berglund6e20cda2015-03-10 12:01:38 +01006023 * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
6024 * storing nanoseconds in 64 bits. The limit may be increased in the future.
6025 *
Camilla Berglund20bce152016-05-30 16:04:37 +02006026 * @thread_safety This function may be called from any thread. Reading and
Camilla Löwybb6945a2019-05-20 17:13:09 +02006027 * writing of the internal base time is not atomic, so it needs to be
Camilla Berglund20bce152016-05-30 16:04:37 +02006028 * externally synchronized with calls to @ref glfwGetTime.
Camilla Berglund0e205772014-03-24 11:58:35 +01006029 *
Camilla Berglund4188c262015-01-18 01:55:25 +01006030 * @sa @ref time
Camilla Berglunde248fb62013-03-29 14:06:23 +01006031 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006032 * @since Added in version 2.2.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006033 *
6034 * @ingroup input
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006035 */
6036GLFWAPI void glfwSetTime(double time);
6037
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006038/*! @brief Returns the current value of the raw timer.
6039 *
Camilla Berglund337c77a2016-03-06 14:11:14 +01006040 * This function returns the current value of the raw timer, measured in
6041 * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
6042 * glfwGetTimerFrequency.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006043 *
Emmanuel Gil Peyrotc3cba582017-11-17 03:34:18 +00006044 * @return The value of the timer, or zero if an
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006045 * [error](@ref error_handling) occurred.
6046 *
Camilla Berglund46fce402016-03-07 13:35:37 +01006047 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006048 *
6049 * @thread_safety This function may be called from any thread.
6050 *
6051 * @sa @ref time
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006052 * @sa @ref glfwGetTimerFrequency
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006053 *
6054 * @since Added in version 3.2.
6055 *
6056 * @ingroup input
6057 */
Camilla Berglund5661d032016-03-23 10:09:07 +01006058GLFWAPI uint64_t glfwGetTimerValue(void);
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006059
6060/*! @brief Returns the frequency, in Hz, of the raw timer.
6061 *
Camilla Berglunddefaea32016-03-07 13:36:54 +01006062 * This function returns the frequency, in Hz, of the raw timer.
6063 *
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006064 * @return The frequency of the timer, in Hz, or zero if an
6065 * [error](@ref error_handling) occurred.
6066 *
Camilla Berglund46fce402016-03-07 13:35:37 +01006067 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006068 *
6069 * @thread_safety This function may be called from any thread.
6070 *
6071 * @sa @ref time
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006072 * @sa @ref glfwGetTimerValue
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006073 *
6074 * @since Added in version 3.2.
6075 *
6076 * @ingroup input
6077 */
Camilla Berglund5661d032016-03-23 10:09:07 +01006078GLFWAPI uint64_t glfwGetTimerFrequency(void);
Camilla Berglund31f67dd2016-03-06 11:38:55 +01006079
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006080/*! @brief Makes the context of the specified window current for the calling
6081 * thread.
6082 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006083 * This function makes the OpenGL or OpenGL ES context of the specified window
Camilla Löwy3f315192023-12-03 17:40:42 +01006084 * current on the calling thread. It can also detach the current context from
6085 * the calling thread without making a new one current by passing in `NULL`.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006086 *
Camilla Löwy3f315192023-12-03 17:40:42 +01006087 * A context must only be made current on a single thread at a time and each
6088 * thread can have only a single current context at a time. Making a context
6089 * current detaches any previously current context on the calling thread.
6090 *
6091 * When moving a context between threads, you must detach it (make it
6092 * non-current) on the old thread before making it current on the new one.
Camilla Löwyf2756d02017-11-02 19:30:12 +01006093 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006094 * By default, making a context non-current implicitly forces a pipeline flush.
6095 * On machines that support `GL_KHR_context_flush_control`, you can control
6096 * whether a context performs this flush by setting the
Camilla Löwyce161c22016-12-06 01:14:23 +01006097 * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
6098 * hint.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006099 *
Camilla Berglund98b478f2015-11-05 13:44:15 +01006100 * The specified window must have an OpenGL or OpenGL ES context. Specifying
6101 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
6102 * error.
6103 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01006104 * @param[in] window The window whose context to make current, or `NULL` to
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006105 * detach the current context.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006106 *
Camilla Löwy3f315192023-12-03 17:40:42 +01006107 * @remarks If the previously current context was created via a different
6108 * context creation API than the one passed to this function, GLFW will still
6109 * detach the previous one from its API before making the new one current.
6110 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006111 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6112 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6113 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006114 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006115 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006116 * @sa @ref context_current
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006117 * @sa @ref glfwGetCurrentContext
Camilla Berglunde248fb62013-03-29 14:06:23 +01006118 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006119 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006120 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01006121 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006122 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01006123GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006124
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006125/*! @brief Returns the window whose context is current on the calling thread.
6126 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006127 * This function returns the window whose OpenGL or OpenGL ES context is
6128 * current on the calling thread.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006129 *
Camilla Berglund71d2b572013-03-12 15:33:05 +01006130 * @return The window whose context is current, or `NULL` if no window's
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006131 * context is current.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006132 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006133 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
6134 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006135 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006136 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006137 * @sa @ref context_current
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006138 * @sa @ref glfwMakeContextCurrent
Camilla Berglunde248fb62013-03-29 14:06:23 +01006139 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006140 * @since Added in version 3.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006141 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01006142 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006143 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01006144GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006145
6146/*! @brief Swaps the front and back buffers of the specified window.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006147 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006148 * This function swaps the front and back buffers of the specified window when
6149 * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
6150 * zero, the GPU driver waits the specified number of screen updates before
6151 * swapping the buffers.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006152 *
Camilla Berglund98b478f2015-11-05 13:44:15 +01006153 * The specified window must have an OpenGL or OpenGL ES context. Specifying
6154 * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
6155 * error.
6156 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006157 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6158 * see `vkQueuePresentKHR` instead.
6159 *
Camilla Berglund9492fc52013-01-17 17:51:12 +01006160 * @param[in] window The window whose buffers to swap.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006161 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006162 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6163 * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6164 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006165 * @remark __EGL:__ The context of the specified window must be current on the
Camilla Berglund276b1bc2016-01-31 19:17:18 +01006166 * calling thread.
6167 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006168 * @thread_safety This function may be called from any thread.
Camilla Berglund401033c2013-03-12 19:17:07 +01006169 *
Camilla Berglund4188c262015-01-18 01:55:25 +01006170 * @sa @ref buffer_swap
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006171 * @sa @ref glfwSwapInterval
Camilla Berglunde248fb62013-03-29 14:06:23 +01006172 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006173 * @since Added in version 1.0.
Camilla Berglund951a9582016-01-31 21:32:14 +01006174 * @glfw3 Added window handle parameter.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006175 *
6176 * @ingroup window
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006177 */
Camilla Berglund9af960e2013-01-05 21:13:28 +01006178GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006179
6180/*! @brief Sets the swap interval for the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006181 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006182 * This function sets the swap interval for the current OpenGL or OpenGL ES
6183 * context, i.e. the number of screen updates to wait from the time @ref
6184 * glfwSwapBuffers was called before swapping the buffers and returning. This
6185 * is sometimes called _vertical synchronization_, _vertical retrace
6186 * synchronization_ or just _vsync_.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006187 *
Camilla Löwy8094a1c2017-11-27 15:53:59 +01006188 * A context that supports either of the `WGL_EXT_swap_control_tear` and
Camilla Löwybfe2d422017-11-27 01:18:51 +01006189 * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
6190 * intervals, which allows the driver to swap immediately even if a frame
6191 * arrives a little bit late. You can check for these extensions with @ref
6192 * glfwExtensionSupported.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02006193 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006194 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01006195 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006196 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006197 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6198 * see the present mode of your swapchain instead.
6199 *
Camilla Berglund5fd409b2013-06-05 17:53:13 +02006200 * @param[in] interval The minimum number of screen updates to wait for
6201 * until the buffers are swapped by @ref glfwSwapBuffers.
6202 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006203 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6204 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6205 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006206 * @remark This function is not called during context creation, leaving the
Camilla Löwy56a4cb02021-07-13 21:50:09 +02006207 * swap interval set to whatever is the default for that API. This is done
Camilla Berglund3af1c412013-09-19 21:37:01 +02006208 * because some swap interval extensions used by GLFW do not allow the swap
6209 * interval to be reset to zero once it has been set to a non-zero value.
6210 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006211 * @remark Some GPU drivers do not honor the requested swap interval, either
Camilla Berglund11c22d62015-02-19 15:33:51 +01006212 * because of a user setting that overrides the application's request or due to
6213 * bugs in the driver.
Camilla Berglund8282a8f2013-04-10 23:01:12 +02006214 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006215 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006216 *
Camilla Berglund4188c262015-01-18 01:55:25 +01006217 * @sa @ref buffer_swap
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006218 * @sa @ref glfwSwapBuffers
Camilla Berglunde248fb62013-03-29 14:06:23 +01006219 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006220 * @since Added in version 1.0.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006221 *
Camilla Berglunde248fb62013-03-29 14:06:23 +01006222 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006223 */
6224GLFWAPI void glfwSwapInterval(int interval);
6225
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006226/*! @brief Returns whether the specified extension is available.
6227 *
Camilla Berglund608109c2013-04-11 20:18:46 +02006228 * This function returns whether the specified
Camilla Berglund001c50c2016-02-19 09:13:56 +01006229 * [API extension](@ref context_glext) is supported by the current OpenGL or
6230 * OpenGL ES context. It searches both for client API extension and context
6231 * creation API extensions.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006232 *
6233 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01006234 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006235 *
6236 * As this functions retrieves and searches one or more extension strings each
6237 * call, it is recommended that you cache its results if it is going to be used
6238 * frequently. The extension strings will not change during the lifetime of
6239 * a context, so there is no danger in doing this.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006240 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006241 * This function does not apply to Vulkan. If you are using Vulkan, see @ref
6242 * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
6243 * and `vkEnumerateDeviceExtensionProperties` instead.
6244 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006245 * @param[in] extension The ASCII encoded name of the extension.
Camilla Berglund0eccf752015-08-23 19:30:04 +02006246 * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
6247 * otherwise.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006248 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006249 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6250 * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
6251 * GLFW_PLATFORM_ERROR.
6252 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006253 * @thread_safety This function may be called from any thread.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006254 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006255 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006256 * @sa @ref glfwGetProcAddress
Camilla Berglund4591ad22014-09-18 15:03:29 +02006257 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006258 * @since Added in version 1.0.
Camilla Berglunde248fb62013-03-29 14:06:23 +01006259 *
6260 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006261 */
6262GLFWAPI int glfwExtensionSupported(const char* extension);
6263
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006264/*! @brief Returns the address of the specified function for the current
6265 * context.
6266 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006267 * This function returns the address of the specified OpenGL or OpenGL ES
Camilla Berglund11c22d62015-02-19 15:33:51 +01006268 * [core or extension function](@ref context_glext), if it is supported
Camilla Berglund1f5f20e2013-05-27 17:10:34 +02006269 * by the current context.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006270 *
Camilla Berglund4591ad22014-09-18 15:03:29 +02006271 * A context must be current on the calling thread. Calling this function
Camilla Berglundce8f97c2015-01-11 23:33:14 +01006272 * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006273 *
Camilla Berglund001c50c2016-02-19 09:13:56 +01006274 * This function does not apply to Vulkan. If you are rendering with Vulkan,
6275 * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
6276 * `vkGetDeviceProcAddr` instead.
6277 *
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006278 * @param[in] procname The ASCII encoded name of the function.
Camilla Berglunda36e3a22015-11-05 17:14:26 +01006279 * @return The address of the function, or `NULL` if an
6280 * [error](@ref error_handling) occurred.
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006281 *
Camilla Berglundf51cf812016-02-05 00:51:40 +01006282 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6283 * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
6284 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006285 * @remark The address of a given function is not guaranteed to be the same
Camilla Berglund4591ad22014-09-18 15:03:29 +02006286 * between contexts.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006287 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006288 * @remark This function may return a non-`NULL` address despite the
Camilla Berglund11c22d62015-02-19 15:33:51 +01006289 * associated version or extension not being available. Always check the
Camilla Berglundc8e06872015-08-27 21:40:22 +02006290 * context version or extension string first.
Camilla Berglund11c22d62015-02-19 15:33:51 +01006291 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006292 * @pointer_lifetime The returned function pointer is valid until the context
6293 * is destroyed or the library is terminated.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006294 *
Camilla Berglund951a9582016-01-31 21:32:14 +01006295 * @thread_safety This function may be called from any thread.
Camilla Berglund4591ad22014-09-18 15:03:29 +02006296 *
6297 * @sa @ref context_glext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006298 * @sa @ref glfwExtensionSupported
Camilla Berglund4591ad22014-09-18 15:03:29 +02006299 *
Camilla Berglund832c2ff2016-01-31 22:35:11 +01006300 * @since Added in version 1.0.
Camilla Berglund2d5fb772013-03-18 19:11:02 +01006301 *
6302 * @ingroup context
Camilla Berglundbce2cd62012-11-22 16:38:24 +01006303 */
Camilla Berglundbf42c3c2012-06-05 00:16:40 +02006304GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
Camilla Berglund3249f812010-09-07 17:34:51 +02006305
Camilla Löwy98bdd362017-02-07 20:56:48 +01006306/*! @brief Returns whether the Vulkan loader and an ICD have been found.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006307 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01006308 * This function returns whether the Vulkan loader and any minimally functional
6309 * ICD have been found.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006310 *
Camilla Löwy4be04442021-10-12 12:54:19 +02006311 * The availability of a Vulkan loader and even an ICD does not by itself guarantee that
6312 * surface creation or even instance creation is possible. Call @ref
6313 * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
6314 * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
6315 * check whether a queue family of a physical device supports image presentation.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006316 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01006317 * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
6318 * otherwise.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006319 *
6320 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
6321 *
6322 * @thread_safety This function may be called from any thread.
6323 *
6324 * @sa @ref vulkan_support
6325 *
6326 * @since Added in version 3.2.
6327 *
6328 * @ingroup vulkan
6329 */
6330GLFWAPI int glfwVulkanSupported(void);
6331
6332/*! @brief Returns the Vulkan instance extensions required by GLFW.
6333 *
6334 * This function returns an array of names of Vulkan instance extensions required
6335 * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
Lukas Zanner84b13112019-06-14 12:53:57 +02006336 * list will always contain `VK_KHR_surface`, so if you don't require any
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006337 * additional extensions you can pass this list directly to the
6338 * `VkInstanceCreateInfo` struct.
6339 *
6340 * If Vulkan is not available on the machine, this function returns `NULL` and
6341 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01006342 * to check whether Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006343 *
6344 * If Vulkan is available but no set of extensions allowing window surface
6345 * creation was found, this function returns `NULL`. You may still use Vulkan
6346 * for off-screen rendering and compute work.
6347 *
6348 * @param[out] count Where to store the number of extensions in the returned
6349 * array. This is set to zero if an error occurred.
6350 * @return An array of ASCII encoded extension names, or `NULL` if an
6351 * [error](@ref error_handling) occurred.
6352 *
6353 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6354 * GLFW_API_UNAVAILABLE.
6355 *
Camilla Berglund67931bd2016-10-26 16:58:56 +02006356 * @remark Additional extensions may be required by future versions of GLFW.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006357 * You should check if any extensions you wish to enable are already in the
6358 * returned array, as it is an error to specify an extension more than once in
6359 * the `VkInstanceCreateInfo` struct.
6360 *
6361 * @pointer_lifetime The returned array is allocated and freed by GLFW. You
6362 * should not free it yourself. It is guaranteed to be valid only until the
6363 * library is terminated.
6364 *
6365 * @thread_safety This function may be called from any thread.
6366 *
6367 * @sa @ref vulkan_ext
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006368 * @sa @ref glfwCreateWindowSurface
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006369 *
6370 * @since Added in version 3.2.
6371 *
6372 * @ingroup vulkan
6373 */
Camilla Berglund7ab7d8b2016-03-23 10:24:01 +01006374GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006375
6376#if defined(VK_VERSION_1_0)
6377
6378/*! @brief Returns the address of the specified Vulkan instance function.
6379 *
6380 * This function returns the address of the specified Vulkan core or extension
6381 * function for the specified instance. If instance is set to `NULL` it can
6382 * return any function exported from the Vulkan loader, including at least the
6383 * following functions:
6384 *
6385 * - `vkEnumerateInstanceExtensionProperties`
6386 * - `vkEnumerateInstanceLayerProperties`
6387 * - `vkCreateInstance`
6388 * - `vkGetInstanceProcAddr`
6389 *
6390 * If Vulkan is not available on the machine, this function returns `NULL` and
6391 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01006392 * to check whether Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006393 *
6394 * This function is equivalent to calling `vkGetInstanceProcAddr` with
6395 * a platform-specific query of the Vulkan loader as a fallback.
6396 *
6397 * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
6398 * functions related to instance creation.
6399 * @param[in] procname The ASCII encoded name of the function.
6400 * @return The address of the function, or `NULL` if an
6401 * [error](@ref error_handling) occurred.
6402 *
6403 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
6404 * GLFW_API_UNAVAILABLE.
6405 *
6406 * @pointer_lifetime The returned function pointer is valid until the library
6407 * is terminated.
6408 *
6409 * @thread_safety This function may be called from any thread.
6410 *
6411 * @sa @ref vulkan_proc
6412 *
6413 * @since Added in version 3.2.
6414 *
6415 * @ingroup vulkan
6416 */
6417GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
6418
6419/*! @brief Returns whether the specified queue family can present images.
6420 *
6421 * This function returns whether the specified queue family of the specified
6422 * physical device supports presentation to the platform GLFW was built for.
6423 *
6424 * If Vulkan or the required window surface creation instance extensions are
6425 * not available on the machine, or if the specified instance was not created
6426 * with the required extensions, this function returns `GLFW_FALSE` and
6427 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
Camilla Löwy98bdd362017-02-07 20:56:48 +01006428 * to check whether Vulkan is at least minimally available and @ref
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006429 * glfwGetRequiredInstanceExtensions to check what instance extensions are
6430 * required.
6431 *
6432 * @param[in] instance The instance that the physical device belongs to.
6433 * @param[in] device The physical device that the queue family belongs to.
6434 * @param[in] queuefamily The index of the queue family to query.
6435 * @return `GLFW_TRUE` if the queue family supports presentation, or
6436 * `GLFW_FALSE` otherwise.
6437 *
6438 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
6439 * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
6440 *
Camilla Berglunde94d1662016-10-14 01:46:56 +02006441 * @remark @macos This function currently always returns `GLFW_TRUE`, as the
Camilla Löwy4c90e212020-12-10 00:28:09 +01006442 * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
Camilla Berglunde94d1662016-10-14 01:46:56 +02006443 * a `vkGetPhysicalDevice*PresentationSupport` type function.
6444 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006445 * @thread_safety This function may be called from any thread. For
6446 * synchronization details of Vulkan objects, see the Vulkan specification.
6447 *
6448 * @sa @ref vulkan_present
6449 *
6450 * @since Added in version 3.2.
6451 *
6452 * @ingroup vulkan
6453 */
6454GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
6455
6456/*! @brief Creates a Vulkan surface for the specified window.
6457 *
6458 * This function creates a Vulkan surface for the specified window.
6459 *
Camilla Löwy98bdd362017-02-07 20:56:48 +01006460 * If the Vulkan loader or at least one minimally functional ICD were not found,
6461 * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
6462 * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
6463 * Vulkan is at least minimally available.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006464 *
6465 * If the required window surface creation instance extensions are not
6466 * available or if the specified instance was not created with these extensions
6467 * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
6468 * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
6469 * glfwGetRequiredInstanceExtensions to check what instance extensions are
6470 * required.
6471 *
Corentin Wallez8a8eefa2018-01-30 13:25:17 -05006472 * The window surface cannot be shared with another API so the window must
6473 * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
6474 * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
6475 * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
6476 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006477 * The window surface must be destroyed before the specified Vulkan instance.
6478 * It is the responsibility of the caller to destroy the window surface. GLFW
6479 * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
6480 * surface.
6481 *
6482 * @param[in] instance The Vulkan instance to create the surface in.
6483 * @param[in] window The window to create the surface for.
6484 * @param[in] allocator The allocator to use, or `NULL` to use the default
6485 * allocator.
6486 * @param[out] surface Where to store the handle of the surface. This is set
6487 * to `VK_NULL_HANDLE` if an error occurred.
6488 * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
6489 * [error](@ref error_handling) occurred.
6490 *
6491 * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
Corentin Wallez8a8eefa2018-01-30 13:25:17 -05006492 * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006493 *
Camilla Berglund67931bd2016-10-26 16:58:56 +02006494 * @remark If an error occurs before the creation call is made, GLFW returns
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006495 * the Vulkan error code most appropriate for the error. Appropriate use of
6496 * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
Camilla Berglundee33dcd2016-03-07 14:42:51 +01006497 * eliminate almost all occurrences of these errors.
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006498 *
Camilla Löwy05b0e2f2021-12-26 18:02:00 +01006499 * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
6500 * `VK_MVK_macos_surface` extension as a fallback. The name of the selected
6501 * extension, if any, is included in the array returned by @ref
6502 * glfwGetRequiredInstanceExtensions.
Camilla Berglunde94d1662016-10-14 01:46:56 +02006503 *
6504 * @remark @macos This function creates and sets a `CAMetalLayer` instance for
6505 * the window content view, which is required for MoltenVK to function.
6506 *
Camilla Löwy05b0e2f2021-12-26 18:02:00 +01006507 * @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension,
6508 * with the `VK_KHR_xlib_surface` extension as a fallback. You can make
6509 * `VK_KHR_xlib_surface` the preferred extension by setting the
Camilla Löwya25e8eb2020-12-10 00:11:44 +01006510 * [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
Camilla Löwy05b0e2f2021-12-26 18:02:00 +01006511 * hint. The name of the selected extension, if any, is included in the array
6512 * returned by @ref glfwGetRequiredInstanceExtensions.
Camilla Löwya25e8eb2020-12-10 00:11:44 +01006513 *
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006514 * @thread_safety This function may be called from any thread. For
6515 * synchronization details of Vulkan objects, see the Vulkan specification.
6516 *
6517 * @sa @ref vulkan_surface
Camilla Berglund7e9e3212016-09-14 20:17:26 +02006518 * @sa @ref glfwGetRequiredInstanceExtensions
Camilla Berglund9b75bff2015-08-10 20:19:04 +02006519 *
6520 * @since Added in version 3.2.
6521 *
6522 * @ingroup vulkan
6523 */
6524GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
6525
6526#endif /*VK_VERSION_1_0*/
6527
Camilla Berglund3249f812010-09-07 17:34:51 +02006528
Camilla Berglund4afc67c2011-07-27 17:09:17 +02006529/*************************************************************************
6530 * Global definition cleanup
6531 *************************************************************************/
6532
6533/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
6534
Camilla Berglund4afc67c2011-07-27 17:09:17 +02006535#ifdef GLFW_WINGDIAPI_DEFINED
6536 #undef WINGDIAPI
6537 #undef GLFW_WINGDIAPI_DEFINED
6538#endif
6539
6540#ifdef GLFW_CALLBACK_DEFINED
6541 #undef CALLBACK
6542 #undef GLFW_CALLBACK_DEFINED
6543#endif
6544
Camilla Löwybe51c202017-07-03 14:25:47 +02006545/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
6546 * defined by some gl.h variants (OpenBSD) so define it after if needed.
6547 */
6548#ifndef GLAPIENTRY
6549 #define GLAPIENTRY APIENTRY
Camilla Löwyce85c7d2022-05-03 19:54:08 +02006550 #define GLFW_GLAPIENTRY_DEFINED
Camilla Löwybe51c202017-07-03 14:25:47 +02006551#endif
6552
Camilla Berglund4afc67c2011-07-27 17:09:17 +02006553/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
6554
6555
Camilla Berglund3249f812010-09-07 17:34:51 +02006556#ifdef __cplusplus
6557}
6558#endif
6559
Camilla Berglundf8df91d2013-01-15 01:59:56 +01006560#endif /* _glfw3_h_ */
Camilla Berglund3249f812010-09-07 17:34:51 +02006561