JuliaGL / GLFW.jl

Julia interface to GLFW, a multi-platform library for creating windows with OpenGL contexts and managing input and events.
http://www.glfw.org/
MIT License
138 stars 33 forks source link

Support Wayland backend #188

Open hearnsj opened 5 years ago

hearnsj commented 5 years ago

I am building GLFW.jl on a Fedore 30 system. This uses Wayland graphics. I have had to install a boat load of X11 related RPMS and am still finding missing dependencies. Not an issue with the code here of course but this could trip people up in future.

If it is useful I would commit to installing a fresh Fedora 30 VM and documenting the RPMs which need installed.

jayschwa commented 5 years ago

The GLFW library can be built with Wayland support, but GLFW.jl only builds for X11 right now. If there is something easy to check for the existence of Wayland (e.g. an environment variable), then perhaps it could switch to that during Pkg.build. I assume there would still need to be some development dependencies installed, but probably less than if it's using the X11 backend.

caseykneale commented 4 years ago

How do you build it with Wayland support? I've been pulling my hair our trying to install this package - it seems really cool.

caseykneale commented 4 years ago

So i did some reading on this... Turns out - I think - for the CMAKE specifying wayland is trivial https://github.com/glfw/glfw/issues/986

As far as detecting wayland it seems there are a few easy environment variables to look for - https://stackoverflow.com/questions/45536141/how-i-can-find-out-if-a-linux-system-uses-wayland-or-x11

caseykneale commented 4 years ago

Where could I implement this? I am not seeing where a Cmake gets called or anything anywhere? I made a thread on discourse asking for help - https://discourse.julialang.org/t/contributing-wayland-support-to-cimgui-jl-help-wanted/32576

jayschwa commented 4 years ago

The build process is no longer managed by this repository. It is run elsewhere and this repo just references the built artifact. See https://github.com/JuliaPackaging/Yggdrasil/blob/master/G/GLFW/build_tarballs.jl

caseykneale commented 4 years ago

Thanks Jayschwa!

Turns out, the julia wizards wrote a binary wrapper for wayland! It works beautifully now!

@hearnsj - you can close this now after you test it for yourself!

jayschwa commented 4 years ago

@caseykneale, are you saying that GLFW.jl works with Wayland as-is? That's a little surprising to me since it doesn't look like the artifact is being provided Wayland build flags or dependencies. Is XWayland being run somewhere?

caseykneale commented 4 years ago

I'm not 100% sure how it's working, but yes my experience so far is the GLFW successfully builds on wayland systems right now without any effort. The BinaryBuilders crew in julia slack could probably explain how its working :)

giordano commented 4 years ago

To be honest, I'm also surprised that it works: as @jayschwa pointed out, the GLFW binary we provide in Yggdrasil doesn't currently know much about Wayland. However, as long as it works I think we can say we're happy? :slightly_smiling_face:

Gnimuc commented 4 years ago

image

caseykneale commented 4 years ago

Screenshot from 2019-12-26 20-59-33 All I can do is confirm that whatever you all did everything works fine now?

jayschwa commented 4 years ago

Are you able to make windows and stuff (see examples directory for sample code)?

Also, what does GLFW's version string say? That usually has information about the backend it was built for.

julia> import GLFW

julia> GLFW.GetVersionString()
"3.3.0 X11 GLX EGL OSMesa clock_gettime evdev shared"

If it's the case that it now works because of XWayland, then maybe that's Good Enough™ for now.

caseykneale commented 4 years ago
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0 (2019-11-26)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> import GLFW

julia> GLFW.GetVersionString()
"3.3.0 X11 GLX EGL OSMesa clock_gettime evdev shared"

I can see windows in CImGui, I haven't tried explicitly using GLFW

adigitoleo commented 3 years ago

@jayschwa

it now works because of XWayland

Are there any plans for supporting Wayland-only compositors? I'm not too knowledgable about all this (so I don't know how much effort this would take), but I'm coming from the Python+Matplotlib world which is working without XWayland.

jayschwa commented 3 years ago

I personally probably won't put in the time to figure it out, but patches are welcome. The process will likely look something like:

  1. Independent of Julia, figure out how to build GLFW to support both Wayland and X11.
    • Dropping support for X11 is not an option for now.
  2. Adapt step 1 to the Julia binary builder process.
  3. When step 2 succeeds, update this repo's Project.toml to pull in the new build artifact.
adigitoleo commented 3 years ago

Since last month I've had to get XWayland running for other stuff anyway, and unfortunately I don't see myself putting much work into this very soon. Here are a few points in case anyone is interested in picking this up: