Hi everyone,
I’m working on a python + gtk4 frontend, for an emulator called mupen64plus, that it was originally written in Gtk 3 but now I’m trying to port it to use Gtk 4 instead, but I’m currently struggling with it.
First of all, a bit of context may be needed here: This emulator doesn’t come with a GUI, but it does have an API that allows any third party frontend to communicate with it. One subset of this API provides callbacks for 3D render output, that can be redefined by the frontend to provide its own callbacks instead (https ://mupen64plus .org/wiki/index.php?title=Mupen64Plus_v2.0_Core_Video_Extension) .
The purpose of this override is that it allows the frontend to embed the output in the window. But there’s some limitation in what the frontend can do and what it cannot do, e.g. for most part it doesn’t handle OpenGL calls, the emulator is the one that still does it.
With that said, I have to redefine VidExt_GL_SetAttribute and VidExt_GL_GetAttribute callbacks to set the pixel format (https ://github .com/mupen64plus/mupen64plus-core/blob/53c20cd18c57bdc4f39ff0aba6dc7510dc57045f/src/api/m64p_types.h#L408) that must be then passed back to the emulator, so that I can use it to draw on a dedicated area of the window.
With gtk3, I could use EGL to set the OpenGL attributes for the pixel format, and then use eglCreateWindowSurface (see here) and pass the window handle (XID) as parameter to it. In the window all I have to do is to put a Drawing Area on it and let the magic happen.
But with gtk4 this seems isn’t possible anymore because, with subwindows being removed and apparently there’s no substitute for it, EGL just draws all over the window. Could a subsurface be a good replacement for it? In that case, how exactly can I implement that in a Drawing Area or any other suitable widget?
If not, I can try to think of any other alternatives, for example I could implement eglCreatePbufferSurface (see here) instead of eglCreateWindowSurface and use that to draw in the Drawing Area, but sadly I have yet to understand how to set up the pixel buffer on Gtk4 and I’m not even sure if this whole idea can work. Other than that, I can’t come up with anything…
Many thanks for any possible help or advice.