nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.62k stars 614 forks source link

GLEW initialization failed. #306

Open misterabdul opened 3 years ago

misterabdul commented 3 years ago

I have this code: https://gist.github.com/misterabdul/a44036fbc0103cab3d38319d4ce95036

And compiled like this :

cc src/main.c -o bin/main -lGLEW -lGLU -lGL -lglfw  -Wall -Wextra

But when I'm running it, it says: Failed to initialize GLEW

I'm using Fedora 34.

nigels-com commented 3 years ago

What's the output of glewinfo ?

misterabdul commented 3 years ago

It's 0x4, when I pass that value to glewGetErrorString(), it says: unknown error.

nigels-com commented 3 years ago

glewinfo is a CLI tool that might shed some light on the available OpenGL support.

For example:

$ glewinfo -profile core -version 4.0
---------------------------
    GLEW Extension Info
---------------------------

GLEW version 2.1.0
Reporting capabilities of display , visual 0x2b
Running on a GeForce GT 1030/PCIe/SSE2 from NVIDIA Corporation
OpenGL version 4.0.0 NVIDIA 460.73.01 is supported

GL_VERSION_1_1:                                                OK
...
misterabdul commented 3 years ago

Here's the result of my glewinfo: https://gist.github.com/misterabdul/129c51236b41ad25ad0494f81cfafcbe It's about 5000+ lines.

nigels-com commented 3 years ago

That output looks healthy.

The next thing that comes to mind is X11 vs Wayland.

What is the output of glxinfo ?

misterabdul commented 3 years ago

I don't know if this will help or not, but here it is, the output of my glxinfo: https://gist.github.com/misterabdul/1bc4dd1a8c22ce48de089e441a0efbc6

nigels-com commented 3 years ago

It's 0x4, when I pass that value to glewGetErrorString(), it says: unknown error.

Ah, interesting. So error 4 be no GLX display from glewGetErrorString, so that's a bug in my opinion.

This could be because EGL is being used by the application. I'll have a think about how to detect if EGL is "live", and error more descriptively.

joshuarubin commented 3 years ago

Running into this issue as well on wayland/sway. Happy to help debug and test fixes. I don't think better wording of the error is the issue here. Or, if it is, what is the way to work around this in code?

nigels-com commented 3 years ago

Some breadcrumbs regarding OpenGL and Wayland. In short, GLX depends on X11. https://unix.stackexchange.com/questions/511134/why-wayland-is-using-opengl-es-instead-of-opengl

nigels-com commented 3 years ago

This looks like the reason Wayland isn't on my radar. (Nvidia GPU) I'll scratch around to see if I have a laptop with Intel graphics. https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-GL-VLK-XWayland

nigels-com commented 3 years ago

@misterabdul 's glewinfo indicates Intel GPU:

Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel (0x8086)
    Device: Mesa Intel(R) HD Graphics 620 (KBL GT2) (0x5916)
    Version: 21.1.2