Many people get this error when trying to run my game:
C:\dist>java -cp lwjgl.jar; Schlug
java.lang.NullPointerException
at org.lwjgl.Display.create(Unknown Source)
at Schlug.initGL(Schlug.java:123)
at Schlug.run(Schlug.java:40)
at java.lang.Thread.run(Thread.java:536)
All of them can run AF without any problems, so it can´t be LWJGL fault... But I cant find any error in my code, can you take a look?
here is the init() method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public void initGL() throws Exception { org.lwjgl.DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { if (modes[i].width == 1600 && modes[i].height == 1200 && modes[i].bpp == 32) { displayMode = modes[i]; break; } } Display.create(displayMode, true, displayName); gl.create(); org.lwjgl.input.Mouse.create(); Keyboard.create();
gl.shadeModel(GL.SMOOTH); gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.clearDepth(1.0); gl.enable(GL.DEPTH_TEST); gl.depthFunc(GL.LEQUAL); gl.matrixMode(GL.PROJECTION); glu.perspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 100.0f); gl.matrixMode(GL.MODELVIEW); gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); if (org.lwjgl.opengl.GL.WGL_EXT_swap_control) gl.wglSwapIntervalEXT(1); } |