Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL is dying #3

Open
jonathanhogg opened this issue Apr 11, 2023 · 5 comments
Open

OpenGL is dying #3

jonathanhogg opened this issue Apr 11, 2023 · 5 comments
Labels
💡 idea A hair-brained concept 🎨 render Anything to do with rendering (windows, physics, etc.)

Comments

@jonathanhogg
Copy link
Owner

My current use of pyglet and moderngl was always a hack and needs to end. There are, thankfully, now some decent alternatives to investigate.

The top candidate for replacing OpenGL has to be WebGPU – which thankfully isn't just for the web. The rust-based wgpu-native library provides a multi-platform translation API that, importantly for me, maps to Metal in macOS. There appear to be solid Python bindings available for this library.

I'm still going to need a windowing layer and GLFW may be the thinnest/simplest cross-platform API for this that is supported by wgpu-py.

@jonathanhogg jonathanhogg added the 🚀 enhancement New feature or request label Apr 11, 2023
@jonathanhogg jonathanhogg self-assigned this Apr 11, 2023
@jonathanhogg jonathanhogg added the 🎨 render Anything to do with rendering (windows, physics, etc.) label Apr 12, 2023
@jonathanhogg
Copy link
Owner Author

I've switched to GLFW, so at least a small part of this is now done.

@jonathanhogg
Copy link
Owner Author

Actually, a problem here is going to be that I am using the OpenGL back-end for skia. skia-python is pretty far behind mainline skia now, so there is an argument for replacing it, but I see no decent candidates and I'm not sure I have the appetite for creating my own…

@jonathanhogg jonathanhogg removed their assignment Oct 30, 2023
@jonathanhogg jonathanhogg added 💡 idea A hair-brained concept and removed 🚀 enhancement New feature or request labels Feb 15, 2024
@jonathanhogg
Copy link
Owner Author

As an alternative to switching away from OpenGL entirely it is worth considering switching to using ANGLE. This is a cross-platform implementation of OpenGL ES that translates to Metal on macOS. Now that I have Flitter compatible with OpenGL ES, I could use ANGLE as the back-end without a lot of rewriting.

Interestingly, I have sort of tested this on Apple Silicon macOS: the UTM virtualisation app allows running aarch64 Linux on macOS and this provides a para-virtualised GPU that uses ANGLE. Testing some GPU intensive Flitter examples with this shows them running over twice as fast under virtualisation than native.

GLFW has direct support for EGL using the glfw.CONTEXT_CREATION_API/glfw.EGL_CONTEXT_API hint and I've verified that this will load libEGL.dylib and libGLESv2.dylib libraries that I cribbed out of macOS Chrome.

The problem, however, is that moderngl uses glcontext and this uses the native OpenGL Framework on macOS and WGL on Windows. It does contain a Linux backend for EGL, however. The question is, can this be made to compile and function on macOS and Windows?

@jonathanhogg
Copy link
Owner Author

Had a quick look at changing glcontext and it might be possible.

An alternative is to switch to something else like zengl – although I am loath to make massive changes and zengl is a fairly different architecture. It at least looks like it ought to be easier to create an EGL loader. Although, it looks like it might be trying to use a function that isn't in OpenGL ES.

@jonathanhogg
Copy link
Owner Author

Have kinda gotten zengl working, but it wants to use glGetBufferSubData, which doesn't seem to be implemented in OpenGL ES.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 idea A hair-brained concept 🎨 render Anything to do with rendering (windows, physics, etc.)
Projects
None yet
Development

No branches or pull requests

1 participant