> Date:         Mon, 15 Apr 2002 12:53:09 +0200
> From: Gustaf Duell <[EMAIL PROTECTED]>
>
> I hope someone of you can help me on this issue.  I am working with two
> monitors on my computer and I can only get J3D to work on one of the screens.
> If I start the window on screen one the java 3d is working, if I move the
> window to screen two it freezes and if I then move back to screen one I get a
> bluescreen. (I use w2k, sp 2)

Success in using accelerated 3D graphics on a virtual screen is
unfortunately system and driver dependent.  (By virtual screen I mean one
which allows contiguous pixel addressing across two or more physical
screens, and allows you to move windows from one screen to another and
straddle screen edges with them).  On Unix systems this capability is
provided by the Xinerama extension to the X11 Window System, and most 3D
graphics drivers designed for Unix and OpenGL these days will work with
Xinerama transparently.  Apple and Windows computers have their own systems
which may or may not work with a particular 3D graphics card driver.

Java 3D does very little in particular to support virtual screens and relies
mostly on the Java AWT and the underlying hardware drivers to handle the
situation.  You might have better luck with Direct3D drivers than with
OpenGL drivers for your graphics accelerators; there is explicit support for
virtualizing multiple monitors in D3D, although the drivers may fall back to
software emulation for cases in which a window straddles two or more
screens.

> If I start the window on screen two the J3D is just the grey background and
> if I move the window to screen one it works.

It sounds like you are creating a Canvas3D using the GraphicsConfiguration
for screen one and that your computer setup doesn't support 3D graphics
acceleration on a virtual screen.  In that case you will only be able to get
an image when the window is on the same screen from which you retrieved the
GraphicsConfiguration.

> I do not know if it is due to the second screen's graphics card or because
> of the new SW versions. In a previous versions it worked but it was with a
> different computer, different graphics cards and JDK1.3 and J3D 1.2.1_03.
> Now I am using JDK1.4 and J3D 1.2.1_04. The first screen is using a GeForce3
> and the second screen a GeForce 2 card.

You should use JDK 1.4 and Java 3D 1.3 for the best chance of success if you
want to use virtual screens.  JDK 1.3 was supposed to provide separate
GraphicsConfigurations for each physical screen in a virtual screen setup,
but there was bug in the release that prevented Java 3D 1.2 and other JDK
1.3 clients from retrieving anything other than the graphics configuration
for the default screen.  The bug was fixed in JDK 1.4 and Java 3D 1.3 was
then updated to provide correct virtual screen support.

Your chance of success will probably improve if you use the same model
graphics card for each screen as well.

If you are able to disable virtual screen support (so that each physical
screen is independent and windows can't straddle screens or cross from one
to the other), then you should be able use JDK 1.3 to obtain a separate
GraphicsConfiguration for each screen and create a Canvas3D from it for use
by Java 3D 1.2.

> The first thing I am thinking of is how do I get the GraphicsConfiguration
> for the screen the window should appear on?
> To start the J3D I get a GraphicsConfiguration with:
> GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration()
> The documentation on "getPreferredConfiguration" says:
>         "Finds the preferred GraphicsConfiguration object for the system.
> This object can then be
>         used to create the Canvas3D objet for this system.
>         Returns: The best GraphicsConfiguration object for the system."

getPreferredConfiguration() calls getBestConfiguration() on the default
screen device returned by getDefaultScreenDevice().  The default screen
device is system dependent, but is usually the 1st or top left-most screen.
If your system supports 3D acceleration on virtual screens, then with this
configuration you will be able to create a Canvas3D on the default screen
and move it to any other screen; if not, then the Canvas3D will work
properly only on that default screen.

> But if the screen where i want the J3Dwindow is not the best
> GraphicsConfiguration but the second best? How do I decide which
> GraphicsConfiguraion I want to use?
> In normal Java I select screen by getting an array with the displays in with
> the function:
> abstract GraphicsDevice[] GraphicsEnvironment.getScreenDevices()
> and from each on of the elements (screens) in the array I can get the
> GraphicsConfiguration with
> abstract GraphicsConfiguration  = GraphicsDevice .getDefaultConfiguration()
> But this type of GraphicsConfiguration  does not work with J3D, only the
> GraphicsConfiguration  that I get from
> SimpleUniverse.getPreferredConfiguration() works.

You're doing everything right here except that you need to call
getBestConfiguration() with a GraphicsConfigTemplate3D instead of just
calling getDefaultConfiguration().  GraphicsConfigTemplate3D selects for
configurations that support the 3D capabilities that Java 3D requires.  You
can also use GraphicsConfigTemplate3D to select for any other special
capabilities you require in your application, such as stereo or scene
antialiasing.  But note, this will only work with JDK 1.4 and Java 3D 1.3 if
you're using a virtual screen; with earlier versions you'll only get the
graphics configuration for the default screen.

Also note, if your application is for something like a CAVE with a
non-planar arrangement of screens, then you must obtain a separate graphics
configuration for each physical screen as above instead of using the
graphics configuration of the default screen for each Canvas3D (from
something like a call to getPreferredConfiguration()).  A Screen3D class in
Java 3D is only created for each unique GraphicsConfiguration, and separate
Screen3D instances are needed in order to specify the orientation of each
physical screen.

-- Mark Hood

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to