It's a bit involved as we need to ensure that gl.Context.current doesn't
outline the Application instance, so we need to:
- remember the Application object when it gets constructed (and clear
it again when it gets destructed)
- in gl.Context.current check if there's an active Application (which
means sharing data across two different Python modules, and even
though pybind11 docs suggest to "simply export a symbol", this
*cannot* possibly work in practice; instead we share data using a
Python capsule), and increase its refcount when returning the Context
instance
- decrease the Application refcount again when the Context gets
destructed
Pybind changed py::module to py::module_ in order to support C++
modules, adapting to that change. It still builds on older versions,
but we're using only the new APIs.
That makes it much easier to handle in that case (because that's the
whole point of static builds) and also nicely circumvents any issues
with duplicated global data when a static lib would be linked to
multiple dynamic libraries.
Only the double ones, exposed as floats, because the extra ALU required
by doubles is negligible to function call overhead. It'll be different
for non-scalar types, but here I use this.