ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.66k stars 373 forks source link

Please add support for resolutions less than 640x480 #4346

Closed Wolod closed 2 years ago

Wolod commented 2 years ago

Preliminary checks

Describe the problem requiring a solution

Hello and thanks for your hard work!

I'm trying to play fhereos2 on a Chinese handheld console with a 3:2 screen that works in a 480x320 resolution. This resolution is the only available option when I run fheroes2 on my device. Game works completely fine but different crucial UI elements are hidden behind the screen. For example I can't start a new campaign or do different things inside my castle.

On the other hand I tested original HoMM2 in the dosbox pure emulator on my console and everything scaled properly.

Here's how incorrect UI scaling looks on my device.

IMG_20211009_143239 IMG_20211009_143305 IMG_20211009_143335 IMG_20211009_143537 IMG_20211009_143458

Describe the possible solution

I think my issue is related to the fact that minimal resolution that fheroes2 support is 640x480.

Additional info

My device is called Anbernic RG351P and I use ArkOS firmware that is based on Ubuntu. So basically I'm trying to play Ubuntu version of fheroes2 on my console.

ihhub commented 2 years ago

Hi @Wolod , we aren't going to support any resolutions lower than the original 640x480.

Wolod commented 2 years ago

Sad to hear that. Anyway thanks for the quick response @ihhub !

a1exsh commented 2 years ago

I wonder how the scaling for the fullscreen mode is currently handled? It looks like when you use a resolution lower than the current, it gets scaled up to the current screen resolution (by SDL?)

Could it not be made work the other way around — that is, scaling down to a resolution lower than the minimum?

ihhub commented 2 years ago

By right SDL must handle scaling properly if user sets the original resolution. I'm more surprised to see resolution lower than the original. I remember we have a check for this.

ihhub commented 2 years ago

My bad: we check only with static assertion. To fix the issue we must validate that the minimum resolution is equal or higher than the original one. If it's smaller we must force to 640x480.

ihhub commented 2 years ago

@Wolod , are you able to test a custom build on your console?

Wolod commented 2 years ago

@ihhub , I'll be glad to help. Please provide me with a download link for the custom Ubuntu SDL2 build.

ihhub commented 2 years ago

Hi @Wolod , please try the latest snapshot in about an hour from now. The compilation should be done.

ihhub commented 2 years ago

@Wolod , forgot to mention: most likely you have to run in fullscreen mode or SDL 2 has ability to resize window.

Wolod commented 2 years ago

Hi @ihhub , UI scales properly now but the cursor is invisible. My friend compiled it from the source. He used cmake v.3.13.4, so that's might be the reason because minimum required is v.3.14. He'll try to recompile it on a newer version of cmake.

a1exsh commented 2 years ago

@Wolod just for fun, can you post the photos of scaled UI?

Wolod commented 2 years ago

@a1exsh here you go :)

IMG_20211015_142951 IMG_20211015_143015 IMG_20211015_143404

a1exsh commented 2 years ago

Nice!

Text written in the smallest font will be probably hard to read after scaling, e.g. number of troops in a hero's army, and so on. But it can still be playable!

ihhub commented 2 years ago

Great! Someone before asked about support for PSP so we can tell it works except memory issue 😅

romadu commented 2 years ago

The fix works on linux handheld game devices. Please note that this line means that gamecontroller is only initialised on Vita or Switch, so this #ifdef needed to be removed to allow game controllers to work on linux handheld and other devices with game controller support. Perhaps game controller support can be made generic, if sdl2 is supported. https://github.com/ihhub/fheroes2/blob/c79c9866f821a92b73622aadf2cff45d2d98e2ae/src/fheroes2/game/fheroes2.cpp#L150