GLFW
Introduction
GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc.
GLFW natively supports Windows, macOS and Linux and other Unix-like systems. Experimental implementations for the Wayland protocol and the Mir display server are available but not yet officially supported.
GLFW is licensed under the zlib/libpng license.
The latest stable release is version 3.2.1.
See the downloads page for details and
files, or fetch the latest
branch, which always points to the latest stable
release. Each release starting with 3.0 also has a corresponding annotated
tag with source and binary archives.
The version history lists all user-visible
changes for every release.
This is a development branch for version 3.3, which is not yet described. Pre-release documentation is available here.
The master
branch is the stable integration branch and should always compile
and run on all supported platforms, although details of newly added features may
change until they have been included in a release. New features and many bug
fixes live in other branches until
they are stable enough to merge.
If you are new to GLFW, you may find the tutorial for GLFW 3 useful. If you have used GLFW 2 in the past, there is a transition guide for moving to the GLFW 3 API.
Compiling GLFW
GLFW itself requires only the headers and libraries for your window system. It does not need the headers for any context creation API (WGL, GLX, EGL, NSGL, OSMesa) or rendering API (OpenGL, OpenGL ES, Vulkan) to enable support for them.
GLFW supports compilation on Windows with Visual C++ 2010 and later, MinGW and MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC and Clang. It will likely compile in other environments as well, but this is not regularly tested.
There are pre-compiled Windows binaries available for all supported compilers.
See the compilation guide for more information about how to compile GLFW yourself.
Using GLFW
See the documentation for tutorials, guides and the API reference.
Contributing to GLFW
See the contribution guide for more information.
System requirements
GLFW supports Windows XP and later and macOS 10.7 and later. Linux and other Unix-like systems running the X Window System are supported even without a desktop environment or modern extensions, although some features require a running window or clipboard manager. The OSMesa backend requires Mesa 6.3.
See the compatibility guide in the documentation for more information.
Dependencies
GLFW itself depends only on the headers and libraries for your window system.
The (experimental) Wayland backend also depends on the extra-cmake-modules
package, which is used to generated Wayland protocol headers.
The examples and test programs depend on a number of tiny libraries. These are
located in the deps/
directory.
- getopt_port for examples with command-line options
- TinyCThread for threaded examples
- An OpenGL 3.2 core loader generated by glad for examples using modern OpenGL
- linmath.h for linear algebra in examples
- Nuklear for test and example UI
- stb_image_write for writing images to disk
- Vulkan headers for Vulkan tests
The Vulkan example additionally requires the LunarG Vulkan SDK to be installed, or it will not be included in the build. On macOS you need to provide the path to the SDK manually as it has no standard installation location.
The documentation is generated with Doxygen if CMake can find that tool.
Reporting bugs
Bugs are reported to our issue tracker. Please check the contribution guide for information on what to include when reporting a bug.
Changelog
- Added
glfwGetError
function for querying the last error code and its description (#970) - Added
glfwUpdateGamepadMappings
function for importing gamepad mappings in SDL_GameControllerDB format (#900) - Added
glfwJoystickIsGamepad
function for querying whether a joystick has a gamepad mapping (#900) - Added
glfwGetJoystickGUID
function for querying the SDL compatible GUID of a joystick (#900) - Added
glfwGetGamepadName
function for querying the name provided by the gamepad mapping (#900) - Added
glfwGetGamepadState
function,GLFW_GAMEPAD_*
andGLFWgamepadstate
for retrieving gamepad input state (#900) - Added
glfwGetWindowContentScale
,glfwGetMonitorContentScale
andglfwSetWindowContentScaleCallback
for DPI-aware rendering (#235,#439,#677,#845,#898) - Added
glfwRequestWindowAttention
function for requesting attention from the user (#732,#988) - Added
glfwGetKeyScancode
function that allows retrieving platform dependent scancodes for keys (#830) - Added
glfwSetWindowMaximizeCallback
andGLFWwindowmaximizefun
for receiving window maximization events (#778) - Added
glfwSetWindowAttrib
function for changing window attributes (#537) - Added
glfwGetJoystickHats
function for querying joystick hats (#889,#906,#934) - Added
glfwInitHint
for setting initialization hints - Added
glfwWindowHintString
for setting string type window hints (#893,#1139) - Added
glfwGetWindowOpacity
andglfwSetWindowOpacity
for controlling whole window transparency (#1089) - Added
glfwSetMonitorUserPointer
andglfwGetMonitorUserPointer
for per-monitor user pointers - Added
glfwSetJoystickUserPointer
andglfwGetJoystickUserPointer
for per-joystick user pointers - Added
glfwGetX11SelectionString
andglfwSetX11SelectionString
functions for accessing X11 primary selection (#894,#1056) - Added headless OSMesa backend (#850)
- Added definition of
GLAPIENTRY
to public header - Added
GLFW_TRANSPARENT_FRAMEBUFFER
window hint and attribute for controlling per-pixel framebuffer transparency (#197,#663,#715,#723,#1078) - Added
GLFW_HOVERED
window attribute for polling cursor hover state (#1166) - Added
GLFW_CENTER_CURSOR
window hint for controlling cursor centering (#749,#842) - Added
GLFW_JOYSTICK_HAT_BUTTONS
init hint (#889) - Added
GLFW_LOCK_KEY_MODS
input mode andGLFW_MOD_*_LOCK
mod bits (#946) - Added macOS specific
GLFW_COCOA_RETINA_FRAMEBUFFER
window hint - Added macOS specific
GLFW_COCOA_FRAME_NAME
window hint (#195) - Added macOS specific
GLFW_COCOA_GRAPHICS_SWITCHING
window hint (#377,#935) - Added macOS specific
GLFW_COCOA_CHDIR_RESOURCES
init hint - Added macOS specific
GLFW_COCOA_MENUBAR
init hint - Added X11 specific `GLFW_X11_