java - Java 中没有上下文错误,但在窗口创建后立即设置了上下文

我正在尝试使用 LWJGL 3 制作游戏,但出现此错误:No context is current or a function that is not available in the current context was called.

此错误意味着未调用这些方法:

glfwMakeContextCurrent(window);
GL.createCapabilities();

但是在我的代码中,这些是在创建窗口后立即调用的:

...
this.window = glfwCreateWindow(this.width, this.height, this.title, 0, 0);
    if(this.window == NULL) {
      throw new RuntimeException("Failed to create window");
    }

        glfwMakeContextCurrent(this.window);
        GL.createCapabilities();
      
        ...

        this.world = new World(256, 256, 64); // calls GL11.glGenLists
        this.worldRenderer = new WorldRenderer(this.world);
        this.player = new Player(this.world);
...

这会引发前面提到的异常。我如何解决它?

回答1

GL11.glGenLists 已弃用。改为使用 GLFW_OPENGL_COMPAT_PROFILE

相似文章

随机推荐

最新文章