#2891·glfw

Failing to create a window with OpenGL on Wayland

Author: ilonic23Created Aug 27, 2026Updated Aug 27, 2026

Device info:

GPU: NVIDIA GeForce GTX 1660 Super (595.91.07) OS: NixOS WM: Niri (Wayland)

GLFW version: 3.5.1

Issue:

When trying to create a new window with GLFW the creation fails. (!window condition is true) The error callback isn't being called, though a check if (!window) catches it. Without the check Glad fails to initialize. The version of OpenGL and other WindowHints don't seem to change something, the creation still fails.

The code:

c
  glfwSetErrorCallback(on_error); // panics and terminates the program

// No matter what OpenGL version, the !window condition stays true.
// If set an invalid version like 9.9 the on_error fires.
  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  GLFWwindow *window = glfwCreateWindow(640, 480, "My window", NULL, NULL);
  printf("window: %p\n", window); // Seems to give some pointer
  if (!window)
    panic("!window"); // Panics here
  glfwMakeContextCurrent(window);
  int glad_ver = gladLoadGL(glfwGetProcAddress);
  if (!glad_ver)
    panic("Failed to initialize glad.");
  printf("Loaded OpenGL %d.%d\n", GLAD_VERSION_MAJOR(glad_ver),
         GLAD_VERSION_MINOR(glad_ver));

What can I do with it? Nor the packaged (by nixpkgs) GLFW v3.4, nor built manually 3.5.1 don't change the result. Do I need to provide something else?