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

Cannot run glew on wayland #172

Open
deveee opened this issue Jan 12, 2018 · 11 comments
Open

Cannot run glew on wayland #172

deveee opened this issue Jan 12, 2018 · 11 comments

Comments

@deveee
Copy link
Contributor

deveee commented Jan 12, 2018

I'm currently working on wayland support in Supertuxkart.

The problem is that I have to compile glew with glx support, because I need fallback for xorg session. I mean, I dynamically check when starting the game if wayland is available. If it's available then I use wayland+egl, if not available then fallback to x11+glx. And for this reason I can't use glew+egl.

On wayland I don't need glx extensions at all. And glXGetProcAddress should work as long as we are linking with x11.

Currently I use patched glew:
supertuxkart/stk-code@961ac4d

Or I can use glXGetProcAddress/eglGetProcAddress depending on x11/wayland. Doesn't really matter.

Ideally I would like to execute glxewInit as a separate function that doesn't depend on glewInit, or maybe provide a kind of ignore_glx = true parameter to glewInit.

Also people complain that we don't use system glew:
supertuxkart/stk-code#3059

@nigels-com
Copy link
Owner

I see. So the goal here is use GLEW for OpenGL bindings, but we don't know until runtime if that's in combination with EGL (Wayland) or GLX (not Wayland)? In the glewInit there isn't a runtime way to specify the EGL or the GLX path - it's a compile-time choice. But you're finding that you can use GLEW compiled in default X11/GLX mode providing it doesn't error-out in EGL Wayland mode with no X display?

From a historical perspective I don't think GLEW was intended to support a runtime choice between WGL and GLX, or GLX and Apple. I added EGL support along similar lines, although it's a reasonable thing to have applications that can do Wayland (or not) at runtime.

It doesn't seem like supertuxkart actually needs either EGL or GLX entry-points from GLEW. But ideally there would be more control available via glewInit to initialise via EGL or via GLX, as a runtime choice? Or skip the EGL/GLX/WGL initialisation entirely?

The other aspect is that glXGetProcAddressARB seems to be working fine even in Linux EGL/Wayland mode, rather than eglGetProcAddress. Can you confirm that? (I do have a box with Arty installed, I guess I could give Wayland a try there...)

One option here is to expose glewContextInit as an alternative to glewInit, and indeed for supertuxkart you could declare that manually to bypass the call to glxewInit from glewInit.

That doesn't solve the problem of using the system-installed GLEW, but it does spare you from patching GLEW to fail more gracefully from glxewInit in EGL/Wayland mode. I'd consider bringing glewContextInit into glew.h, but that would take a while to percolate to various distributions as a GLEW 2.2.

Thoughts?

@deveee
Copy link
Contributor Author

deveee commented Jan 13, 2018

Actually I noticed that current version doesn't crash and it only fails with GLEW_ERROR_NO_GLX_DISPLAY error. So that I can just ignore this error and assume that glewInit is success.

Maybe add something like glewIgnoreGLX = true in the same way as glewExperimental variable? In this way we can check if glew returned GLEW_OK and that everything is loaded properly.

And yes, glXGetProcAddressARB works fine on EGL/Wayland. They say:

GL function pointers returned by glXGetProcAddress are independent of the
currently bound context and may be used by any context which supports the exten-
sion.

@nigels-com
Copy link
Owner

I think I'd prefer to add glewContextInit to the interface, than another state variable. That leaves the option open to the application to initialise WGL/GLX/EGL as appropriate. But stops short of supporting either GLX or EGL as a runtime choice. Is Wayland really coming? :-)

@deveee
Copy link
Contributor Author

deveee commented Jan 13, 2018

It depends on what do you mean by really comming ;) I think that some solutions are too young (stable xdg shell is not supported by compositors yet and you still have to use unstable version) and some issues are not solved yet. For example Gnome still doesn't want allow to use server-side decorations, which affects multiple applications. But I think that it's usable in general.

@nigels-com nigels-com self-assigned this Feb 2, 2019
@nigels-com nigels-com added this to the GLEW 2.2.0 milestone Feb 2, 2019
@nigels-com
Copy link
Owner

I was expecting a "Wayland Apocalypse" with Ubuntu 18.04 Bionic, but that didn't come to pass.

In preparation for an upcoming GLEW 2.2.0 - I'm considering simply exposing glewContextInit as an alternative path to glewInit.

