PyOpenGL 4.0.0a5 -- Significant Changes

So now we're starting to cash in on the various changes we've made to PyOpenGL, namely dropping Python 2.7 support and adding the more extensive test suite. The effect of those is that we can create a table-driven dispatch accelerator in OpenGL_accelerate. In plain terms, write a C module that provides the core OpenGL API as a raw CPython extension module. That dispatch system also paves the way for eventually properly handling multiple contexts in an application that use different OpenGL implementations, though we haven't landed the ctypes implementation for that yet (and the OpenGL_accelerate cython modules still disable free threading on loading).

For those who have been using PyOpenGL for the last 28 years or so, you'll recognise that we started with a C-coded extension module, and this is almost us returning to the original wrapping approach, having rewritten in SWIG, and then ctypes in the meantime. However, we are still writing the core using ctypes, and PyPy will still use ctypes as the implementation. The C module here is an accelerator that gets imported to override the ctypes versions to reduce per-call overhead.

The new accelerator gives approximately a 5 percent uplift on OpenGLContext games/demos. That is pretty weak sauce, but the real win will be for systems that are not as aggressively optimised as OpenGLContext. If you're doing lots of calls to OpenGL entry points the effect should be greater. It's still not a great idea to do lots of calls in Python, but this should obviate some of the badness.

Error checking is also made more efficient on platforms that support the KHR_debug extension. The non GL submodules also now have their own Error classes that get raised and they don't call glGetError any more (which was always wrong).

The rewrite also gives us type annotations (pyi files), and a more formal approach to the generation and wrapping of entry points. The auto-generated wrapper code now includes the vast majority of the annotation code that was previously sitting in the higher-level python wrapper modules. The ctypes implementation now uses that same set of annotations to automatically wrap the entry points, so the amount of hand-coding drops significantly.

The test suite is pretty significantly extended and cleaned up. PyOpenGL has far more comprehensive test coverage with a matrix that now tests far more broadly across the various settings that we support. That suite now runs in CI for Ubuntu, Windows and OS-X using off-screen rendering libraries for that support.

We have a new (still experimental) TK OpenGL widget implementation that supports both Core and Compatibility contexts on EGL/GLX/WGL, that's then wrapped in OpenGLContext to eventually make TK a first-class backend. Will hopefully find someone who can port to AGL/CGL for OS-X before the final release of 4.0.0.

We've also got PyInstaller hooks distributed with the library.

This is still an alpha release, as there's a bunch more work needed to release the whole tree of modules, and we may still hit errors in the core as we do so, but the major pieces I wanted to complete for the 4.0 release are mostly in place.

Comments

No comments yet.

Pingbacks

Pingbacks are closed.

Post your comment