kirides / GD3D11

D3D11-Renderer for Gothic and Gothic 2
GNU General Public License v3.0
200 stars 18 forks source link

GUI should be DPI-aware #168

Open Reveares opened 2 weeks ago

Reveares commented 2 weeks ago

To Reproduce Monitor with 3840x2160 resolution, 27 inches and 150% scaling in Windows. Also in Systempack Scale=1.5. With the systempack setting everything is rendered correctly in Gothic, but all menus from GD3DD11 do not change their scaling.

Expected behavior The scaling setting from the Systempack could be used. The preferred solution would be for GD3DD11 to implement the corresponding high-DPI APIs so that manual specification of the scaling is no longer necessary.

Screenshots grafik grafik

kirides commented 2 weeks ago

Games are usually not DPI aware, but use a fixed/scalable UI size.

I'm working on getting such to work

It looks promising so far, though a bunch of calculations which were already off are now off plus scaled :D

grafik grafik

Reveares commented 2 weeks ago

Games are usually not DPI aware, but use a fixed/scalable UI size.

Modern games are DPI aware - they have to be if they are cross-platform when it comes to smartphone, tablet, laptop, PC or TV screens. Or if you have several monitors with different DPI on your PC and move the window around. That's why the High DPI API from windows is very practical. But of course, normally the GUI lib should take care of this. I had a quick look in AntTweakBar and the lib doesn't look very lively.

Nice that you are looking into this!

Reveares commented 2 weeks ago

I found another issue in this regard with the default resolution of GD3DD11, because GetClientRect is not DPI aware and returns 2560x1440 for my setup. https://github.com/kirides/GD3D11/blob/053172fce4055a5a46818c92ed046355dbe45f9b/D3D11Engine/GothicGraphicsState.h#L655-L659 Should I look into this or are you already updating every DPI dependent aspect?

kirides commented 2 weeks ago

yea, "AntTweakBar" (CTRL+F11) itself only barely supports "high dpi" by upscaling fontsizes and the renderers own d2d11 interface (F11) doesn't support any dynamic sizing at all.

luckily in d2d11 world, scaling something is clean and sharp. But correcting all calculations and adding a scaling factor (96/DPI) is a bit of hit and miss.

if i were to force DPI aware manifests with the renderer, a bunch of union plugins which use windowing apis would break, as windows usually accomodates for "no high dpi support" by doing the transformations for the application. Like Union/Systempack itself for the UI Scaling, it doesn't depend on DPI but merely scales the UI by the specified factor.

Thus my only choice to correct this while being as compatible as possible with future and past OSes is to ignore "correct DPI awareness" but implement it anyway