Solved

Java 3D Graphics: JVM hangs in Canvas3D constructor

Posted on 2003-11-17
3
301 Views
Last Modified: 2010-03-31
Hi,

I am trying to create a simple graphics configuration and pass it to the Canvas#D constructor but the jvm hangs forever in the constructor and never reaches the next statement.

I have tried all the following ways without any luck.  I am a beginner in 3D java graphics, any help would be very much appreciated.

-----
Tried the following 3 ways without luck:

/* first try*/
GraphicsConfigTemplate3D template3d = new GraphicsConfigTemplate3D();
    GraphicsConfiguration[] arrConfig = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getConfigurations();
    GraphicsConfiguration config = template3d.getBestConfiguration(arrConfig);
Canvas3D canvas3D = new Canvas3D(config); //hangs here forever

/* second try */
GraphicsConfiguration config =                        SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(config); //hangs here forever

/* Third try */
GraphicsConfigTemplate3D template3d = new GraphicsConfigTemplate3D();
GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template3d);
Canvas3D canvas3D = new Canvas3D(config); //hangs here forever

/* Fourth try */
Canvas3D canvas3D = new Canvas3D(null);// this doesn't work since I am using a newer version that doesn't allow passing null for GraphicsConfiguration.  Hence I get an error message.

--------------


0
Comment
Question by:mschumacher74
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
ID: 9771417
According to: http://www.j3d.org/tutorials/raw_j3d/chapter1/world_window.html

you should do:

GraphicsConfigTemplate3D tmpl = new GraphicsConfigTemplate3D();
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();
GraphicsConfiguration config = device.getBestConfiguration( tmpl );
canvas = new Canvas3D( config );

which seems to be your "Third try"

----------

A lot of other examples seem to use:

    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D c = new Canvas3D(config);

using the SimpleUniverse (from com.sun.j3d.utils.universe.* I think)

Tim
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 194
How to monitor the number of connections/threads being utilized on Tomcat 6.0 8 70
ForLoop Example 3 48
type mismatch (Object[] to double[] 4 24
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question