Bad badder baddest!

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:


// Initialize Opengl
  
  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); // Enable Smooth Shading
    gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
    gl.clearDepth(1.0); // Depth Buffer Setup
    gl.enable(GL.DEPTH_TEST); // Enables Depth Testing
    gl.depthFunc(GL.LEQUAL); // The Type Of Depth Testing To Do
    gl.matrixMode(GL.PROJECTION); // Select The Projection Matrix

    // Calculate The Aspect Ratio Of The Window
    
    glu.perspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 0.1f, 100.0f);
    gl.matrixMode(GL.MODELVIEW); // Select The Modelview Matrix

    gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); // Really Nice Perspective Calculations

    if (org.lwjgl.opengl.GL.WGL_EXT_swap_control) gl.wglSwapIntervalEXT(1); // Sync with refresh rate of monitor
  }

Seems pretty simple to me. You’re requiring people to have 1600x1200 as a resolution (which most don’t) and thus you’re never getting a DisplayMode. How about you try 1024x768 and then tell us if there’s a problem?

oh lol :slight_smile: thanks g