explaingit

dav1dde/glad

4,508CAudience · developerComplexity · 3/5LicenseSetup · easy

TLDR

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.

Mindmap

mindmap
  root((GLAD))
    What it does
      Generate loader code
      OpenGL setup
      API function loading
    Supported APIs
      OpenGL
      Vulkan
      GLES EGL
    Tech stack
      C
      C++
      Python
      CMake
    Use cases
      Graphics apps
      Game engines
      Debug builds
    Getting started
      Web generator
      pip install
      vcpkg
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate the OpenGL loader code for a C++ graphics project so you can call OpenGL functions without manual function-pointer setup.

USE CASE 2

Set up Vulkan in a new C project using GLAD 2's generated headers and a single initialization call at startup.

USE CASE 3

Add a debug build of OpenGL that wraps every API call with automatic error-checking callbacks to catch mistakes easily.

Tech stack

CC++PythonCMake

Getting it running

Difficulty · easy Time to first run · 5min

Easiest path is the web generator, pick your options, download the files, drop them into your project, and call the load function.

Generated code is public domain (CC0 or WTFPL, your choice), use it in any project, open source or commercial, with no restrictions.

In plain English

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.

Copy-paste prompts

Prompt 1
I want to use OpenGL 4.6 in a C++ project. Walk me through using GLAD to generate the loader code and integrate it with GLFW.
Prompt 2
How do I use the GLAD web generator at glad.dav1d.de to download OpenGL 3.3 core profile loader files for a new C project?
Prompt 3
Set up GLAD 2 with CMake in a C++ project that uses both Vulkan and OpenGL.
Prompt 4
How do I enable GLAD's debug build mode so I get automatic error checking after every OpenGL API call?
Open on GitHub → Explain another repo

← dav1dde on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.