A Python generator for the Khronos APIs OpenGL, OpenGL ES, OpenGL SC, and EGL
Switch branches/tags
Nothing to show
Clone or download


KHR Binding C++ Generator


  1. Load XML from Khronos repository
  2. Generate C++ API binding from XML

Preconfigured Profiles

Currently available profiles for loading and generating (in subdirectory profiles):

  • gl.json for the OpenGL API (results are deployed in glbinding)
  • gles.json for the OpenGL ES API (results are deployed in glesbinding)
  • glsc.json for the OpenGL SC API (results are deployed in glscbinding)
  • egl.json for the EGL API (results are deployed in eglbinding)


Load XML from Khronos repository

python3 scripts/update.py -p profiles/gl.json

Generate C++ API binding from XML

python3 scripts/generate.py -p profiles/gl.json -d glbinding

Profile Documentation

A profile file is a JSON file with a flat layout, although semantic groups are intended. The currently supported tags are:

  • API specification
    • sourceUrl: The url to download the API specification
    • sourceFile: The intermediate file name to store the API specification
    • patchFile: A local file for patching the downloaded specification (optional)
    • apiIdentifier: For multi-API specification files, specifies the one API to select
  • Code Generation
    • bindingNamespace: The identifier for the subdirectories and C++ binding namespace
    • baseNamespace: The C++ namespace for the generated API
    • coreProfileSince: The version of core profile introduction (e.g., 3.2 for OpenGL)
    • multiContext: Set to true if the API supports multiple contexts
    • booleanWidth: The width of a boolean in this API (may be either 8 or 32)

More options are subject to future development. Ideas and requirements are welcomed.

Example profile gl.json

  "": "API specification",
  "apiIdentifier": "gl",
  "sourceUrl": "https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/gl.xml",
  "sourceFile": "gl.xml",
  "patchFile": "glpatch.xml",

  "": "Code Generation",
  "bindingNamespace": "glbinding",
  "baseNamespace": "gl",
  "coreProfileSince": "3.2",
  "multiContext": true,
  "booleanWidth": 8


  • Python (either 2.7 or 3)
    • pystache