LWJGL wglGetCurrentContext exception

195 views Asked by At

I am starting to learn LWJGL, but I'm having a problem with it. I get an error with the line GLContext.createFromCurrent(); and I can't figure out how to fix it. The first step using LWJGL I wrote my own code for creating the display, but the error popped up. Later I just copied the demonstration code from the lwjgl web page, but I have the same error. And the full error is:

Hello LWJGL 3.0.0a!
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.lwjgl.opengl.WGL.wglGetCurrentContext()J
    at org.lwjgl.opengl.WGL.wglGetCurrentContext(Native Method)
    at org.lwjgl.opengl.GLContextWindows.createFromCurrent(GLContextWindows.java:59)
    at org.lwjgl.opengl.GLContext.createFromCurrent(GLContext.java:36)
    at Main.loop(Main.java:97)
    at Main.run(Main.java:26)
    at Main.main(Main.java:117)
2

There are 2 answers

0
Dawnkeeper On BEST ANSWER

As you left out the interesting half of the exception message I will just guess that you didn't set the path to LWJGL right:

System.setProperty("org.lwjgl.librarypath", new File("pathToNatives").getAbsolutePath());

For further reference see Here

0
Tormod On

When importing the library, you also need the native implementation of the library accessible. I did a dirty hack: copied all the files in the librery LWJGL 3.x.x(https://github.com/LWJGL/lwjgl3/releases) into the same folder. (flat structure) with all the native,javadoc ++. Then I imported all the files as a library (in the IDE). It's not elegant but it worked.