moderngl-window
moderngl-window copied to clipboard
Possibly add a separate headless_egl window
Since moderngl-window are doing the context creation we might need to add a separate window for egl. Optionally the current headless window should be more configurable.
The below code works for me
class EglHeadlessWindow(headless.Window):
name = "egl-headless"
def init_mgl_context(self) -> None:
"""Create an standalone context and framebuffer"""
self._ctx = mgl.create_standalone_context(
require=self.gl_version_code,
backend="egl",
)
self._fbo = self.ctx.framebuffer(
color_attachments=self.ctx.texture(self.size, 4, samples=self._samples),
depth_attachment=self.ctx.depth_texture(self.size, samples=self._samples),
)
self.use()
Though I'm not sure what is the best interface to use this. The only thing I want to do is to pass backend="egl"
, and I guess most users do too.
That is a perfectly fine way to do it. Optionally you can just monkeypatch the method in the headless window itself. There might be several other context creation parameters people want to supply here as well.
Hmm then window_cls(context_settings={"backend": "egl"})
might be a good interface