this post was submitted on 06 Oct 2023
0 points (50.0% liked)

C++

1782 readers
1 users here now

The center for all discussion and news regarding C++.

Rules

founded 1 year ago
MODERATORS
 

I was using this OpenGL tutorial, and when i compile the program and execute it, it fails with the error "Failed to create context: Arguments are inconsistent" the code: https://pastebin.com/1hQJYHxe Im using Arch Linux with sway (Wayland) glxinfo output: https://pastebin.com/VXWtib2W

top 14 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 1 year ago (2 children)

Does it fail in X11 as well?

[–] [email protected] 1 points 1 year ago

I belive GLFW is either built X11 only, or wayland only, so they would have to check what build they're using first

[–] [email protected] 1 points 1 year ago (1 children)

in X11 fails due to not being able to find a Wayland display

[–] [email protected] 2 points 1 year ago (1 children)

I think you'd need i3 instead of Sway for an X11 test.

[–] [email protected] 2 points 1 year ago

i logged into i3 and tested it, anyway, i already solved it, the problem we're the glfwWindowHint calls, now it works normally, thank you anyway

[–] [email protected] 2 points 1 year ago (2 children)

It seems to have something to do with context creation, not the window, first thing I'd try to do is use a lower opengl version when creating the window and see if that works, Wayland uses EGL as far as I know, so the base compatibility will potentially be different? The error message isn't very useful either, as it's a one liner, it also could potentially be a GLFW bug itself too...

[–] [email protected] 2 points 1 year ago

I was digging around in the GLFW code a bit before I saw your comment, and the "Arguments are inconsistent" message seems to be how GLFW describes an EGL_BAD_MATCH error code. There's a few places in egl_context.c where getEGLErrorString is called that could return that string, but it's probably in _glfwCreateContextEGL given the "Failed to create context" part of the error quoted.

The error handling there (if this is the right place -- I would have also expected "EGL" in the message, but maybe OP dropped it) follows a failure of eglCreateContext. The reference documentation for that function here -- https://registry.khronos.org/EGL/sdk/docs/man/html/eglCreateContext.xhtml -- unfortunately doesn't give much detail about the kinds of errors that can happen, but does talk about OpenGL versions so a mismatch on that makes sense; I think this is on the right track.

Googling the OpenGL renderer string: llvmpipe (LLVM 16.0.6, 128 bits) line from the glxinfo output suggests that's software rendering, so the OpenGL version shown there may differ from what is actually supported by hardware rendering. Is there an EGL equivalent to glxinfo? (eglinfo, maybe?)

I'd personally comment out all the glfwWindowHint calls and see if a window shows up at all -- then mess with the OpenGL version if needed.

[–] [email protected] 1 points 1 year ago (2 children)

It also throws an error code: 65543, i didnt add it because i thought it was an error in my code that i wasnt able to see, im sorry, anyway, do you need more info about my system?

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

Try doing what e0qdk suggests in this comment as it seems to be an issue with how GLFW creates windows in wayland. You're technically creating an eGL window through it and the profile version is different (egl2 is opengl4.x compatible while egl1 is opengl 3.x compatible I think?), so just remove the window calls to glfwWindowHint and see what version it tries to use by default

[–] [email protected] 1 points 1 year ago

i commented all the calls to glfwWindowHint, and now it just exits inmediately with code 0, so i think it is working, although it doesnt create any window either, there is a way to see which version is using by default?

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

65543 seems to be the constant defined for GLFW_VERSION_UNAVAILABLE passed back from the error handling code I was looking at in egl_context.c -- that helps confirm I'm looking at the right chunk of code in GLFW's guts, thanks.

As I suggested in my other comment, try commenting out the hint lines and see if a window shows up at all. (Your program doesn't do anything other than quit after making the window, so it should just flash a window briefly, I'd expect.)

[–] [email protected] 1 points 1 year ago (1 children)

it just starts and ends with code 0 without creating any output to the terminal or any window

[–] [email protected] 2 points 1 year ago (1 children)

That's because you need to run an event loop, your window is being created successfully, but your program immediately exits after the fact because the line directly after glfwCreateWindow is return EXIT_SUCCESS. You're probably good to follow the rest of the tutorial now

[–] [email protected] 1 points 1 year ago

thank you :D