shinyquagsire23 / OpenJKDF2

A cross-platform reimplementation of JKDF2 in C
Other
493 stars 39 forks source link

Force resolution and/or make the app DPI aware in Windows #248

Open dgrdsv opened 1 year ago

dgrdsv commented 1 year ago

I was playing with the port yesterday (runs great btw, incredible job!) and ran into a convenience issue which should be fixed probably - the app seem to adhere to Windows DPI scaling even in rendering resolution which isn't good.

So my display is 4K/32" and I run Windows desktop at 125% scaling. This leads to OpenJKDF2 rendering in 3072x1728 by default without any way of forcing it into rendering in display native 3840x2160 resolution.

The only way to solve the issue is to switch Windows global scaling to 100% - which has to be done manually each time you run the OpenJKDF2.

I think that a simple way of solving this would be to provide a resolution selection option but if it is possible to make the app Windows DPI scaling aware - and ignore it if it's not 100% - then that would work too.

shinyquagsire23 commented 1 year ago

There's the SSAA multiplier in Display Settings that can be adjusted down, but I'll probably have to add a resolution selection box bc the SSAA gets confused for SSAO or whatever. So HiDPI and 0.5 SSAA would be half internal res. I usually do like, 0.8 to avoid cranking my laptop GPU.

dgrdsv commented 1 year ago

There's the SSAA multiplier in Display Settings that can be adjusted down, but I'll probably have to add a resolution selection box bc the SSAA gets confused for SSAO or whatever. So HiDPI and 0.5 SSAA would be half internal res. I usually do like, 0.8 to avoid cranking my laptop GPU.

But in this case the engine actually render in less than native resolution and it is stretched to native with pretty obvious artifacts.

I don't think that using SSAA would help because the front buffer resolution would remain the same, only the backbuffer would be supersampled. But I haven't tried this option tbh.

As I've said the most obvious option here would be to discard Windows scaling completely (i.e. not use Windows provided "virtual" resolution and use display native one instead).

I know it can be done because OpenJK does exactly that and it is using SDL2 as well I believe.

shinyquagsire23 commented 1 year ago

the most obvious option here would be to discard Windows scaling completely (i.e. not use Windows provided "virtual" resolution and use display native one instead).

I think the way to do that is to set HiDPI off and then there's some setting if you right click the EXE > Properties > Something under compatibility. Or use fullscreen maybe, I don't see any explicit SDL settings for adjusting the frontbuffer res. I could be missing something though.

On macOS, HiDPI off will have screen+pixel coordinates at the same size (but half res and scaled), HiDPI on had screen coordinates remain at half, but pixel coordinates/frontbuffer were native. It's kind of a mess and I'm not 100% sure how Windows reports things for scaling.

dgrdsv commented 1 year ago

I think the way to do that is to set HiDPI off

That's what I ended up doing. But it's quite an annoyance when you're playing in 8K on a 32" display.

and then there's some setting if you right click the EXE > Properties > Something under compatibility

Yes but it's either broken in current Win11 22H2 version or the app isn't affected by these settings for some reason. Basically there is no change if you set the scaling compatibility option to "Scaling performed by: Application".

Or use fullscreen maybe

All of this is about fullscreen.