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

Add support for EGL on Linux #74

Merged
merged 1 commit into from
Dec 23, 2021
Merged

Add support for EGL on Linux #74

merged 1 commit into from
Dec 23, 2021

Conversation

ShadowNinja
Copy link
Contributor

GLX is a X11-specific API. EGL is an alternative that is supported under both X11 and Wayland. GL3W should remove its dependency on GLX as the Linux desktop transitions to Wayland.

This attempts to use whichever library is already loaded so that it will match your windowing library (SDL/glut/glfw/etc), but if one of them isn't already loaded it falls back to EGL or the legacy libGL implementation.

I tested it with glut_test and glfw_test and it worked (glfw's Wayland implementation does randomly segfault on exit sometimes, but that seems unrelated...).

// already loaded either EGL or GLX and we want to use the same one.

if (is_library_loaded("libEGL.so.1", &libegl) ||
is_library_loaded("libGLX.so.0", &libglx)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this libGLX check? Is it just an alternative to using GLX via libGL? (And if so, why is it being checked with libEGL instead of below with libGL?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's an alternative to libGL.
On modern Linux systems there are two ways to load GLX:

  • The new GLVND way: load GLX from libGLX and OpenGL from libOpenGL.
  • The legacy way: load both GLX and OpenGL from libGL. On modern systems this just routes calls to libOpenGL or libGLX (or libGLdispatch, but that's a GLVND implementation detail).

See the GLVND README and OpenGL ABI probosal that it links to for more information.

The reason the check is here is because if we load libGLX we also have to load libOpenGL, same as with libEGL. If libEGL is found the condition will short-circuit and it won't check for libGLX, otherwise it will check for libGLX. Inside the conditional body exactly one of libegl or libglx will be non-null. Either way we'll want to attempt to load libOpenGL to complete the EGL/GLX + OpenGL pairing.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I forgot to respond, thanks for the explanation!

@skaslev skaslev merged commit ec62d76 into skaslev:master Dec 23, 2021
@skaslev
Copy link
Owner

skaslev commented Dec 23, 2021

Merged, thanks for working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants