我正在使用 LWJGL 3“工作”演示 (http://www.lwjgl.org/guide)。
我在 glClearColor 上遇到错误:
Exception in thread "main" java.lang.IllegalStateException: There is no OpenGL context current in the current thread.
at org.lwjgl.opengl.GL.getCapabilities(GL.java:164)
at org.lwjgl.opengl.GL11.getInstance(GL11.java:1388)
at org.lwjgl.opengl.GL11.glClearColor(GL11.java:1828)
at me.harrysmc.jgame.HelloWorld.loop(HelloWorld.java:98)
at me.harrysmc.jgame.HelloWorld.run(HelloWorld.java:28)
at me.harrysmc.jgame.HelloWorld.main(HelloWorld.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
即使您在演示中看到有“GL.createCapabilities(true)”和“glfwMakeContextCurrent(window)”
尝试了其他问题的相关答案。
最佳答案
我刚刚遇到了完全相同的问题,我通过添加 GLContext.createFromCurrent(); 解决了它;到 init()。
关于java - LWJGL3 'working' 演示抛出 'no OpenGL context current in the current thread' 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32035270/