Skip to content

Extending Glad

Dav1dde edited this page May 2, 2018 · 1 revision

Extending Glad

Glad supports a basic plugin API using setuptools entry points.

Currently two entry points are supported:

  1. Specification
  2. Language

Glad uses these entrpoints as well and exposes builtin language backends and specifications this way. See setup.py for examples.

Specification

To add additional specifications extend the glad.specifications entry point with a glad.parse.Specification class, usually inheriting from glad.parse.Specification and overriding the glad.parse.Specification.DISPLAY_NAME, glad.parse.Specification.API and glad.parse.Specification.NAME static variables is enough.

E.g. the OpenGL specification:

class GL(Specification):
    DISPLAY_NAME = 'OpenGL'

    API = 'https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/'
    NAME = 'gl'

Language

Add a generator class to the glad.language entry point to add an additional language.

A language is (for now) just a generator which accepts a feautre set and turns it into code. The builtin glad.language.generator.BaseGenerator uses Jinja2 to generate code.

Clone this wiki locally