mvdevs / jk2mv

JK2MV - improved, modernized JK2 client and server
https://jk2mv.org
GNU General Public License v2.0
108 stars 33 forks source link

Fix High DPI support #136

Closed aufau closed 4 months ago

aufau commented 4 years ago

In 1.4.1 High dpi support works correctly on Windows because it reports DPI as 96 * desktop scaling. It is not the case on X11, wayland and macos.

For a quick fix, revert jk2mv@a678ad2755dd155a52912b3a3c969c581e83efdb and Disable DPI console font.scaling on linux/macos.

  1. macos and wayland don't recognize jk2mv as being high dpi aware. For this special flag in SDL_CreateWindow() and a pinfo.list manifest variable on macos is required. Because of this, eg. on 4k display with desktop scaling 2x jk2mv sees native resolution as 1080p, renders at 1080p and is stretched to full screen. This means console font has correct size, although image is rendered at sub par resolution.
  2. X11 just renders jk2mv at native resolution, but DPI obtained from SDL is an actual monitor DPI, not desktop scaling. This means that with old method console font size is the same (measured physically on display) on 13 inch laptop that is usually viewed up close and on 4k tv you're watching from another end of the room. This is not correct, instead desktop scaling should be used.

SDL has a concept of "screen coordinates" for high dpi support (when conditions mentioned in 1. are met) and it seems to work on macos and wayland (wayland support is new in sdl and may be buggy). Find out if there is a better method for windows and X11 than using DPI (for reasons explained in 2.)

aufau commented 4 years ago

This branch: https://github.com/aufau/jk2mv/tree/wip/sdl_hidpi has code working on macos (sdl support for wayland seems broken for now, at least with opengl). The only problem is when you launch fullscreen with non-desktop resolution. It seems to be SDL bug (wrong opengl drawing size returned by SDL?) and I'm not very motivated to work on it anymore.

Non high-dpi mode works ok. Only that you can't get high resolutions.

aufau commented 4 months ago

Fixed in #138