Hi, I’m new and I’m playing around with the basic project, and I have the following problem. I would like to set the game’s full screen resolution myself depending on the the actual computer screen, without using a splash screen. So long as I have the splash screen display it seems to work fine, but when I turn off the splash screen using the setShowSettings(false) method I get a runtime exception from the LWJGL. Here’s my code as it stands and then the stack trace I’m getting:
public class Main extends SimpleApplication {
private static Main applicationInstance = new Main();
private static AppSettings configurationInstance = new AppSettings(true);
public static void main(String[] args) {
getLargestFullScreenResolutionAllowed();
configurationInstance.setFullscreen(true);
configurationInstance.setSamples(2); // anti-aliasing
configurationInstance.setTitle("Playing Around"); // branding: window name
applicationInstance.setShowSettings(false);
applicationInstance.setSettings(configurationInstance);
applicationInstance.start();
}
private static void getLargestFullScreenResolutionAllowed() {
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
DisplayMode[] modes = device.getDisplayModes();
DisplayMode largestMode = findLargestDisplayMode(modes);
configurationInstance.setResolution(largestMode.getWidth(), largestMode.getHeight());
configurationInstance.setBitsPerPixel(largestMode.getBitDepth());
configurationInstance.setFrequency(largestMode.getRefreshRate());
}
private static DisplayMode findLargestDisplayMode(DisplayMode[] modes) {
int lastModeArea = 0;
DisplayMode lastBiggestMode = null;
for (DisplayMode mode : modes) {
int modeArea = mode.getHeight() * mode.getWidth();
if (modeArea > lastModeArea) {
lastBiggestMode = mode;
lastModeArea = modeArea;
}
}
if (lastBiggestMode == null) {
return modes[0];
}
return lastBiggestMode;
}
}
The stack trace for the Runtime Exception is such:
java.lang.RuntimeException: Unable to find fullscreen display mode matching settings
at com.jme3.system.lwjgl.LwjglDisplay.createContext(LwjglDisplay.java:79)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)
Aug 13, 2015 9:04:32 AM com.jme3.system.lwjgl.LwjglAbstractDisplay run
SEVERE: Display initialization failed. Cannot continue.
Basically I’m wondering why I the display fails initialization when there is no splash screen?