|
From: <tre...@us...> - 2008-02-26 19:43:58
|
Revision: 773
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=773&view=rev
Author: trevorolio
Date: 2008-02-26 11:43:02 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
Making the graphics configuration process a little more resilient to failure.
Modified Paths:
--------------
maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
Modified: maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java
===================================================================
--- maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-26 17:32:44 UTC (rev 772)
+++ maven/trunk/ogoglio-common/src/main/java/com/ogoglio/viewer/j3d/J3DRenderer.java 2008-02-26 19:43:02 UTC (rev 773)
@@ -108,7 +108,7 @@
private boolean rendererStopped = false;
private boolean completedInitialLoad = false;
-
+
private boolean memoryNotificationSent = false;
private J3DDataManager dataManager = null;
@@ -132,9 +132,21 @@
setCapabilities(tempCameraGroup);
GraphicsConfiguration graphicsConfig = getGraphicsConfiguration(offScreen);
if (graphicsConfig == null) {
- throw new IllegalStateException("Cannot create a 3D graphics configuration.");
+ throw new IllegalStateException("Can not set up 3D graphics.");
}
- canvas = new J3DCanvas(graphicsConfig, offScreen);
+ try {
+ canvas = new J3DCanvas(graphicsConfig, offScreen);
+ } catch (Exception e) {
+ Log.debug("Could not load first pass graphics config: " + e);
+ }
+ if (canvas == null) {
+ //try the minimal graphics configuration, but if we fail we fail
+ graphicsConfig = getGraphicsConfiguration(true);
+ if (graphicsConfig == null) {
+ throw new IllegalStateException("Can't create a 3D graphics viewer.");
+ }
+ canvas = new J3DCanvas(graphicsConfig, offScreen);
+ }
camera = new J3DCamera();
}
@@ -354,7 +366,7 @@
return;
}
ThingRenderable renderable = getThingRenderable(thing.getThingID());
- if(renderable == null){
+ if (renderable == null) {
Log.warn("Got a started call for a thing with no renderabl: " + thing.getThingID());
return;
}
@@ -437,7 +449,7 @@
renderable.playAnimation(BodyConstants.SIT_ANIMATION_NAME, false, false);
return;
}
- if(getUserRenderable(user.getUsername()) != null){
+ if (getUserRenderable(user.getUsername()) != null) {
return;
}
usersGroup.addChild(renderable);
@@ -746,7 +758,7 @@
for (int i = 0; i < attachments.length; i++) {
J3DAttachment j3dAttachment = new J3DAttachment(attachments[i], dataManager);
renderable.attach(j3dAttachment);
- }
+ }
return renderable;
}
@@ -765,12 +777,12 @@
private ThingRenderable createThingRenderable(Thing thing, boolean useCache) throws IOException, RenderableParseException {
J3DRenderableLoader loader = new J3DRenderableLoader(dataManager.getTemplateData(thing.getTemplate().getOwnerUsername(), thing.getTemplate().getTemplateID(), useCache));
-
+
if (dataManager.maxMemoryUsed() && !memoryNotificationSent) {
- notifyMaximumMemoryUsed();
- memoryNotificationSent = true;
+ notifyMaximumMemoryUsed();
+ memoryNotificationSent = true;
}
-
+
J3DThingRenderable renderable = loader.loadThing(thing);
renderable.setPosition(thing.getPosition());
@@ -783,19 +795,22 @@
return renderable;
}
- public static GraphicsConfiguration getGraphicsConfiguration(boolean offscreen) {
+ public static GraphicsConfiguration getGraphicsConfiguration(boolean minimal) {
GraphicsConfigTemplate3D configTemplate = new GraphicsConfigTemplate3D();
- configTemplate.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
- configTemplate.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
- if (!offscreen) { //it appears that these lines hose up an EC2 instance running j3d
+ if (!minimal) { //it appears that these lines hose up an EC2 instance running j3d
+ configTemplate.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
+ configTemplate.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
configTemplate.setBlueSize(8);
configTemplate.setRedSize(8);
configTemplate.setGreenSize(8);
+ } else {
+ Log.debug("Using minimal graphics configuration");
}
GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(configTemplate);
if (config != null) {
return config;
}
+ Log.debug("Could not use graphics config template. Using default configuration.");
//fall back to whatever Java3D picks, which even on great cards looks like crap
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|