moderngl-window icon indicating copy to clipboard operation
moderngl-window copied to clipboard

Possibly add a separate headless_egl window

Open einarf opened this issue 3 years ago • 3 comments

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.

einarf avatar Mar 13 '21 14:03 einarf

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.

kngwyu avatar Apr 26 '22 12:04 kngwyu

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.

einarf avatar Apr 26 '22 12:04 einarf

Hmm then window_cls(context_settings={"backend": "egl"}) might be a good interface

kngwyu avatar Apr 26 '22 12:04 kngwyu