Solved

Java 3D Graphics: JVM hangs in Canvas3D constructor

Posted on 2003-11-17
3
285 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now