// time to create the OpenGL Graphics Engine
if (fullscreen) {
// fullscreen mode
JOGLFullScreenMode mode = null;
try {
// using reflection to load the class, this is a work around
// to
// avoid
// JOGL static initialization exception when JOGL library is
// not
// included in the bundle, when the game is not using JOGL
// graphics engine
Class joglClass = Class
.forName("com.golden.gamedev.engine.jogl.JOGLFullScreenMode");
Constructor joglConstructor = joglClass
.getConstructor(new Class[] {
Dimension.class, boolean.class
});
mode = (JOGLFullScreenMode) joglConstructor
.newInstance(new Object[] {
d, new Boolean(vsync)
});
mode.getFrame().removeWindowListener(
WindowExitListener.getInstance());
mode.getFrame().addWindowListener(this);
this.gfx = mode;
}
catch (Throwable e) {
// the first exception is
// the exception because of class creation via reflection
// we need to know what is the actual exception!
if (e.getCause() != null) {
e = e.getCause();
}
e.printStackTrace();
JOptionPane.showMessageDialog(null,
"ERROR: Entering JOGL FullScreen Mode\n"
+ "Caused by: " + e.toString(),
"Graphics Engine Initialization",
JOptionPane.ERROR_MESSAGE);
// fail-safe
fullscreen = false;
if (mode != null) {
mode.cleanup();
}
}
}
if (!fullscreen) {
// using reflection to load the class, this is a work around to
// avoid
// JOGL static initialization exception when JOGL library is not
// included in the bundle, when the game is not using JOGL
// graphics
// engine
Class joglClass = Class
.forName("com.golden.gamedev.engine.jogl.JOGLWindowedMode");
Constructor joglConstructor = joglClass
.getConstructor(new Class[] {
Dimension.class, boolean.class
});
JOGLWindowedMode mode = (JOGLWindowedMode) joglConstructor
.newInstance(new Object[] {
d, new Boolean(vsync)
});
mode.getFrame().removeWindowListener(
WindowExitListener.getInstance());
mode.getFrame().addWindowListener(this);
this.gfx = mode;
}
this.game = game;