FWGS / xash3d

DEPRECATED in favor of https://github.com/FWGS/xash3d-fwgs. Only bugfixes are accepted.
https://xash.su
GNU General Public License v3.0
553 stars 108 forks source link

[Port Request] WinRT (aka UWP) support #408

Open MoeMod opened 6 years ago

MoeMod commented 6 years ago

Nowadays Windows Tablets become popular, such as Surface lineup. However most of them are packaged with Windows 10 S where win32 app is not recommended, so UWP apps are preferred.

Possible solutions

  1. filesystem: SDL_WinRTGetFSPathUTF8 that returns somewhere in AppData
  2. library loader: LoadPackagedLibrary
  3. video: Angle project (https://github.com/Microsoft/angle) that are supported by SDL2
  4. network: winsock2 (only need to change header)

Problems up to now

However, I had a hard time debugging SDL2 video initialization... so that the engine cannot be loaded.

MoeMod commented 6 years ago

The half-made VS project can be found on https://github.com/MoeMod/xash3d/tree/winrt-port

Additional files needed:

  1. SDL source code
  2. Angle binaries (libEGL.dll, libGLESv2.dll)

    Notes:

    • The GL initialization fails... hope someone can fix it
    • Win32 .dll binaries are not supported. All binaries should be compiled under WinRT (Windows Store App Support).
mittorn commented 6 years ago

What about library loading? Is LoadLibrary availiable in UWP? You need gl-wes-v2 to make GL it work with angle. It already used in WebGL port. And of cause adapt it for UWP, where libraries loaded (i think) different way

MoeMod commented 6 years ago

Libraries need to be compiled under WinRT. And then replace LoadLibrary by LoadPackagedLibrary.

MoeMod commented 6 years ago

In additional, WinRT projects only provides unicode APIs, so LoadPackagedLibrary accepts wchar_t * library path and needs some encodings. This should work: https://github.com/MoeMod/xash3d/blob/winrt-port/engine/common/library.c

mittorn commented 6 years ago

And how to load angle? We need to patch gl-wes-v2 to work on winrt and use angle

MoeMod commented 6 years ago

seems that angle (libEGL.dll, libGLESv2.dll) will be loaded by SDL2-UWP.

MoeMod commented 6 years ago

In my latest test, the engine fails when SDL_CreateWindow returns nullptr.

a1batross commented 6 years ago

You should try to run Xash Dedicated Server at least. If it runs well, then filesystem at least is ported correctly.

Don't know about UWP support state in SDL2, but looks like it abstracts graphics for us, so we can just create GLES2 context. You need only define XASH_GLES and XASH_WES and compile in gl-wes-v2 source code.

mittorn commented 6 years ago

gl-wes-v2 already works with SDL2. Just define XASH_SDL in it. And maybe some changes needed to build it on windows. I not tested it on win32.

a1batross commented 6 years ago

Yeah, I tried gl-wes-v2 before on Linux. Worked flawlessly! Sadly, using our forks of nanogl or gl-wes-v2 isn't intuitive enough. You need to clone repository with source and add them to engine build process, so compiler flags will be same.

HeadClot commented 5 years ago

Hey - Has there been any further progress made on this?

a1batross commented 5 years ago

Never heard that anyone is ported engine to UWP.