I am getting the following exception in a Java app:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
Canvas3D: GraphicsConfiguration is not compatible with Canvas3D
at javax.media.j3d.Canvas3D.checkForValidGraphicsConfig(Canvas3D.java:965)
at javax.media.j3d.Canvas3D.<init>(Canvas3D.java:1032)
...etc...
Canvas3D is being instantiated like this:
GraphicsConfiguration graphicsConfiguration = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(graphicsConfiguration);
This code is working correctly on one machine (HP dc7900 desktop), but not a couple of newer ones (HP 630 laptops). All running XP.
The API docs say that this exception means that "the specified GraphicsConfiguration does not support 3D rendering". What does that mean? The 'preferred configuration' is presumably gained from the OS, and so reflects what's actually possible... but I'm a bit lost.
A bug report suggests this code as an alternative:
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(template);
Canvas3D c3d = new Canvas3D(gc);
But it doesn't change anything.
Similar problems seem to have been solved by modifying graphics adapter settings or selecting different renderers, e.g.: reducing bit depth to 16, or running java with -Dj3d.rend=d3d
, but doing so doesn't change anything.
It turns out that it was simply a Java version incompatibility: I downgraded to 1.6, from 1.7, and everything worked correctly.