Library / SDK
glfw/glfw avatar
glfw/glfw

GLFW: the C windowing layer under OpenGL, OpenGL ES and Vulkan apps

A multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input

15,369 stars5,936 forksCZlib

At a glance

What is it?
GLFW is a small C99 library that creates windows, contexts and input for graphics applications without dragging in a UI toolkit. It is aimed at engine and tool authors who want one API across Windows, macOS, Linux, Wayland and X11, and it is best judged on what it deliberately refuses to do.
Who is it for?
Adopt GLFW if you are writing a renderer, engine or graphics tool in C or C++ and want window, context and input handling without a widget toolkit attached. Do not adopt it if you expect it to draw user interface controls, manage a scene graph, or provide a software fallback when no GPU context can be created; GLFW creates the surface and stops there.
Can I use it commercially?
Yes. Zlib is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 56 days ago.
What is it written in?
Mainly C, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What GLFW takes off your plate, and what it leaves on it

Every graphics application needs the same unglamorous plumbing: a window that the operating system recognises, a rendering context bound to it, a surface for Vulkan, a stream of key and cursor events, and a way to ask what time it is. GLFW supplies exactly that surface and nothing above it. The README describes it as "a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc."

The audience follows from that scope. If you are writing a game engine, a CAD viewer, a simulation front end or a rendering research tool in C or C++, GLFW is the layer you put between your renderer and the platform. If you are writing a desktop application with menus, text fields and dialogs, the absence of a widget layer is not a gap you can ignore; you will be pairing GLFW with something else or choosing a different foundation entirely. The library is written primarily in C99, with parts of the macOS support in Objective-C, which matters if you care about linking a C library into a C++ codebase without a runtime boundary in the way.

One API over Win32, Cocoa, Wayland and X11

GLFW's mechanism is a platform-independent front end over per-platform backends. You call the same functions regardless of target; the implementation behind them talks to Win32 on Windows, Cocoa on macOS, and either Wayland or X11 on Linux. That is why the repository's src/ tree is the interesting part and why the include/ headers are the only thing your build needs to see.

The practical consequence is that platform behaviour differences do not disappear, they relocate. The README states that on GNOME Wayland, window decorations will be very basic unless the libdecor package is installed. It also notes that X11 systems are supported even without a desktop environment or modern extensions, though some features require a clipboard manager or a modern window manager. So the promise is one API, not one experience. If you ship on Linux, you are effectively shipping against two window systems with different capability sets, and the compatibility guide is where those differences are catalogued.

The repository layout reinforces how self-contained the project intends to be. The examples and test programs depend on small bundled libraries in deps/: getopt_port, TinyCThread, glad2, linmath.h, Nuklear and stb_image_write. The README states plainly that the repository has no submodules. Documentation is generated with Doxygen when the library is built, provided CMake found a sufficiently new version during configuration.

Getting GLFW and building the bundled examples

The README says GLFW itself needs only CMake and the headers and libraries for your operating system and window system, and that no other SDKs are required. Pre-compiled binaries exist for Windows and macOS, but building from source is the normal path on Linux. The README points to the compilation guide for the exact dependencies required for each window system, and to the download page for the latest stable release as source or Windows and macOS binaries. There are release tags with source and binary archives attached for every version since 3.0.

The repository's top level holds CMakeLists.txt and a CMake/ directory, which is the entry point the compilation guide describes. The examples and test programs are built from examples/ and tests/, and the small libraries they need are bundled in deps/ rather than fetched as submodules, which the README states explicitly. The public headers live in include/, and the platform implementations in src/. If you want to see what a minimal program looks like before writing your own, the bundled examples include examples/triangle-opengl.c, examples/triangle-opengles.c, examples/offscreen.c and examples/windows.c.

The tutorial in the HTML documentation walks through window creation, context setup and the event loop. That tutorial, not this article, is the reference for the exact call sequence, since the API surface changes between releases. Two branch rules from the README matter when you pick a revision: master is the stable integration branch that should always compile and run on all supported platforms, and the ci branch should never be relied on for any purpose.

The failure mode is the missing context, not the missing window

The sharpest limitation is structural. GLFW creates windows, contexts and surfaces, and the README's description stops there. It does not provide a software renderer, a fallback drawing path, or any abstraction over the graphics API you have chosen. If context creation fails because the driver is absent, the machine is headless, or the requested version is unsupported, there is no rendering path left. Your application must detect that and decide what to do, and the library will not decide for you.

