Browse Source

python: expose Platform::GLContext as platform.{egl,wgl,glx}.Context.

Turning the link-time decision to a runtime decision. Crazily enough
this seems to work with no duplicate symbol issues (apart from having
to expose a function-local subclass).
pull/11/head
Vladimír Vondruš 5 years ago
parent
commit
a2d16c15f8
  1. 8
      src/python/magnum/platform/egl.cpp
  2. 8
      src/python/magnum/platform/glx.cpp
  3. 8
      src/python/magnum/platform/wgl.cpp
  4. 7
      src/python/magnum/platform/windowlessapplication.h

8
src/python/magnum/platform/egl.cpp

@ -25,6 +25,7 @@
#include <pybind11/pybind11.h>
#include <Magnum/Platform/WindowlessEglApplication.h>
#include <Magnum/Platform/GLContext.h>
#include "magnum/bootstrap.h"
#include "magnum/platform/windowlessapplication.h"
@ -68,6 +69,13 @@ void egl(py::module_& m) {
py::class_<PyWindowlessApplication, ApplicationHolder<PyWindowlessApplication>> 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_<PyContext> glContext{m, "Context", "EGL-specific Magnum OpenGL context"};
context(glContext);
}
}}

8
src/python/magnum/platform/glx.cpp

@ -25,6 +25,7 @@
#include <pybind11/pybind11.h>
#include <Magnum/Platform/WindowlessGlxApplication.h>
#include <Magnum/Platform/GLContext.h>
#include "magnum/bootstrap.h"
#include "magnum/platform/windowlessapplication.h"
@ -68,6 +69,13 @@ void glx(py::module_& m) {
py::class_<PyWindowlessApplication, ApplicationHolder<PyWindowlessApplication>> 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_<PyContext> glContext{m, "Context", "GLX-specific Magnum OpenGL context"};
context(glContext);
}
}}

8
src/python/magnum/platform/wgl.cpp

@ -25,6 +25,7 @@
#include <pybind11/pybind11.h>
#include <Magnum/Platform/WindowlessWglApplication.h>
#include <Magnum/Platform/GLContext.h>
#include "magnum/bootstrap.h"
#include "magnum/platform/windowlessapplication.h"
@ -68,6 +69,13 @@ void wgl(py::module_& m) {
py::class_<PyWindowlessApplication, ApplicationHolder<PyWindowlessApplication>> 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_<PyContext> glContext{m, "Context", "WGL-specific Magnum OpenGL context"};
context(glContext);
}
}}

7
src/python/magnum/platform/windowlessapplication.h

@ -46,4 +46,11 @@ template<class T, class Holder> void windowlessapplication(py::class_<T, Holder>
;
}
template<class T> void context(py::class_<T>& c) {
c
.def(py::init())
/** @todo delayed creation */
;
}
}}

Loading…
Cancel
Save