LWJGL Forum

Programming => OpenGL => Topic started by: elect on July 23, 2015, 07:50:59

Title: There is no OpenGL context current in the current thread.
Post by: elect on July 23, 2015, 07:50:59
Simple program, everything in a class, here (https://github.com/elect86/glCallsOverhead/blob/master/glCallsOverhead/src/lwjgl/GlCallsOverhead.java)

I know jogl, but I wanted to give a try to lwjgl and so I started writing it from the hello word in order to minimize problems..

As you can see, glfwMakeContextCurrent() is called (https://github.com/elect86/glCallsOverhead/blob/master/glCallsOverhead/src/lwjgl/GlCallsOverhead.java#L102) before all the various initializations (porgrams, textures, targets, vbo, vao)

But I still get this exception

QuoteGlCallsOverheads 3.0.0a!
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.GL20.getInstance(GL20.java:372)
   at org.lwjgl.opengl.GL20.glCreateShader(GL20.java:469)
   at lwjgl.glsl.ProgramBase.loadShader(ProgramBase.java:55)
   at lwjgl.glsl.ProgramBase.<init>(ProgramBase.java:26)
   at lwjgl.GlCallsOverhead.initPrograms(GlCallsOverhead.java:137)
   at lwjgl.GlCallsOverhead.init(GlCallsOverhead.java:109)
   at lwjgl.GlCallsOverhead.run(GlCallsOverhead.java:49)
   at lwjgl.GlCallsOverhead.main(GlCallsOverhead.java:320)
Java Result: 1
Title: Re: There is no OpenGL context current in the current thread.
Post by: spasi on July 23, 2015, 07:59:04
Hey elect,

You need to move GLContext.createFromCurrent() from line 273 to somewhere between glfwMakeContextCurrent(window) and initPrograms(). It must be called before any OpenGL function is used.
Title: Re: There is no OpenGL context current in the current thread.
Post by: elect on July 23, 2015, 09:34:46
Quote from: spasi on July 23, 2015, 07:59:04
Hey elect,

You need to move GLContext.createFromCurrent() from line 273 to somewhere between glfwMakeContextCurrent(window) and initPrograms(). It must be called before any OpenGL function is used.

Thanks Spasi, it worked