henricj / dunelegacy

GNU General Public License v2.0
27 stars 5 forks source link

Ingame renders incorrectly unless game settings resolution matches display resolution #16

Open juj opened 2 years ago

juj commented 2 years ago

By default after a clean build, looks like Game Settings Resolution is set to 640x480.

However the game does not resize the system display to 640x480 mode (tested on Windows 10) but keeps it in desktop resolution (1920x1080 in my setup's case).

I don't know if it is intentional that it does not switch system screen resolution or not, or if the game is supposed to work on a "virtual" resolution of some kind.

However, when entering ingame with that default 640x480 mode when monitor has 1920x1080, the ingame UI is rendered incorrectly:

image

Also e.g. drag-selecting multiple units does not work, but one of the drag selection corners get clamped to 640x480 bottom right limits. In the above picture mouse selection box is being dragged towards bottom right of the screen, but the selection box corner does not follow the mouse, but clips/clamps at 640x480 coordinate.

juj commented 2 years ago

It looks like as a fix, when I set Video Resolution to match the system desktop resolution, then the issues go away. I.e. bad setting that resulted in the above screenshot:

image

Good setting for 1920x1080 desktop:

image

which results in a proper looking UI:

image

where mouse multiselect also works.

henricj commented 2 years ago

If you start in windowed mode and then switch to full screen with Alt-Enter, it should work better. The above-mentioned https://github.com/henricj/dunelegacy/commit/65514b0cf6bf623022f06873d3da3c0eb3d08c08 commit should make it okay to start in full screen mode.

The size of the top bar and the sidebar are both fixed when the screen is created. The process of reworking such components to render on the fly rather than creating a fixed-size static texture is ongoing, but those two haven't yet been converted (the was no support for on-the-fly window size changes or DPI changes until about a month ago).

henricj commented 2 years ago

It looks like as a fix, when I set Video Resolution to match the system desktop resolution, then the issues go away.

Yesterday, I added a stop-gap to use the actual window size instead of the setting size when drawing images, so the workaround you mention should no longer be needed (8edfc7e). Things will still not draw properly after a resize until all the pre-rendered bitmaps are replaced with on-the-fly rendering. E.g., the top bar is drawn here, but only when the GFXManager is initialized: https://github.com/henricj/dunelegacy/blob/8edfc7e62963c0df7456b08271970f0574a08f2c/src/FileClasses/PictureFactory.cpp#L247-L267 More stuff like this is needed.