mcfletch / pyopengl

Repository for the PyOpenGL Project
Other
315 stars 97 forks source link

Attempt to auto-detect wayland vs. x11 (egl vs. glx) on linux #41

Closed mcfletch closed 2 years ago

mcfletch commented 4 years ago

SourceForge ticket here: https://sourceforge.net/p/pyopengl/bugs/275/

The values I see people reporting for wayland sessions seem to be "wayland", "xwayland" (for the nested x server) and "" for cases where wayland isn't run by SDDM or the like. I'm going on the assumption that using the EGL API for xwayland is correct, but I haven't been able to get wayland working on my machines, so it's just a guess as to what is appropriate.

a-anjos commented 4 years ago

This is what works for me, from the terminal: $ PYOPENGL_PLATFORM="egl" python3 myprogram.py The following doesn't work, i.e. setting inside myprogram.py: os.environ["PYOPENGL_PLATFORM"] = "egl"

I'll test your fix if you let me know how to do it without messing up my currently pip3 installed pyopengl.

totaam commented 4 years ago

xisxwayland may help: tool to be used within shell scripts to determine whether the X server in use is Xwayland

adabru commented 3 years ago

Hi, I tried out the develop branch with the pyqtgraph examples, running python -m pyqtgraph.examples. They are qt based, my observation is following:

Thing is, on weston I could use the command python -m pyqtgraph.examples without any environment variables set before. Now, on the develop branch, I have to set either QT_QPA_PLATFORM=wayland or PYOPENGL_PLATFORM=x11. So this could be a regression. But I guess qt will anyways default to wayland on weston somewhere along the way. Sway already does, I'm not sure what is currently the case with e.g. gnome.

For my use case the fix is perfect, there seems to be a possibility that on some compositors qt applications may fail if QT_QPA_PLATFORM=wayland is not set.

@a-anjos you can use following commands to leave your python environment untouched:

python -m venv .venv
source .venv/bin/activate
pip list
git clone --depth 1 --no-single-branch https://github.com/mcfletch/pyopengl.git
cd pyopengl
git checkout develop
pip install .
pip list

@mcfletch, if you want to test something out under wayland, you could try following steps (mainly taken from a fedora HowTo):

I'm coming from issue https://github.com/pyqtgraph/pyqtgraph/issues/1661 and would be glad if the develop branch will be merged and released.