The second constraint is platform reach. The README states support for Windows 7 and later and macOS 10.11 and later, and notes that other C99 compilers will likely work but are not regularly tested. That last clause is worth reading twice: the officially exercised compilers are Visual C++ 2013 and later, GCC and Clang, including Clang-CL and MinGW-w64. If your toolchain sits outside that set, you are on your own.

There is also a branch-hygiene trap. The README says the master branch is the stable integration branch and should always compile and run on all supported platforms, but also that details of a newly added feature, including the public API, may change until it has been included in a release. Tracking master in a shipping product means accepting API drift between releases.

GLFW versus SDL, and why the comparison is about scope

The obvious alternative is SDL, and the difference is not quality but boundary. SDL is a broader multimedia layer: it also covers audio, game controllers, threads and file I/O, and it ships a 2D rendering API on top of the platform graphics. GLFW's README describes a narrower contract, windows, contexts, surfaces, input and events, and the project does not attempt the rest.

That makes the choice concrete. If your application needs audio output and controller support in the same dependency, SDL gives you one library to integrate. If you already have an audio stack, a controller abstraction and a renderer, adding SDL means carrying code you will not call. GLFW's smaller surface is the point: fewer subsystems to configure, fewer platform behaviours to reason about when something breaks.

The other comparison people reach for is GLFW against the raw platform APIs, Win32, Cocoa and the X11 or Wayland protocols directly. That path gives you access to platform features GLFW does not expose, at the cost of writing and maintaining three backends. GLFW's value is that the backend work is already done and the API is uniform; its cost is that anything outside the uniform API is out of reach.

Maintenance, releases and what the zlib licence permits

The last push to the repository was on 2026-08-04, and the most recent release listed is 3.5.1 from 2026-07-31. The preceding releases, 3.4 and 3.3.10, both date from February 2024, so the gap between 3.4 and 3.5.1 was roughly two and a half years. That cadence is worth planning around: if you need a fix in the library itself rather than in your code, the wait between releases can be long, and the README's own changelog section for the period since 3.5 reads "None." Pinning to a release tag and reading its release notes is more predictable than following master.

On licensing, the README states GLFW is licensed under the zlib/libpng license, and the repository carries LICENSE.md at the top level. The zlib licence is a permissive licence, which in practice means the usual obligations around attribution and notice retention apply to redistributed source and binaries. That is a description of the licence family, not legal advice; read LICENSE.md and the license page on glfw.org for the actual terms before you ship.

The upgrade path is source-level. Because GLFW is compiled into your application rather than installed as a system service, moving from one release to the next means rebuilding against the new headers and resolving any API changes the release notes list. The version history on glfw.org records every user-visible change per release, which is the document to diff against when you bump the dependency.

Editorial conclusion

Adopt GLFW if you are writing a renderer, engine or graphics tool in C or C++ and want window, context and input handling without a widget toolkit attached. Do not adopt it if you expect it to draw user interface controls, manage a scene graph, or provide a software fallback when no GPU context can be created; GLFW creates the surface and stops there. Before committing, check the compatibility guide for the window systems you actually ship on, confirm whether libdecor is present on your GNOME Wayland targets, and read the release notes for the version you pin, because the README states that details of a newly added feature, including the public API, may change until it has been included in a release.

Frequently asked questions

Can you use GLFW without OpenGL?

Yes. The README describes GLFW as a library for OpenGL, OpenGL ES and Vulkan application development, and it handles windows, contexts, surfaces, input and events. The repository also includes examples/offscreen.c, which shows a windowless usage path in the bundled examples. What GLFW does not provide is any rendering of its own, so you still supply the graphics API.

What is the purpose of OpenGL?

This question is about OpenGL, not about GLFW, and the available documentation does not describe OpenGL's purpose. GLFW's README only places OpenGL among the APIs it supports for application development, alongside OpenGL ES and Vulkan.

Is OpenGL a C++ library?

This question concerns OpenGL rather than GLFW. The only related fact available is about GLFW itself: it is written primarily in C99, with parts of the macOS support written in Objective-C.

Can I use GLFW on Linux?

Yes. The README states that GLFW supports Windows, macOS and Linux, and also works on many other Unix-like systems, with both Wayland and X11 supported on Linux. On GNOME Wayland, window decorations will be very basic unless the libdecor package is installed.

Official sources

  1. glfw/glfw on GitHub
  2. License: Zlib
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/glfw-glfw.svg)](https://hysenlabs.com/projects/glfw-glfw)