JOGL broken with JRE>8 and Windows window-scaling

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

JOGL broken with JRE>8 and Windows window-scaling

nyxcode
I'm just learning OpenGL using JOGL and, after dozens of hours of debugging, I think I found a bug..
When using the window scaling feature of windows (usefull for small high-resolution screens, laptops, ..) and Java 9 or 10 (Java 8 works fine though) the AWT Frame scales (when using 125% scaling a 500x500 Frame will be 625x625) but the GLCanvas doesnt.

Java 8, everything works as expected: https://prnt.sc/kjf9fp
Java 10, the window is 25% larger and has a nasty black border at the right and the top: https://prnt.sc/kjf9zq

Is this a known bug? Does anyone know of a workaround?
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

nyxcode
If it was possible to get the scaling factor (or the "true" size of the window), I could do something like
glViewport(0, 0, width * scalingFactor, height * scalingFactor)



Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

gouessej
Administrator
In reply to this post by nyxcode
Hello

You can simply disable the HiDPI support by setting the system property "sun.java2d.dpiaware" to false (or use "-Dsun.java2d.dpiaware=false" as a VM argument).
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

nyxcode
Thanks for your response!

I tried your suggestion with HotSpot build 10.0.2+13 and OpenJDK Zulu build 9.0.7.1+1 - both without success.
Am I missing something? I have read multiple times that this system property did not work on 1.8 - which is confusing since I didn't have any problems with 1.8.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

gouessej
Administrator
You have to set it very early to give it a chance to work, it's mentioned in the source code in sun.java2d.windows.WindowsFlags. How did you try it?

Edit.: The flag still exists in the source code and works with Java 1.10.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

nyxcode
I am not sure what part of the source you are refering to.. I couldn't find any instructions there.. Could you clarify what you mean with "very early"?

So far I have set the flag through a vm parameter - System.getProperty() confirms that it has been set successfully.

Edit: this worked out for me. I would definetly prefer an other solution though..
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

gouessej
Administrator
I'm referring to the source code of OpenJDK.

Thank you for sharing your workaround. I see no other solution for now, xerxes mentioned some changes we have to do in JOGL to take into account HiDPI under Windows, I wrongly assumed that it was already done, it's not trivial, we have to use two different APIs to handle HiDPI under Windows >= 10 and Windows < 10.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

nyxcode
Ah - I almost thought I was too stupid to pass a VM flag ^^

Thanks for investigating this. I'll stick with 1.8 (using Kotlin anyways) for now!
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

gouessej
Administrator
By the way, AdoptOpenJDK provides OpenJDK builds too, I use their OpenJDK 1.8 builds for my own projects.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

Martin
Hi!

I am having a similar problem : my application running on windows 10+jre 10 is scaled by HiDPI.

As describe in this jzy3d issue, I wasn't able to avoid scaling with the JVM flag mentionned above. I was however able to remove the buggy scaling using Windows configuration (see my post).

This Windows configuration workaround is not satisfying for me since it desactivates HiDPI for the complete application, I hence loose all rendering improvements on widgets, text, etc.

Is there a mean to avoid inappropriate GL scaling for the GL canvas only - without changing whole the application? 

Thanks in advance,

Martin
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

Marcel
This post was updated on .
Hello Martin,

which canvas do you use. I was able to workaround the scaling issues (OpenJDK 12) on NewtCanvasSWT by introduce an SWT scaling.

I also patched the SWT_AWT class for Windows introducing a wrong layout, see (only 200% but not 150% works in SWT):

https://bugs.eclipse.org/bugs/show_bug.cgi?id=545265

You might also play with the following java vm arg settings to scale Swing/Awt (AWT has still some issues):

-Dsun.java2d.uiScale=2.0

see (in one answer):

https://superuser.com/questions/988379/how-do-i-run-java-apps-upscaled-on-a-high-dpi-display

It might be that the GLCanvas (client area) must be scaled, too, to make an appropriate layout, see:

https://github.com/sgothel/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java

As afore mentioned on SWT I did this with the Dpi API: DPIUtil.autoScaleUp(getClientArea());

which I thin only allows 200%, 300% settings so a zoom factor would be more appropriate.



Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

Martin
Thanks you for these hints!

I am using the AWT GLCanvas. Do you have a similar solution for non SWT canvases? The DPIUtil class seem to work in SWT only environments?

To my memory, NewtCanvasAwt was attempted as an alternative but had the same problem. I need to verify that point.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

gouessej
Administrator
There is no miraculous solution. HiDPI isn't handled correctly within JOGL on some platforms including Windows. Don't expect a quick fix, sorry.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

Sven Gothel
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

Martin JANDA
I would like to ask about plans for fixing this issue for AWT GLCanvas and GLJPanel in next release.
Thank you
   Martin
Reply | Threaded
Open this post in threaded view
|

Re: JOGL broken with JRE>8 and Windows window-scaling

gouessej
Administrator
Hello

As far as I understand, some problems on HiDPI will only be solved in JOGL 2.5, not in JOGL 2.4.
Julien Gouesse | Personal blog | Website