Got display problems here on linux with the error
java.lang.NullPointerException: mode must be non-null
at org.lwjgl.opengl.Display.setDisplayMode(Display.java:223)
at rtype.Prototyp.init(Prototyp.java:308)
at rtype.Prototyp.<init>(Prototyp.java:136)
at rtype.Prototyp.main(Prototyp.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:1272)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1218)
at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1065)
at com.sun.javaws.Launcher.run(Launcher.java:105)
at java.lang.Thread.run(Thread.java:619)
#### Java Web Start Error:
#### null
I would recommend you replace this code as it will not work every where
DisplayMode displayMode = null;
DisplayMode d[] = Display.getAvailableDisplayModes();
for (int i = 0; i < d.length; i++) {
if (d[i].getWidth() == SCREEN_WIDTH
&& d[i].getHeight() == SCREEN_HEIGHT
&& d[i].getBitsPerPixel() == 32) {
displayMode = d[i];
break;
}
}
Display.setDisplayMode(displayMode);
Display.setFullscreen(FULL_SCREEN);
Display.create();
The following will work nicely for you
replace the code above with
createWindow(SCREEN_WIDTH, SCREEN_HEIGHT, FULL_SCREEN) ;
and add this additional method to your tutorial
private void createWindow(int screenWidth, int screenHeight, boolean fullscreen) throws Exception {
//enable frame sync with refresh rate
//Display.setVSyncEnabled(true);
if (fullscreen) {
Display.setFullscreen(true);
try
{
DisplayMode dm[] = org.lwjgl.util.Display.getAvailableDisplayModes(320, 240, -1, -1, -1, -1, 60, 85);
org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
"width=" + screenWidth, "height=" + screenHeight, "freq=85",
"bpp=" + Display.getDisplayMode().getBitsPerPixel()
});
}
catch(Exception e)
{
Log.warning("Could not start full screen, switching to windowed mode", e);
Sys.alert("Error", "Could not start full screen, switching to windowed mode");
Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight));
}
}
// else create windowed mode
else {
Display.setDisplayMode(new DisplayMode(screenWidth, screenHeight));
}
// create display
Display.create();
}
hope it helps, should sort out the resolution problems you are having.