int x = settings.getResolutionX();
int y = settings.getResolutionY();
int frequency = settings.getFrequency();
try {
DisplayMode modes[] = org.lwjgl.util.Display.getAvailableDisplayModes(x, y, x, y, 32, 32, frequency,
frequency);
DisplayMode mode = null;
if (modes.length > 0)
mode = modes[0];
if (mode == null) {
Sys.alert("Error", "Display mode not supported. Switchting to desktop display mode.");
// use desktop display mode
mode = Display.getDesktopDisplayMode();
x = mode.getWidth();
y = mode.getHeight();
frequency = mode.getFrequency();
modes = org.lwjgl.util.Display.getAvailableDisplayModes(x, y, x, y, 32, 32, frequency, frequency);
if (modes.length > 0)
mode = modes[0];
else {
Sys.alert("Fatal Error", "No valid display mode found.");
System.exit(1);
}
// set fullscreen because we use full resolution now
settings.setFullscreen(true);
}
Display.setDisplayMode(mode);
Display.setVSyncEnabled(settings.getVSync());
Display.setFullscreen(settings.getFullscreen());
Display.setTitle("PonkOut");
// load icons
ByteBuffer[] icons = new ByteBuffer[5];
icons[0] = Texture.getBytes("icon16.tga");
icons[1] = Texture.getBytes("icon32.tga");
icons[2] = Texture.getBytes("icon48.tga");
icons[3] = Texture.getBytes("icon64.tga");
icons[4] = Texture.getBytes("icon128.tga");
// set icons
Display.setIcon(icons);
// update settings
settings.setResolution(mode.getWidth(), mode.getHeight());
settings.setFrequency(mode.getFrequency());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}