Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java 3D Graphics: JVM hangs in Canvas3D constructor

Posted on 2003-11-17
3
Medium Priority
?
357 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

610 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