@Cybertwip
Copy link

Cybertwip commented Aug 23, 2019

I have Ubuntu 18.04 and I'm facing the same situation here. What is the alternative for building, it seems that it lacks some support with GLEW_ERROR_NO_GLX_DISPLAY. Not sure how to handle it though.

We're the team behind Sonic 2 HD and Linux is one of our ports.

@nigels-com
Copy link
Owner

@victorjl I did propose a change for this. Could you take a look and indicate if this might solve your problem? #216
Thanks!

@nigels-com
Copy link
Owner

Some fresh discussion over at Issue #328

@nigels-com
Copy link
Owner

glewContextInit is added in the upcoming release. (In master branch now)

punesemu added a commit to punesemu/puNES that referenced this issue Mar 24, 2022
- GLEW upgrade to version 2.2.0.
- applied the patch
  nigels-com/glew@715afa0
  to allow starting with Wayland
  nigels-com/glew#172.
acaudwell pushed a commit to acaudwell/Core that referenced this issue Oct 6, 2022
When GLEW starts on Wayland, it returns GLEW_ERROR_NO_GLX_DISPLAY
because it's Wayland and not X.  Checking for and ignoring this one
specific error allows the code to run successfully on Fedora 36 which
natively ships with Wayland.

See nigels-com/glew#172

Signed-off-by: Ed Beroset <[email protected]>
catsout added a commit to catsout/ppsspp that referenced this issue Oct 18, 2022
glXGetProcAddress works on wayland if linking with x11.
As long as we don't use glx related funcs, it can be ignored.
The no glx error should be handled by SDL.
Glew is only used to init gl funcs.

related:
nigels-com/glew#172
catsout added a commit to catsout/ppsspp that referenced this issue Oct 18, 2022
glXGetProcAddress works on wayland if linking with x11.
As long as we don't use glx related funcs,
no_glx_error can be ignored.
SDL should handle the no_glx_error brefore glewInit.
Glew is only used to init gl funcs.

related:
nigels-com/glew#172
pvmm added a commit to pvmm/openMSX that referenced this issue Feb 15, 2023
GLEW fails to initialise because there is no GLX on wayland and the one provided by distros is build to use GLX over EGL. This PR ignores the GLEW_ERROR_NO_GLX_DISPLAY error and it is the temporary fix until this is fixed by GLEW upstream, see nigels-com/glew#172
pvmm added a commit to pvmm/openMSX that referenced this issue Feb 15, 2023
GLEW fails to initialise because there is no GLX on wayland and the one provided by distros was built to use GLX instead of EGL. This PR ignores the GLEW_ERROR_NO_GLX_DISPLAY error and it is the temporary fix until this is fixed by GLEW upstream. See nigels-com/glew#172
pvmm added a commit to pvmm/openMSX that referenced this issue Feb 15, 2023
GLEW fails to initialise because there is no GLX on wayland and the one provided by distros was built to use GLX instead of EGL. This PR ignores the GLEW_ERROR_NO_GLX_DISPLAY error and it is a temporary fix until this is fixed by GLEW upstream. See nigels-com/glew#172
pvmm added a commit to pvmm/openMSX that referenced this issue Feb 15, 2023
GLEW fails to initialise because there is no GLX on Wayland and the one provided by distros was built to use GLX instead of EGL. This PR ignores the GLEW_ERROR_NO_GLX_DISPLAY error and it is a temporary fix until this is fixed by GLEW upstream. See nigels-com/glew#172
m9710797 pushed a commit to openMSX/openMSX that referenced this issue Feb 15, 2023
GLEW fails to initialise because there is no GLX on Wayland and the one provided by distros was built to use GLX instead of EGL. This PR ignores the GLEW_ERROR_NO_GLX_DISPLAY error and it is a temporary fix until this is fixed by GLEW upstream. See nigels-com/glew#172
@ganguin
Copy link

ganguin commented Nov 12, 2023

If someone is interested, I'm running supertux and supertuxkart on pure wayland, I compiled GLEW as following

sed -i -e 's/-lGL\>/-lGLESv2/' config/Makefile.linux-egl
make SYSTEM=linux-egl

GL bits provided by libglvnd

@lanodan
Copy link

lanodan commented Nov 17, 2023 via email

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

No branches or pull requests

5 participants