gitmyhub

glad

C ★ 4.5k updated 9d ago

Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs.

A code generator that produces the boilerplate C or C++ setup needed to call OpenGL, Vulkan, and related graphics API functions, eliminating the tedious manual address-lookup code.

CC++PythonCMakesetup: easycomplexity 3/5

GLAD is a tool that generates the setup code you need before you can use OpenGL (or related graphics APIs like Vulkan, GLES, EGL, GLX, and WGL) in a C or C++ program. OpenGL works differently from most libraries: the graphics functions you want to call are not available directly at compile time. Instead, your program has to ask the operating system for the address of each function at runtime. Writing that address-lookup code by hand is tedious and error-prone, so GLAD does it for you.

You give GLAD your target API (OpenGL, Vulkan, etc.) and the version and extensions you want to support, and it produces a small set of C source files you drop into your project. Including the generated header and calling a single load function at startup is all that is needed. After that, you write normal OpenGL calls as if they were ordinary functions.

The easiest way to use GLAD is through the web generator at glad.dav1d.de, where you pick options in a browser and download the files directly, no installation required. If you prefer to run it locally, you can install it via pip (the Python package manager) or through the vcpkg package manager on Windows.

A newer version called GLAD 2 is available on a separate branch and a separate website (glad.sh). It adds Vulkan support, Rust support, better CMake integration, and other improvements. The original version remains supported for existing projects, and there is no forced migration.

The generated code is dedicated to the public domain (or CC0 / WTFPL, your choice), so you can include it in any project, open source or commercial, without license complications. The spec files that GLAD reads from the Khronos Group carry Apache 2.0 licenses, but the generated output itself is free of restrictions. A debug build variant is also available that wraps every OpenGL call with before-and-after callbacks, making it straightforward to catch errors from any API call automatically.

Where it fits