FosterFramework / Foster

A small C# game framework
MIT License
450 stars 37 forks source link

App.ContentScale always returns (2,2) #9

Closed MrBrixican closed 1 year ago

MrBrixican commented 1 year ago

I imagine this is probably meant to return a value depending on the system/monitor.

I'm writing an ImGui.NET renderer for Foster and I imagine this is necessary to accurately display on a Mac (I do not own a Mac so I can't verify this).

NoelFB commented 1 year ago

Yeah, so in the old Foster this retrieved the DPI values from SDL2, however they were always a little bit weird and not necessarily correct. The SDL2 function is itself likely going to be removed/changed in the future.

For the meantime, I think what may make sense is to return the WidthInPixels / the Window Width, which on Mac will likely always be 2.0. What I usually end up doing with my own ImGui/Gui implementations is to include an actual user-scale setting that scales the UI, as automatically detecting it outside of the pixel scale just seems fairly inconsistent...

MrBrixican commented 1 year ago

Ah, that makes complete sense. I'll probably use (1f * App.WidthInPixels / App.Width, 1f * App.HeightInPixels / App.Height) as a primary scale and a multiplicative scale setting for adjustments.

NoelFB commented 1 year ago

I've pushed a change to ContentScale to use the Pixel size. Will close this for now, but I've written some comments for the ContentScale property to mention the reasoning & potential fixes in the future. (fd2c596)