Solved

Java 3D Graphics: JVM hangs in Canvas3D constructor

Posted on 2003-11-17
3
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

726 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