Login  Register

SWT GLCanvas with DPI scaling in Eclipse

Posted by ChrisB on Jan 23, 2018; 1:07pm
URL: https://forum.jogamp.org/SWT-GLCanvas-with-DPI-scaling-in-Eclipse-tp4038566.html

When using high DPI displays, it is usually required to scale up UI and Text to keep things readable. Eclipse and SWT work fine. However, the GLCanvas included in jogl has some issues. When using a scale factor of 200%, only the lower left quarter of the GLCanvas is used. The cause of this was fairly easy to track down. The method com.jogamp.opengl.swt.GLCanvas.updateSizeCheck() retrieves the size of the canvas by calling org.eclipse.swt.widgets.Scrollable.getClientArea(). A quick look at the code shows that this method returns the scaled size. This means that GLCanvas treats the canvas smaller than it actually is.

Even worse, it appears that SWT has no public method for retrieving the actual size of a widget on screen. My current workaround is overwriting getClientArea for GLCanvas and scaling the size back to the original values.

I'm using jogl 2.3.2 and Eclipse Oxygen.
This help page explains how Eclipse treats scale settings and how to tweak them
https://www.eclipse.org/eclipse/news/4.6/platform.php#swt-autoscale-tweaks