JOGL broken with JRE>8 and Windows window-scaling

classic Classic list List threaded Threaded
9 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