OpenGL Interface Implementation
See OpenGL Interface for details on the publically-visible modules.
See ctypes Wrapper Generation for details on some of these modules are generated.
Most functions link to libGL.so (Linux), opengl32.dll (Windows) or
OpenGL.framework (OS X).
pyglet.gl.lib provides some helper types then
imports linker functions for the appropriate platform: one of
On any platform, the following steps are taken to link each function during import:
Look in the appropriate library (e.g. libGL.so, opengl32.dll, etc.) using
If not found, call
glxGetProcAddressto try to resolve the function’s address dynamically. On OS X, skip this step.
On Windows, this will fail if the context hasn’t been created yet. Create and return a proxy object
WGLFunctionProxywhich will try the same resolution again when the object is
The proxy object caches its result so that subsequent calls have only a single extra function-call overhead.
If the function is still not found (either during import or proxy call), the function is replaced with
pyglet.gl.lib), which raises an exception. The exception message details the name of the function, and optionally the name of the extension or OpenGL version it requires.
We currently include all functions and enums from OpenGL 4.6 in separate modules.
gl.gexposes the core api and
gl_compat.pyexposes the compatibility profile (no deprecation).
What extensions are included can be found in
To access the linking function, import
pyglet.gl.lib and use one of
is what the generated modules do.
Missing extensions can be added to the
extensions list in