Java3D HiDPI canvas in Java 9

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Java3D HiDPI canvas in Java 9

runiter
I'm experimenting with running Java3D in Java 9.
It works fine except the canvas panel is shrunk to 1/4 of what it should be.

In ardor3d there was a similar problem but I could fix that by simply calling this:

canvas.setSurfaceScale(new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE });

However I couldn't find any equivalent method to setSurfaceScale() in Java3D.

Any suggestions is appreciated.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

gouessej
Administrator
Hi

Java3D doesn't directly override JOGL canvases and windows unlike JogAmp's Ardor3D Continuation, it's a fundamental difference between them. Therefore, don't expect to find a trivial workaround except if you succeed in disabling HiDPI within AWT or Java2D:
-Dsun.java2d.dpiaware=false

Good luck.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

runiter
Thanks gouessej,

But I noticed that Java3D works fine in Mac OS X in Retina display. Doesn't that mean that a similar technique to canvas.setSurfaceScale is already implemented in Java3D? Looks like it's just missing in Windows.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

gouessej
Administrator
No, no similar technique is implemented in Java3D because it can't be implemented in Java3D. Your supposition is completely absurd, sorry to be harsh. Canvas3D and JCanvas3D don't extend JOGL canvases and have remained mostly unchanged for years, they both were written lots of years before the release of the first hardware supporting HiDPI and a long time before it became supported by OpenJDK and Oracle Java.

Keep in mind that the support of HiDPI depends on the version of the operation system and on the version of Java. Moreover, it depends on Java2D too, it can fail to detect it, the stability of this feature depends on the maturity of the JRE.

As far as I know, the JEP 263 concerns HiDPI support in Windows and Linux, HiDPI was already supported under OS X in Java 1.8. I can't be 100% sure but I think that either HiDPI is disabled when you run Java3D on your Mac or HiDPI is enabled and AWT returns the right information only under OS X but not under Windows.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

runiter
gouessej wrote
I can't be 100% sure but I think that either HiDPI is disabled when you run Java3D on your Mac or HiDPI is enabled and AWT returns the right information only under OS X but not under Windows.
I think it's the latter because usually when HiDPI is disabled I notice swing components become blurry, but they look crisp sharp in my case.

In any case, thanks for the info. I guess I won't upgrade to Java 9 yet.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

gouessej
Administrator
Which build have you tried? Please be very accurate.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

runiter
In Windows I'm tried both the latest version and older version from 2 years ago.

The latest version I used is: Java3D 1.7 and JOGL 2.3.2

In Mac I didn't upgrade to the latest version because the old version was fine. So I'm not sure if the latest version still works in Mac. I can try it when I return home (I'm away in Canada right now).
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

hharrison
There were some workarounds added to the Java3d jogl backend to work on retina displays, so it's likely still working for OSX because of that.
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

runiter
Thanks Harrison, that would explain it.
I wonder how difficult it is to apply the same workaround to Windows HiDPI.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

philjord
Sorry for not jumping in earlier on this topic, but I've never had a need to use HiDPi scaling.

An intial look at the code doesn't show me anything that make OSX work with this scale.

I would expect it to be in Screen3D or maybe something related to DrawingSurfaceObject or GraphicsConfigInfo.
Possibly it's already in GraphicsConfiguration and just needs to be used when creating the context.

I'll look through the commits on github and see if I can see anything about this.

If I can't find anything existing now I'll have to examine Ardor3D and try to retro fit that solution into Java3D. However which version number it will be released under will be a problem. 1.6 is fixed now, but 1.7 requires major changes to package names to adopt...
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

gouessej
Administrator
JogAmp's Ardor3D Continuation exposes the pixel scale which can't be done in Java3D as it uses its own canvases instead of those of JOGL.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

runiter
In reply to this post by philjord
Thanks Phil,
It'd be great if it's possible to make Java3D work like Ardor3D. Hopefully it's possible. The internal workings of Java3D is a mystery to me.
Saeid Nourian, Ph.D. Eng. | Graphing Calculator 3D
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

hharrison
In reply to this post by philjord
My dim memory of it is that the workarounds are in JoglPipeline itself.
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

Ian Brown
In reply to this post by philjord
Hi Phil, the fix for this is actually pretty trivial.
I rasied a PR on the 1.6 base to demonstrate: https://github.com/hharrison/java3d-core/pull/24/files

You just need to account for the scaling in the graphic object passed to the paint function in the component. The original code assumes it will be always 1.

Ian
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

gouessej
Administrator
Yes, that's the only advantage of using directly the Swing and AWT canvases within Java3D, the HiDPI works as expected simply by taking to account the scaled size which is exactly what Ian does in his fix :)

The only remaining stuff to fix is the part depending on NEWT used in Java3D 1.7.0, Canvas3D and JCanvas3D should work as expected.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

Manu
In reply to this post by Ian Brown
I tried Ian's patch and it worked like a charm in Sweet Home 3D with Java 10

hharrison, would you agree to integrate Ian's patch in Java 3D 1.6 and release a new version 1.6.0.1 or 1.6.1?
This is really a blocking issue for anyone running Java 3D on a HiDPI screen with Java 10...
Emmanuel Puybaret
Reply | Threaded
Open this post in threaded view
|

Re: Java3D HiDPI canvas in Java 9

gouessej
Administrator
In principle, we only maintain the very latest version which is Java3D 1.7.0 but Harvey is free to do whatever he wants.
Julien Gouesse | Personal blog | Website