Java中没有上下文错误,但在创建窗口后立即设置上下文[已关闭]

vlf7wbxs  于 2022-11-04  发布在  Java
关注(0)|答案(1)|浏览(134)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
6个月前关闭。
Improve this question
我尝试使用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);
...

这将抛出前面提到的异常。如何修复它?

jq6vz3qz

jq6vz3qz1#

不推荐使用GL11.glGenLists。请切换到使用GLFW_OPENGL_COMPAT_PROFILE

相关问题