pixels_per_unit question

15 views
Skip to first unread message

Gonzalo Garramuño

unread,
Aug 1, 2025, 9:20:24 PMAug 1
to fltkc...@googlegroups.com
In my Vulkan branch, I am not yet handling pixels_per_unit() properly.

I am wondering if one of the devs can show me where does the, for
example, Windows Desktop Scaling is retrieved.  I cannot locate the code
that does it.  And how does the pipeline for OpenGL pixels_per_unit() works.

--
ggar...@gmail.com

Manolo

unread,
Aug 2, 2025, 2:08:46 PMAug 2
to fltk.coredev
Function Fl_Screen_Driver::open_display() calls Fl_Screen_Driver::use_startup_scale_factor() that calls
function Fl_WinAPI_Screen_Driver::desktop_scale_factor() that calls function GetDpiForMonitor() for each display
that gives dpiX and dpiY. Then dpiX / 96. is the display's scaling factor returned by function Fl::screen_scale(nscreen)
and by function Fl_Gl_Window::pixels_per_unit() for the display containing the given GL window.

Gonzalo Garramuño

unread,
Aug 3, 2025, 7:48:29 PMAug 3
to fltkc...@googlegroups.com
Thanks, Manolo.  What was confusing me was that changing the DPI
dynamically with <Ctrl>+ or <Ctrl>- would call resize without the new
width/height values.  I had to keep an internal variable to check for
the old pixel ratio.

Also, for Vulkan, the rounding off pixel_w() and pixel_h() has to be
done down (ie - 0.5 not + 0.5 like OpenGL).  Now everything seems to be
working peachy.

--
ggar...@gmail.com

Reply all
Reply to author
Forward
0 new messages