Catch errors when initializing OpenGL and allow them to be displayed to

the user.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3573 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-05-24 17:48:10 +00:00
parent 04bd9c768a
commit 56deaa4982
+51 -31
View File
@@ -86,48 +86,59 @@ public class JmeApp
* to begin the rendering/event loop. Derived classes can override * to begin the rendering/event loop. Derived classes can override
* this, being sure to call super before doing their own * this, being sure to call super before doing their own
* initalization. * initalization.
*
* @return true if the application initialized successfully, false if
* initialization failed. (See {@link #reportInitFailure}.)
*/ */
public void init () public boolean init ()
{ {
// load up our renderer configuration try {
_properties = new PropertiesIO(getConfigPath("jme.cfg")); // load up our renderer configuration
readDisplayConfig(); _properties = new PropertiesIO(getConfigPath("jme.cfg"));
readDisplayConfig();
// create an appropriate timer // create an appropriate timer
_timer = Timer.getTimer(_properties.getRenderer()); _timer = Timer.getTimer(_properties.getRenderer());
// default to 60 fps // default to 60 fps
setTargetFrameRate(60); setTargetFrameRate(60);
// initialize the rendering system // initialize the rendering system
initDisplay(); initDisplay();
if (!_display.isCreated()) { if (!_display.isCreated()) {
throw new IllegalStateException("Failed to initialize display?"); throw new IllegalStateException("Failed to initialize display?");
} }
// initialize our main camera controls and user input handling // initialize our main camera controls and user input handling
initInput(); initInput();
// initialize the root node // initialize the root node
initRoot(); initRoot();
// initialize the lighting // initialize the lighting
initLighting(); initLighting();
// initialize the UI support stuff // initialize the UI support stuff
initInterface(); initInterface();
// update everything for the zeroth tick // update everything for the zeroth tick
_iface.updateRenderState(); _iface.updateRenderState();
_geom.updateRenderState(); _geom.updateRenderState();
_root.updateGeometricState(0f, true); _root.updateGeometricState(0f, true);
_root.updateRenderState(); _root.updateRenderState();
// create and add our statistics display // create and add our statistics display
if (displayStatistics()) { if (displayStatistics()) {
_stats = new StatsDisplay(_display.getRenderer()); _stats = new StatsDisplay(_display.getRenderer());
_stats.updateGeometricState(0f, true); _stats.updateGeometricState(0f, true);
_stats.updateRenderState(); _stats.updateRenderState();
}
return true;
} catch (Exception e) {
reportInitFailure(e);
return false;
} }
} }
@@ -327,6 +338,15 @@ public class JmeApp
InputSystem.getMouseInput().setCursorVisible(true); InputSystem.getMouseInput().setCursorVisible(true);
} }
/**
* Called when initialization fails to give the application a chance
* to report the failure to the user.
*/
protected void reportInitFailure (Exception e)
{
Log.logStackTrace(e);
}
/** /**
* Processes a single frame. * Processes a single frame.
*/ */