I’m attempting to initialize GLFW on an X11 session, but it is failing with the following:
error code: 65544
description: Wayland: Failed to connect to display
I have the following environment variables set:
XDG_SESSION_TYPE=x11
GDK_BACKEND=x11
Code segment:
int code;
int ret = glfwInit();
if (ret == GLFW_FALSE) {
code = glfwGetError(&description);
std::cerr << "glfwInit return error, code " << code;
if (description)
std::cerr << ": " << description;
std::cerr << std::endl;
abort();
}
On Arch Linux, the glfw
package supports both X11 and Wayland AFAIK.
Did you set the init hint GLFW_PLATFORM? It may be that since that was introduced the environment variable doesn’t matter. In any way, I would so something like this:
if(glfwPlatformSupported(GLFW_PLATFORM_WIN32)) glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WIN32);
else if(glfwPlatformSupported(GLFW_PLATFORM_COCOA)) glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_COCOA);
else if(glfwPlatformSupported(GLFW_PLATFORM_X11)) glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11);
else if(glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
else {
fprintf(stderr, "Error: could not find acceptable platform for GLFW\n");
abort();
}
before the code you have written above (maybe rearrange the cases for whatever priority you want to have). Maybe you can try if somthing like that helps your case.
description: Wayland: Failed to connect to display
This error description indicates that GLFW was compiled with only Wayland support. What does the GLFW version string say?