You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wayland(Hyprland,NVIDIA)环境下glfwCreateWindow失败:EGL上下文错误

在Arch Linux + Hyprland下使用LWJGL创建GLFW窗口失败

报错信息

[LWJGL] GLFW_PLATFORM_ERROR error
  Description : 
    EGL: Failed to clear current context: 
    An EGLDisplay argument does not name a valid EGL display connection

    Stacktrace  :
      org.lwjgl.glfw.GLFW.nglfwCreateWindow(GLFW.java:2086)
      org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:2251)

环境信息

  • 操作系统:Arch Linux(6.12.9-arch-1)
  • 合成器:Hyprland(Wayland)
  • GPU:NVIDIA RTX 3070
  • 驱动版本:565.77
  • LWJGL版本:3.3.6
  • EGL版本:1.5

复现代码

import org.lwjgl.*;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import org.lwjgl.system.*;

import static org.lwjgl.glfw.Callbacks.*;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;

public class Game {
    public static void main(String[] args) {
        GLFWErrorCallback.createPrint(System.err).set();

        if (!glfwInit()) 
            throw new IllegalStateException("Unable to init GLFW");

        glfwDefaultWindowHints();
        glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
        glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
        glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);

        long window = glfwCreateWindow(800, 600, "Test", NULL, NULL);
        if (window == NULL) 
            throw new RuntimeException("glfwCreateWindow failed");

        glfwMakeContextCurrent(window);
        glfwSwapInterval(1);
        glfwShowWindow(window);
    }
}

LWJGL说明

使用的依赖来自LWJGL自定义页面的稳定版3.3.6 Linux x86完整包。

补充说明

已测试vkcube、glxgears、weston以及Rust+winit编写的Vulkan渲染器,均能正常运行。


内容的提问来源于stack exchange,提问作者amir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 22:16:05