Loobinex / keeperfx-unofficial

KeeperFX - Unofficial release
60 stars 7 forks source link

SDL2 port #184

Closed Real-Gecko closed 4 years ago

Real-Gecko commented 4 years ago

Hey, guys! I'm back. This time with something serious: I ported the game to SDL2. I tried to keep changes at minimum, by simply replacing obsolete SDL functions with SDL2 equivalents. However there're is a change worth noting: full screen now works in SDL_WINDOW_FULLSCREEN_DESKTOP mode. Meaning any size settings for window are ignored, window is border less and is size of desktop. This was done to fix the bug that plagued SDL apps for ages: alt tabbing of the full screen app causes D3D device lost leading to app freeze. In SDL_WINDOW_FULLSCREEN_DESKTOP this problem does not exist as there's no video mode switch thus no device is lost. I played few levels from original campaign and a couple of levels from Deeper Dungeons, I've even played full moon level, everything seems to work fine. However I was not able to test network play. And also I tested using WINE, so maybe some trouble can arise while playing on winduz. Anyway testing and feedback is highly appreciated. Thanks!

Real-Gecko commented 4 years ago

Also thing to note: I tested in various resolutions 640x480w32, 800x600w32, 1366x768x32. Alas I was unable to test 1920x1080x32.

Loobinex commented 4 years ago

Thanks Gecko, I'll look at it for sure. It needs some real good testing, because this is the third attempt at porting to SDL2, the previous 2 times there were issues.

Real-Gecko commented 4 years ago

If some issues arise I'm ready to fix 'em.

Loobinex commented 4 years ago

I build it, and copied 2 dlls into my keeperfx install, but the game doesn't run like this. image

Real-Gecko commented 4 years ago

I build it, and copied 2 dlls into my keeperfx install, but the game doesn't run like this.

It requires SDL2_mixer.dll, SDL2_net.dll and SDL2.dll you can find them inside sdl dir:

sdl/bin/SDL2.dll
sdl/lib/SDL2_mixer.dll
sdl/lib/SDL2_net.dll

Those from keeperfx-0.4.7 are a bit outdated:

$ exiftool SDL2.dll
ExifTool Version Number         : 12.00
File Name                       : SDL2.dll
Directory                       : .
File Size                       : 984 kB
File Modification Date/Time     : 2014:03:16 02:33:24+00:00
File Access Date/Time           : 2020:07:28 06:14:17+00:00
File Inode Change Date/Time     : 2020:07:28 06:14:17+00:00
File Permissions                : rw-r--r--
File Type                       : Win32 DLL
File Type Extension             : dll
MIME Type                       : application/octet-stream
Machine Type                    : Intel 386 or later, and compatibles
Time Stamp                      : 2014:03:16 02:33:24+00:00
Image File Characteristics      : Executable, No line numbers, No symbols, 32-bit, No debug, DLL
PE Type                         : PE32
Linker Version                  : 2.23
Code Size                       : 870912
Initialized Data Size           : 1006080
Uninitialized Data Size         : 13312
Entry Point                     : 0x1430
OS Version                      : 4.0
Image Version                   : 1.0
Subsystem Version               : 4.0
Subsystem                       : Windows command line
File Version Number             : 2.0.3.0
Product Version Number          : 2.0.3.0
File Flags Mask                 : 0x003f
File Flags                      : (none)
File OS                         : Windows NT 32-bit
Object File Type                : Dynamic link library
File Subtype                    : 0
Language Code                   : English (U.S.)
Character Set                   : Unicode
Company Name                    : 
File Description                : SDL
File Version                    : 2, 0, 3, 0
Internal Name                   : SDL
Legal Copyright                 : Copyright © 2014 Sam Lantinga
Original File Name              : SDL2.dll
Product Name                    : Simple DirectMedia Layer
Product Version                 : 2, 0, 3, 0
Real-Gecko commented 4 years ago

By the way, guys, what build environment and IDEs do you use for development? Just curious how you setup your workspace for KeeperFX.

Loobinex commented 4 years ago

With the proper DLLs it launches now, thanks.

I build with WSL, and use VisualStudio to code. Be sure to join the keeperklan discord and tell me it's you, and I'll add you to the development channel.

Loobinex commented 4 years ago

With this branch, windows mode is broken. When you switch the resolution from full screen to windowed mode, you get a black screen with a white square the size that the windows should be.

Real-Gecko commented 4 years ago

I'll check this out.

Loobinex commented 4 years ago

I tested it a bit, and found no problems. This is a very technical PR however, and I do not feel qualified to review it myself. I've asked in the development channel if somebody else is looking to weight in. If not, I'll merge anyway.

Loobinex commented 4 years ago

I tested it, and it seems to have broken the 'altinput' command line option. This means it's no longer possible to move your windows when playing in windowed mode.

Real-Gecko commented 4 years ago

I tested it, and it seems to have broken the 'altinput' command line option. This means it's no longer possible to move your windows when playing in windowed mode.

This option makes it so that mouse input is not grabbed by the window, so mouse can leave it's borders freeely: https://github.com/Loobinex/keeperfx-unofficial/blob/c893397dc0abddc7c6628d42ab1ffbdaa6113a4b/src/bflib_inputctrl.cpp#L348-L354 And even though I don't find that mode really useful, especially in creature view mode I can implement it with SDL2 too.

But IMO it's better to implement some kind of hot key to grab and ungrab mouse by window like it's done in DOSBox.

Loobinex commented 4 years ago

I agree that a hotkey would be better than a command line option.

Is it easy to just enable the old behavior for SDL2? If so, my suggestion would be to give back that old functionality first. And then if somebody ever managed to make it work through a hotkey, remove it at that point and clean it up altogether.

Real-Gecko commented 4 years ago

Is it easy to just enable the old behavior for SDL2?

Did that.

Loobinex commented 4 years ago

Great, will retest tonight.

Real-Gecko commented 4 years ago

And then if somebody ever managed to make it work through a hotkey, remove it at that point and clean it up altogether.

Yup, maybe later, currently I'm working on getting rid of dllimports, not much to be seen or tested for now, but with time I think things will become better.

Loobinex commented 4 years ago

altinput works great now, better than before.

However, small resolutions now give just a small screen instead if it stretching: image

My native resolution is 1920x1080 and I configured the game like: INGAME_RES=1280x1024x768