This is the reference documentation for initialization and termination of the library, version management and error handling. For more task-oriented information, see the Introduction to the API.
|Joystick hat buttons init hint.
|macOS specific init hint.
|macOS specific init hint.
|Wayland specific init hint.
|GLFWerrorfun) (int error_code, const char *description)
|The function pointer type for error callbacks.
|Initializes the GLFW library.
|Terminates the GLFW library.
|glfwInitHint (int hint, int value)
|Sets the specified init hint to the desired value.
|glfwGetVersion (int *major, int *minor, int *rev)
|Retrieves the version of the GLFW library.
|const char *
|Returns a string describing the compile-time configuration.
|glfwGetError (const char **description)
|Returns and clears the last error for the calling thread.
|glfwSetErrorCallback (GLFWerrorfun callback)
|Sets the error callback.
|#define GLFW_VERSION_MAJOR 3
The major version number of the GLFW header. This is incremented when the API is changed in non-compatible ways.
|#define GLFW_VERSION_MINOR 3
The minor version number of the GLFW header. This is incremented when features are added to the API but it remains backward-compatible.
|#define GLFW_VERSION_REVISION 10
The revision number of the GLFW header. This is incremented when a bug fix release is made that does not contain any API changes.
|#define GLFW_TRUE 1
This is only semantic sugar for the number 1. You can instead use
VK_TRUE or anything else that is equal to one.
|#define GLFW_FALSE 0
This is only semantic sugar for the number 0. You can instead use
VK_FALSE or anything else that is equal to zero.
|#define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
Joystick hat buttons init hint.
|#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
macOS specific init hint.
|#define GLFW_COCOA_MENUBAR 0x00051002
macOS specific init hint.
|#define GLFW_WAYLAND_LIBDECOR 0x00053001
Wayland specific init hint.
|typedef void(* GLFWerrorfun) (int error_code, const char *description)
This is the function pointer type for error callbacks. An error callback function has the following signature:
|An error code. Future releases may add more error codes.
|A UTF-8 encoded string describing the error.
This function initializes the GLFW library. Before most GLFW functions can be used, GLFW must be initialized, and before an application terminates GLFW should be terminated in order to free any resources allocated during or after initialization.
Additional calls to this function after successful initialization but before termination will return
GLFW_TRUE if successful, or
GLFW_FALSE if an error occurred.
Contents/Resources subdirectory of the application's bundle, if present. This can be disabled with the GLFW_COCOA_CHDIR_RESOURCES init hint.
LC_CTYPE category of the application locale according to the current environment if that category is still "C". This is because the "C" locale breaks Unicode text input.
This function destroys all remaining windows and cursors, restores any modified gamma ramps and frees any other allocated resources. Once this function is called, you must again call glfwInit successfully before you will be able to use most GLFW functions.
If GLFW has been successfully initialized, this function should be called before the application exits. If initialization fails, there is no need to call this function, as it is called by glfwInit before it returns failure.
This function has no effect if GLFW is not initialized.
This function sets hints for the next initialization of GLFW.
The values you set hints to are never reset by GLFW, but they only take effect during initialization. Once GLFW has been initialized, any values you set will be ignored until the library is terminated and initialized again.
Some hints are platform specific. These may be set on any platform but they will only affect their specific platform. Other platforms will ignore them. Setting these hints requires no platform specific headers or functions.
|The init hint to set.
|The new value of the init hint.
This function retrieves the major, minor and revision numbers of the GLFW library. It is intended for when you are using GLFW as a shared library and want to ensure that you are using the minimum required version.
Any or all of the version arguments may be
|Where to store the major version number, or
|Where to store the minor version number, or
|Where to store the revision number, or
|const char * glfwGetVersionString
This function returns the compile-time generated version string of the GLFW library binary. It describes the version, platform, compiler and any platform-specific compile-time options. It should not be confused with the OpenGL or OpenGL ES version string, queried with
Do not use the version string to parse the GLFW library version. The glfwGetVersion function provides the version of the running library binary in numerical format.
|const char **
This function returns and clears the error code of the last error that occurred on the calling thread, and optionally a UTF-8 encoded human-readable description of it. If no error has occurred since the last call, it returns GLFW_NO_ERROR (zero) and the description pointer is set to
|Where to store the error description pointer, or
This function sets the error callback, which is called with an error code and a human-readable description each time a GLFW error occurs.
The error code is set before the callback is called. Calling glfwGetError from the error callback will return the same value as the error code argument.
The error callback is called on the thread where the error occurred. If you are using GLFW from multiple threads, your error callback needs to be written accordingly.
Because the description string may have been generated specifically for that error, it is not guaranteed to be valid after the callback has returned. If you wish to use it after the callback returns, you need to make a copy.
Once set, the error callback remains set even after the library has been terminated.
|The new callback, or
NULL to remove the currently set callback.
NULL if no callback was set.
Last update on Wed Feb 21 2024 for GLFW 3.3.10