FATAL ERROR: No context is current

Started by sumwise, November 10, 2021, 17:47:18

Previous topic - Next topic

sumwise

Hello fellow community,

up front: i'm sorry for not providing enough information, i already got the problem fixed, i just don't understand why and would like to hear some input

In my engine i never called GL.createCapabilities(), i just made sure the context is current
(using glfwMakeContextCurrent(window) when running in a GLFW window and using canvas.runInContext(() -> { ..... }) from lwjgl-awt when running in a canvas)
then it is checked which extensions are available etc inside a renderer (using glGetInteger and glGetString) that is also used when running on the Web (so cannot use the fancy GL.createCapabilities())
Unfortunately i cannot figure out the change that caused it (lol), but now i require to add "GL.createCapabilities()" before initializing the aforementioned renderer.
In both cases, the GLFW window as well as the AWTGLCanvas, adding that single line fixes the problem, also in both cases not having that line causes a crash.
Simple fix: i add that line *doh*

I would like to understand the root though, so any idea why i could run without GL.createCapabilities() and now need that call is very much welcomed
here is the actual error:
FATAL ERROR in native method: Thread[main,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
   at org.lwjgl.opengl.GL11C.nglGetIntegerv(Native Method)
   at org.lwjgl.opengl.GL11C.glGetIntegerv(GL11C.java:833)
it is the very first GL call, i definitely made sure glfwMakeContextCurrent is called, once, on that same thread and before the GL calls, with a valid window created with glfwCreateWindow
The fact that it is the exact same exception on the exact same line in the renderer when using the AWTGLCanvas.runInContext(), indicates that the context should be current
Also when using GWT to run in the Browser the same renderer runs fine ofc, but no makeContextCurrent is needed there

Thanks a lot for any input and many greetings from the shire,
sumwise