Login  Register

Re: GLcanvas vs NEWT on Hi DPI Screens

Posted by Sven Gothel on Jan 24, 2023; 10:00pm
URL: https://forum.jogamp.org/GLcanvas-vs-NEWT-on-Hi-DPI-Screens-tp4041191p4042117.html

I added a comment in Bug 1374, detailing the procedure to read the custom pixel-scale.
See https://jogamp.org/bugzilla/show_bug.cgi?id=1374#c7

'pixel scale', an arbitrary scaling factor,
customized by the user, to please the eyes etc.
This in contrast to actual DPI naturally scaled rendering. 'true to scale'.

+++

Generic way to determine the OS's windowing system's so called 'pixel scale':

Windows:
  1a) GetDpiForMonitor(ddmon, MDT_EFFECTIVE_DPI, int *dpi_x, int *dpi_y)
    - NOTE: MDT_EFFECTIVE_DPI returns the custom user DPI setting
            according to user pixel scale setting (See above).
      This is not the true dpi, which NEWT already calculates
      per monitor by its size and resolution!
      (or attribute MDT_RAW_DPI here)

  or, if 1a is n/a

  1b) { dpi_x, dpi_y } = GetDeviceCaps(hdc, {LOGPIXELSX, LOGPIXELSX})
    - NOTE: Same for all monitors

  2) pixel_scale_x = (float)dpi_x / (float)96
     pixel_scale_y = (float)dpi_x / (float)96

Unix:
  0) See https://wiki.archlinux.org/title/HiDPI

  1) KDE Plasme: How to read the setup value?
    - System Settings > Display and Monitor > Display Configuration > Global Scale
    - range 100 - x00% in 25% steps, i.e. float

  2) Qt5: QT_SCREEN_SCALE_FACTORS, QT_SCALE_FACTOR, ...
  3) ...
  9) GDK3+ GTK3/4: int GDK_SCALE, an environment variable
    - NOTE: just an int type, not pleasing - from GDK3 world

  Note: JDK-17 seems to use GDK_SCALE only ..
  Note: We might end up using an AWT Compatibility mode
        - and - a proper pixel scale mode (when and if available)
  Note: Needs more investigation.

Debugging w/ AWT:
  X) float J2D_UISCALE, an environment variable
    - Windows: value is kept as float
    - Unix: valye is cut-off to int (duh!)


.. to be continued ..
.. additional note: On X11/Unix, well, we have a lot of options, i.e. even xrandr
using hw-accel scaling w/o need to interfere from our side as all gets scaled.