diff --git a/src/python/magnum/platform/egl.cpp b/src/python/magnum/platform/egl.cpp index b8dac5a..a90e74d 100644 --- a/src/python/magnum/platform/egl.cpp +++ b/src/python/magnum/platform/egl.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "magnum/bootstrap.h" #include "magnum/platform/windowlessapplication.h" @@ -68,6 +69,13 @@ void egl(py::module_& m) { py::class_> windowlessEglApplication{m, "WindowlessApplication", "Windowless EGL application"}; windowlessapplication(windowlessEglApplication); + + /* Exposing a subclass to avoid the same type being exposed in multiple + (glx, egl...) modules. */ + struct PyContext: Platform::GLContext {}; + py::class_ glContext{m, "Context", "EGL-specific Magnum OpenGL context"}; + + context(glContext); } }} diff --git a/src/python/magnum/platform/glx.cpp b/src/python/magnum/platform/glx.cpp index 554ed85..902733e 100644 --- a/src/python/magnum/platform/glx.cpp +++ b/src/python/magnum/platform/glx.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "magnum/bootstrap.h" #include "magnum/platform/windowlessapplication.h" @@ -68,6 +69,13 @@ void glx(py::module_& m) { py::class_> windowlessGlxApplication{m, "WindowlessApplication", "Windowless GLX application"}; windowlessapplication(windowlessGlxApplication); + + /* Exposing a subclass to avoid the same type being exposed in multiple + (glx, egl...) modules. */ + struct PyContext: Platform::GLContext {}; + py::class_ glContext{m, "Context", "GLX-specific Magnum OpenGL context"}; + + context(glContext); } }} diff --git a/src/python/magnum/platform/wgl.cpp b/src/python/magnum/platform/wgl.cpp index 63ec318..f19a8d8 100644 --- a/src/python/magnum/platform/wgl.cpp +++ b/src/python/magnum/platform/wgl.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "magnum/bootstrap.h" #include "magnum/platform/windowlessapplication.h" @@ -68,6 +69,13 @@ void wgl(py::module_& m) { py::class_> windowlessWglApplication{m, "WindowlessApplication", "Windowless WGL application"}; windowlessapplication(windowlessWglApplication); + + /* Exposing a subclass to avoid the same type being exposed in multiple + (glx, egl...) modules. */ + struct PyContext: Platform::GLContext {}; + py::class_ glContext{m, "Context", "WGL-specific Magnum OpenGL context"}; + + context(glContext); } }} diff --git a/src/python/magnum/platform/windowlessapplication.h b/src/python/magnum/platform/windowlessapplication.h index 8bc9208..2e9afb5 100644 --- a/src/python/magnum/platform/windowlessapplication.h +++ b/src/python/magnum/platform/windowlessapplication.h @@ -46,4 +46,11 @@ template void windowlessapplication(py::class_ ; } +template void context(py::class_& c) { + c + .def(py::init()) + /** @todo delayed creation */ + ; +} + }}