}
// time to create the graphics engine
if (fullscreen) {
// fullscreen mode
FullScreenMode mode = null;
try {
mode = new FullScreenMode(d, bufferstrategy);
mode.getFrame().removeWindowListener(
WindowExitListener.getInstance());
mode.getFrame().addWindowListener(this);
this.gfx = mode;
}
catch (Throwable e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null,
"ERROR: Entering FullScreen Mode\n" + "Caused by: "
+ e.toString(),
"Graphics Engine Initialization",
JOptionPane.ERROR_MESSAGE);
// fail-safe
fullscreen = false;
if (mode != null) {
mode.cleanup();
}
}
}
if (!fullscreen) {
// windowed mode
WindowedMode mode = new WindowedMode(d, bufferstrategy);
mode.getFrame().removeWindowListener(
WindowExitListener.getInstance());
mode.getFrame().addWindowListener(this);
this.gfx = mode;
}
this.game = game;