Currently if you start the game with SP enabled Windows provide DPI virtualization for the window size. This is done to SP using GetMonitorInfoW and MonitorFromWindow to position the game's window. Without marking the thread as DPI aware it gives back virtual sizes and then Windows scales the game's window itself to match the real size later on.
This gives a blurry result because SP draws the game at the virtual resolution Windows gave it. Fixing parts of this is fairly simple, I've already done some rough tests in a local branch.
We could easily just mark the game's thread as DPI aware, this would solve the blurriness but would create big problems for actual high DPI displays.
A better solution would be to actually implement DPI scaling for the game. The first part of doing this is easily done, pass back a virtual resolution to the game ourselves and then actually draw the game at a higher resolutions. This would require some touch ups in some places like the fixedfunctionshaders and StretchRect but overall would be manageable.
The problems start once we get to UI rendering. The game's bitmap fonts and UI elements are not intended to be drawn at high DPIs. We can kind of get away with cubic sampling for the UI elements but text just looks downright bad. Meaning if we want to look good at high DPIs we need to replace the game's fonts with one's we've rendered based on the current DPI. Mods would continue to be screwed sadly.
The best thing I can think of might be to introduce a custom material specifically for font rendering then we replace the game's fonts with that whenever it loads core.lvl like we do for shaders already.
Solving this properly is probably going to take a fair amount of work but I think it is worth looking into.
Currently if you start the game with SP enabled Windows provide DPI virtualization for the window size. This is done to SP using
GetMonitorInfoW
andMonitorFromWindow
to position the game's window. Without marking the thread as DPI aware it gives back virtual sizes and then Windows scales the game's window itself to match the real size later on.This gives a blurry result because SP draws the game at the virtual resolution Windows gave it. Fixing parts of this is fairly simple, I've already done some rough tests in a local branch.
We could easily just mark the game's thread as DPI aware, this would solve the blurriness but would create big problems for actual high DPI displays.
A better solution would be to actually implement DPI scaling for the game. The first part of doing this is easily done, pass back a virtual resolution to the game ourselves and then actually draw the game at a higher resolutions. This would require some touch ups in some places like the fixed function shaders and StretchRect but overall would be manageable.
The problems start once we get to UI rendering. The game's bitmap fonts and UI elements are not intended to be drawn at high DPIs. We can kind of get away with cubic sampling for the UI elements but text just looks downright bad. Meaning if we want to look good at high DPIs we need to replace the game's fonts with one's we've rendered based on the current DPI. Mods would continue to be screwed sadly.
The best thing I can think of might be to introduce a custom material specifically for font rendering then we replace the game's fonts with that whenever it loads core.lvl like we do for shaders already.
Solving this properly is probably going to take a fair amount of work but I think it is worth looking into.